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/. */
7 #ifndef mozilla_PseudoStyleType_h
8 #define mozilla_PseudoStyleType_h
16 // The kind of pseudo-style that we have. This can be:
18 // * CSS pseudo-elements (see nsCSSPseudoElements.h).
19 // * Anonymous boxes (see nsCSSAnonBoxes.h).
20 // * XUL tree pseudo-element stuff.
22 // This roughly corresponds to the `PseudoElement` enum in Rust code.
23 enum class PseudoStyleType
: uint8_t {
24 // If CSS pseudo-elements stop being first here, change GetPseudoType.
25 #define CSS_PSEUDO_ELEMENT(_name, _value, _flags) _name,
26 #include "nsCSSPseudoElementList.h"
27 #undef CSS_PSEUDO_ELEMENT
29 AnonBoxesStart
= CSSPseudoElementsEnd
,
30 InheritingAnonBoxesStart
= CSSPseudoElementsEnd
,
32 // Dummy variant so the next variant also has the same discriminant as
34 __reset_1
= AnonBoxesStart
- 1,
36 #define CSS_ANON_BOX(_name, _str) _name,
37 #define CSS_NON_INHERITING_ANON_BOX(_name, _str)
38 #define CSS_WRAPPER_ANON_BOX(_name, _str)
39 #include "nsCSSAnonBoxList.h"
41 #undef CSS_WRAPPER_ANON_BOX
42 #undef CSS_NON_INHERITING_ANON_BOX
44 // Wrapper anon boxes are inheriting anon boxes.
45 WrapperAnonBoxesStart
,
47 // Dummy variant so the next variant also has the same discriminant as
48 // WrapperAnonBoxesStart.
49 __reset_2
= WrapperAnonBoxesStart
- 1,
51 #define CSS_ANON_BOX(_name, _str)
52 #define CSS_NON_INHERITING_ANON_BOX(_name, _str)
53 #define CSS_WRAPPER_ANON_BOX(_name, _str) _name,
54 #include "nsCSSAnonBoxList.h"
56 #undef CSS_WRAPPER_ANON_BOX
57 #undef CSS_NON_INHERITING_ANON_BOX
60 InheritingAnonBoxesEnd
= WrapperAnonBoxesEnd
,
61 NonInheritingAnonBoxesStart
= WrapperAnonBoxesEnd
,
63 __reset_3
= NonInheritingAnonBoxesStart
- 1,
65 #define CSS_ANON_BOX(_name, _str)
66 #define CSS_NON_INHERITING_ANON_BOX(_name, _str) _name,
67 #include "nsCSSAnonBoxList.h"
69 #undef CSS_NON_INHERITING_ANON_BOX
71 NonInheritingAnonBoxesEnd
,
72 AnonBoxesEnd
= NonInheritingAnonBoxesEnd
,
74 XULTree
= AnonBoxesEnd
,
79 std::ostream
& operator<<(std::ostream
&, PseudoStyleType
);
81 class PseudoStyle final
{
83 using Type
= PseudoStyleType
;
85 // This must match EAGER_PSEUDO_COUNT in Rust code.
86 static const size_t kEagerPseudoCount
= 4;
88 static bool IsPseudoElement(Type aType
) {
89 return aType
< Type::CSSPseudoElementsEnd
;
92 static bool IsAnonBox(Type aType
) {
93 return aType
>= Type::AnonBoxesStart
&& aType
< Type::AnonBoxesEnd
;
96 static bool IsInheritingAnonBox(Type aType
) {
97 return aType
>= Type::InheritingAnonBoxesStart
&&
98 aType
< Type::InheritingAnonBoxesEnd
;
101 static bool IsNonInheritingAnonBox(Type aType
) {
102 return aType
>= Type::NonInheritingAnonBoxesStart
&&
103 aType
< Type::NonInheritingAnonBoxesEnd
;
106 static bool IsWrapperAnonBox(Type aType
) {
107 return aType
>= Type::WrapperAnonBoxesStart
&&
108 aType
< Type::WrapperAnonBoxesEnd
;
112 } // namespace mozilla