|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 /* atom list for CSS pseudo-elements */ |
|
7 |
|
8 #ifndef nsCSSPseudoElements_h___ |
|
9 #define nsCSSPseudoElements_h___ |
|
10 |
|
11 #include "nsIAtom.h" |
|
12 |
|
13 // Is this pseudo-element a CSS2 pseudo-element that can be specified |
|
14 // with the single colon syntax (in addition to the double-colon syntax, |
|
15 // which can be used for all pseudo-elements)? |
|
16 #define CSS_PSEUDO_ELEMENT_IS_CSS2 (1<<0) |
|
17 // Is this pseudo-element a pseudo-element that can contain other |
|
18 // elements? |
|
19 // (Currently pseudo-elements are either leaves of the tree (relative to |
|
20 // real elements) or they contain other elements in a non-tree-like |
|
21 // manner (i.e., like incorrectly-nested start and end tags). It's |
|
22 // possible that in the future there might be container pseudo-elements |
|
23 // that form a properly nested tree structure. If that happens, we |
|
24 // should probably split this flag into two.) |
|
25 #define CSS_PSEUDO_ELEMENT_CONTAINS_ELEMENTS (1<<1) |
|
26 // Flag to add the ability to take into account style attribute set for the |
|
27 // pseudo element (by default it's ignored). |
|
28 #define CSS_PSEUDO_ELEMENT_SUPPORTS_STYLE_ATTRIBUTE (1<<2) |
|
29 // Flag that indicate the pseudo-element supports a user action pseudo-class |
|
30 // following it, such as :active or :hover. This would normally correspond |
|
31 // to whether the pseudo-element is tree-like, but we don't support these |
|
32 // pseudo-classes on ::before and ::after generated content yet. See |
|
33 // http://dev.w3.org/csswg/selectors4/#pseudo-elements. |
|
34 #define CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE (1<<3) |
|
35 // Is content prevented from parsing selectors containing this pseudo-element? |
|
36 #define CSS_PSEUDO_ELEMENT_IS_CHROME_ONLY (1<<4) |
|
37 |
|
38 // Empty class derived from nsIAtom so that function signatures can |
|
39 // require an atom from this atom list. |
|
40 class nsICSSPseudoElement : public nsIAtom {}; |
|
41 |
|
42 class nsCSSPseudoElements { |
|
43 public: |
|
44 |
|
45 static void AddRefAtoms(); |
|
46 |
|
47 static bool IsPseudoElement(nsIAtom *aAtom); |
|
48 |
|
49 static bool IsCSS2PseudoElement(nsIAtom *aAtom); |
|
50 |
|
51 #define CSS_PSEUDO_ELEMENT(_name, _value, _flags) \ |
|
52 static nsICSSPseudoElement* _name; |
|
53 #include "nsCSSPseudoElementList.h" |
|
54 #undef CSS_PSEUDO_ELEMENT |
|
55 |
|
56 enum Type { |
|
57 // If the actual pseudo-elements stop being first here, change |
|
58 // GetPseudoType. |
|
59 #define CSS_PSEUDO_ELEMENT(_name, _value_, _flags) \ |
|
60 ePseudo_##_name, |
|
61 #include "nsCSSPseudoElementList.h" |
|
62 #undef CSS_PSEUDO_ELEMENT |
|
63 ePseudo_PseudoElementCount, |
|
64 ePseudo_AnonBox = ePseudo_PseudoElementCount, |
|
65 #ifdef MOZ_XUL |
|
66 ePseudo_XULTree, |
|
67 #endif |
|
68 ePseudo_NotPseudoElement, |
|
69 ePseudo_MAX |
|
70 }; |
|
71 |
|
72 static Type GetPseudoType(nsIAtom* aAtom); |
|
73 |
|
74 // Get the atom for a given Type. aType must be < ePseudo_PseudoElementCount |
|
75 static nsIAtom* GetPseudoAtom(Type aType); |
|
76 |
|
77 static bool PseudoElementContainsElements(const Type aType) { |
|
78 return PseudoElementHasFlags(aType, CSS_PSEUDO_ELEMENT_CONTAINS_ELEMENTS); |
|
79 } |
|
80 |
|
81 static bool PseudoElementSupportsStyleAttribute(const Type aType) { |
|
82 MOZ_ASSERT(aType < ePseudo_PseudoElementCount); |
|
83 return PseudoElementHasFlags(aType, CSS_PSEUDO_ELEMENT_SUPPORTS_STYLE_ATTRIBUTE); |
|
84 } |
|
85 |
|
86 static bool PseudoElementSupportsUserActionState(const Type aType); |
|
87 |
|
88 static bool PseudoElementIsChromeOnly(const Type aType) { |
|
89 MOZ_ASSERT(aType < ePseudo_PseudoElementCount); |
|
90 return PseudoElementHasFlags(aType, CSS_PSEUDO_ELEMENT_IS_CHROME_ONLY); |
|
91 } |
|
92 |
|
93 private: |
|
94 static uint32_t FlagsForPseudoElement(const Type aType); |
|
95 |
|
96 // Does the given pseudo-element have all of the flags given? |
|
97 static bool PseudoElementHasFlags(const Type aType, uint32_t aFlags) |
|
98 { |
|
99 return (FlagsForPseudoElement(aType) & aFlags) == aFlags; |
|
100 } |
|
101 }; |
|
102 |
|
103 #endif /* nsCSSPseudoElements_h___ */ |