nsCSSAnonBoxes.h (2188B)
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 "mozilla/PseudoStyleType.h" 13 #include "nsAtom.h" 14 #include "nsGkAtoms.h" 15 16 class nsCSSAnonBoxes { 17 using PseudoStyleType = mozilla::PseudoStyleType; 18 using PseudoStyle = mozilla::PseudoStyle; 19 20 public: 21 static bool IsTreePseudoElement(nsAtom* aPseudo); 22 static bool IsNonElement(PseudoStyleType aPseudo) { 23 return aPseudo == PseudoStyleType::mozText || 24 aPseudo == PseudoStyleType::oofPlaceholder || 25 aPseudo == PseudoStyleType::firstLetterContinuation; 26 } 27 28 enum class NonInheriting : uint8_t { 29 #define CSS_ANON_BOX(_name, _value) /* nothing */ 30 #define CSS_NON_INHERITING_ANON_BOX(_name, _value) _name, 31 #include "nsCSSAnonBoxList.h" 32 #undef CSS_NON_INHERITING_ANON_BOX 33 #undef CSS_ANON_BOX 34 _Count 35 }; 36 37 // Get the NonInheriting type for a given pseudo tag. The pseudo tag must 38 // test true for IsNonInheritingAnonBox. 39 static NonInheriting NonInheritingTypeForPseudoType(PseudoStyleType aType) { 40 MOZ_ASSERT(PseudoStyle::IsNonInheritingAnonBox(aType)); 41 static_assert(sizeof(PseudoStyleType) == sizeof(uint8_t), ""); 42 return static_cast<NonInheriting>( 43 static_cast<uint8_t>(aType) - 44 static_cast<uint8_t>(PseudoStyleType::NonInheritingAnonBoxesStart)); 45 } 46 47 #ifdef DEBUG 48 static nsStaticAtom* GetAtomBase(); 49 static void AssertAtoms(); 50 #endif 51 52 // Alias nsCSSAnonBoxes::foo() to nsGkAtoms::AnonBox_foo. 53 #define CSS_ANON_BOX(name_, value_) \ 54 static nsCSSAnonBoxPseudoStaticAtom* name_() { \ 55 return const_cast<nsCSSAnonBoxPseudoStaticAtom*>( \ 56 static_cast<const nsCSSAnonBoxPseudoStaticAtom*>( \ 57 nsGkAtoms::AnonBox_##name_)); \ 58 } 59 #include "nsCSSAnonBoxList.h" 60 #undef CSS_ANON_BOX 61 }; 62 63 #endif /* nsCSSAnonBoxes_h___ */