/work/obj-fuzz/dist/include/nsCSSAnonBoxes.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | /* atom list for CSS anonymous boxes */ |
8 | | |
9 | | #ifndef nsCSSAnonBoxes_h___ |
10 | | #define nsCSSAnonBoxes_h___ |
11 | | |
12 | | #include "nsAtom.h" |
13 | | #include "nsGkAtoms.h" |
14 | | |
15 | | class nsCSSAnonBoxes { |
16 | | public: |
17 | | static bool IsAnonBox(nsAtom *aAtom); |
18 | | #ifdef MOZ_XUL |
19 | | static bool IsTreePseudoElement(nsAtom* aPseudo); |
20 | | #endif |
21 | | static bool IsNonElement(nsAtom* aPseudo) |
22 | | { |
23 | | return aPseudo == nsCSSAnonBoxes::mozText() || |
24 | | aPseudo == nsCSSAnonBoxes::oofPlaceholder() || |
25 | | aPseudo == nsCSSAnonBoxes::firstLetterContinuation(); |
26 | | } |
27 | | |
28 | | typedef uint8_t NonInheritingBase; |
29 | | enum class NonInheriting : NonInheritingBase { |
30 | | #define CSS_ANON_BOX(_name, _value) /* nothing */ |
31 | | #define CSS_NON_INHERITING_ANON_BOX(_name, _value) _name, |
32 | | #include "nsCSSAnonBoxList.h" |
33 | | #undef CSS_NON_INHERITING_ANON_BOX |
34 | | #undef CSS_ANON_BOX |
35 | | _Count |
36 | | }; |
37 | | |
38 | | // Be careful using this: if we have a lot of non-inheriting anon box types it |
39 | | // might not be very fast. We may want to think of ways to handle that |
40 | | // (e.g. by moving to an enum instead of an atom, like we did for |
41 | | // pseudo-elements, or by adding a new value of the pseudo-element enum for |
42 | | // non-inheriting anon boxes or something). |
43 | | static bool IsNonInheritingAnonBox(nsAtom* aPseudo) |
44 | | { |
45 | | return |
46 | | #define CSS_ANON_BOX(_name, _value) /* nothing */ |
47 | | #define CSS_NON_INHERITING_ANON_BOX(_name, _value) \ |
48 | | nsGkAtoms::AnonBox_##_name == aPseudo || |
49 | | #include "nsCSSAnonBoxList.h" |
50 | | #undef CSS_NON_INHERITING_ANON_BOX |
51 | | #undef CSS_ANON_BOX |
52 | | false; |
53 | | } |
54 | | |
55 | | #ifdef DEBUG |
56 | | // NOTE(emilio): DEBUG only because this does a pretty slow linear search. Try |
57 | | // to use IsNonInheritingAnonBox if you know the atom is an anon box already |
58 | | // or, even better, nothing like this. Note that this function returns true |
59 | | // for wrapper anon boxes as well, since they're all inheriting. |
60 | | static bool IsInheritingAnonBox(nsAtom* aPseudo) |
61 | | { |
62 | | return |
63 | | #define CSS_ANON_BOX(_name, _value) nsGkAtoms::AnonBox_##_name == aPseudo || |
64 | | #define CSS_NON_INHERITING_ANON_BOX(_name, _value) /* nothing */ |
65 | | #include "nsCSSAnonBoxList.h" |
66 | | #undef CSS_NON_INHERITING_ANON_BOX |
67 | | #undef CSS_ANON_BOX |
68 | | false; |
69 | | } |
70 | | #endif // DEBUG |
71 | | |
72 | | // This function is rather slow; you probably don't want to use it outside |
73 | | // asserts unless you have to. |
74 | | static bool IsWrapperAnonBox(nsAtom* aPseudo) { |
75 | | // We commonly get null passed here, and want to quickly return false for |
76 | | // it. |
77 | | return aPseudo && |
78 | | ( |
79 | | #define CSS_ANON_BOX(_name, _value) /* nothing */ |
80 | | #define CSS_WRAPPER_ANON_BOX(_name, _value) nsGkAtoms::AnonBox_##_name == aPseudo || |
81 | | #define CSS_NON_INHERITING_ANON_BOX(_name, _value) /* nothing */ |
82 | | #include "nsCSSAnonBoxList.h" |
83 | | #undef CSS_NON_INHERITING_ANON_BOX |
84 | | #undef CSS_WRAPPER_ANON_BOX |
85 | | #undef CSS_ANON_BOX |
86 | | false); |
87 | | } |
88 | | |
89 | | // Get the NonInheriting type for a given pseudo tag. The pseudo tag must |
90 | | // test true for IsNonInheritingAnonBox. |
91 | | static NonInheriting NonInheritingTypeForPseudoTag(nsAtom* aPseudo); |
92 | | |
93 | | #ifdef DEBUG |
94 | | static void AssertAtoms(); |
95 | | #endif |
96 | | |
97 | | // Alias nsCSSAnonBoxes::foo() to alias nsGkAtoms::AnonBox_foo. |
98 | | // XXX Once nsGkAtoms::AnonBox_foo become constexpr variables, these can too. |
99 | | // See bug 1449787. |
100 | | #define CSS_ANON_BOX(name_, value_) \ |
101 | | static constexpr nsICSSAnonBoxPseudo* const& name_() \ |
102 | 0 | { \ |
103 | 0 | return nsGkAtoms::AnonBox_##name_; \ |
104 | 0 | } Unexecuted instantiation: nsCSSAnonBoxes::htmlCanvasContent() Unexecuted instantiation: nsCSSAnonBoxes::mozSVGForeignContent() Unexecuted instantiation: nsCSSAnonBoxes::mozSVGText() |
105 | | #include "nsCSSAnonBoxList.h" |
106 | | #undef CSS_ANON_BOX |
107 | | }; |
108 | | |
109 | | #endif /* nsCSSAnonBoxes_h___ */ |