Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / layout / style / PseudoStyleType.h
blob6804b500c38d3cbc90910ecd643aad26b3db8c86
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
10 #include <cstdint>
11 #include <iosfwd>
13 namespace mozilla {
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
27 CSSPseudoElementsEnd,
28 AnonBoxesStart = CSSPseudoElementsEnd,
29 InheritingAnonBoxesStart = CSSPseudoElementsEnd,
31 // Dummy variant so the next variant also has the same discriminant as
32 // AnonBoxesStart.
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"
39 #undef CSS_ANON_BOX
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"
54 #undef CSS_ANON_BOX
55 #undef CSS_WRAPPER_ANON_BOX
56 #undef CSS_NON_INHERITING_ANON_BOX
58 WrapperAnonBoxesEnd,
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"
67 #undef CSS_ANON_BOX
68 #undef CSS_NON_INHERITING_ANON_BOX
70 NonInheritingAnonBoxesEnd,
71 AnonBoxesEnd = NonInheritingAnonBoxesEnd,
73 XULTree = AnonBoxesEnd,
74 NotPseudo,
75 MAX
78 std::ostream& operator<<(std::ostream&, PseudoStyleType);
80 class PseudoStyle final {
81 public:
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
113 #endif