From 85ca906802447ba68549a7ae1e4812661216e685 Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Tue, 10 May 2016 13:36:25 +1000 Subject: [PATCH] Bug 1269976 part 1 - Move CSSPseudoElements_flags to a static array in nsCSSPseudoElements. r=heycam MozReview-Commit-ID: HWMuRrakCia --HG-- extra : source : fca40d54c5270d09642f329267809fb3f7447c60 --- layout/style/nsCSSPseudoElements.cpp | 12 ++---------- layout/style/nsCSSPseudoElements.h | 7 ++++--- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/layout/style/nsCSSPseudoElements.cpp b/layout/style/nsCSSPseudoElements.cpp index 3323c5412ce7..8d584cac7f1e 100644 --- a/layout/style/nsCSSPseudoElements.cpp +++ b/layout/style/nsCSSPseudoElements.cpp @@ -36,7 +36,8 @@ static const nsStaticAtom CSSPseudoElements_info[] = { // Flags data for each of the pseudo-elements, which must be separate // from the previous array since there's no place for it in // nsStaticAtom. -static const uint32_t CSSPseudoElements_flags[] = { +/* static */ const uint32_t +nsCSSPseudoElements::kPseudoElementFlags[Type::Count] = { #define CSS_PSEUDO_ELEMENT(name_, value_, flags_) \ flags_, #include "nsCSSPseudoElementList.h" @@ -105,15 +106,6 @@ nsCSSPseudoElements::GetPseudoAtom(Type aType) static_cast(aType)].mAtom; } -/* static */ uint32_t -nsCSSPseudoElements::FlagsForPseudoElement(const Type aType) -{ - CSSPseudoElementTypeBase index = static_cast(aType); - NS_ASSERTION(index < ArrayLength(CSSPseudoElements_flags), - "argument must be a pseudo-element"); - return CSSPseudoElements_flags[index]; -} - /* static */ bool nsCSSPseudoElements::PseudoElementSupportsUserActionState(const Type aType) { diff --git a/layout/style/nsCSSPseudoElements.h b/layout/style/nsCSSPseudoElements.h index a3f7c16aa766..e079784e8542 100644 --- a/layout/style/nsCSSPseudoElements.h +++ b/layout/style/nsCSSPseudoElements.h @@ -101,13 +101,14 @@ public: } private: - static uint32_t FlagsForPseudoElement(const Type aType); - // Does the given pseudo-element have all of the flags given? static bool PseudoElementHasFlags(const Type aType, uint32_t aFlags) { - return (FlagsForPseudoElement(aType) & aFlags) == aFlags; + MOZ_ASSERT(aType < Type::Count); + return (kPseudoElementFlags[size_t(aType)] & aFlags) == aFlags; } + + static const uint32_t kPseudoElementFlags[Type::Count]; }; #endif /* nsCSSPseudoElements_h___ */