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
15 // The kind of pseudo-style that we have. This can be:
17 // * CSS pseudo-elements (see nsCSSPseudoElements.h).
18 // * Anonymous boxes (see nsCSSAnonBoxes.h).
19 // * XUL tree pseudo-element stuff.
21 // This roughly corresponds to the `PseudoElement` enum in Rust code.
22 enum class PseudoStyleType
: uint8_t {
23 // If CSS pseudo-elements stop being first here, change GetPseudoType.
24 #define CSS_PSEUDO_ELEMENT(_name, _value, _flags) _name,
25 #include "nsCSSPseudoElementList.h"
26 #undef CSS_PSEUDO_ELEMENT
28 AnonBoxesStart
= CSSPseudoElementsEnd
,
29 InheritingAnonBoxesStart
= CSSPseudoElementsEnd
,
31 // Dummy variant so the next variant also has the same discriminant as
33 __reset_1
= AnonBoxesStart
- 1,
35 #define CSS_ANON_BOX(_name, _str) _name,
36 #define CSS_NON_INHERITING_ANON_BOX(_name, _str)
37 #define CSS_WRAPPER_ANON_BOX(_name, _str)
38 #include "nsCSSAnonBoxList.h"
40 #undef CSS_WRAPPER_ANON_BOX
41 #undef CSS_NON_INHERITING_ANON_BOX
43 // Wrapper anon boxes are inheriting anon boxes.
44 WrapperAnonBoxesStart
,
46 // Dummy variant so the next variant also has the same discriminant as
47 // WrapperAnonBoxesStart.
48 __reset_2
= WrapperAnonBoxesStart
- 1,
50 #define CSS_ANON_BOX(_name, _str)
51 #define CSS_NON_INHERITING_ANON_BOX(_name, _str)
52 #define CSS_WRAPPER_ANON_BOX(_name, _str) _name,
53 #include "nsCSSAnonBoxList.h"
55 #undef CSS_WRAPPER_ANON_BOX
56 #undef CSS_NON_INHERITING_ANON_BOX
59 InheritingAnonBoxesEnd
= WrapperAnonBoxesEnd
,
60 NonInheritingAnonBoxesStart
= WrapperAnonBoxesEnd
,
62 __reset_3
= NonInheritingAnonBoxesStart
- 1,
64 #define CSS_ANON_BOX(_name, _str)
65 #define CSS_NON_INHERITING_ANON_BOX(_name, _str) _name,
66 #include "nsCSSAnonBoxList.h"
68 #undef CSS_NON_INHERITING_ANON_BOX
70 NonInheritingAnonBoxesEnd
,
71 AnonBoxesEnd
= NonInheritingAnonBoxesEnd
,
73 XULTree
= AnonBoxesEnd
,
78 std::ostream
& operator<<(std::ostream
&, PseudoStyleType
);
80 class PseudoStyle final
{
82 using Type
= PseudoStyleType
;
84 // This must match EAGER_PSEUDO_COUNT in Rust code.
85 static const size_t kEagerPseudoCount
= 4;
87 static bool IsPseudoElement(Type aType
) {
88 return aType
< Type::CSSPseudoElementsEnd
;
91 static bool IsAnonBox(Type aType
) {
92 return aType
>= Type::AnonBoxesStart
&& aType
< Type::AnonBoxesEnd
;
95 static bool IsInheritingAnonBox(Type aType
) {
96 return aType
>= Type::InheritingAnonBoxesStart
&&
97 aType
< Type::InheritingAnonBoxesEnd
;
100 static bool IsNonInheritingAnonBox(Type aType
) {
101 return aType
>= Type::NonInheritingAnonBoxesStart
&&
102 aType
< Type::NonInheritingAnonBoxesEnd
;
105 static bool IsWrapperAnonBox(Type aType
) {
106 return aType
>= Type::WrapperAnonBoxesStart
&&
107 aType
< Type::WrapperAnonBoxesEnd
;
111 } // namespace mozilla