Bug 1269976 part 1 - Move CSSPseudoElements_flags to a static array in nsCSSPseudoElements. r=heycam
MozReview-Commit-ID: HWMuRrakCia
--- a/layout/style/nsCSSPseudoElements.cpp
+++ b/layout/style/nsCSSPseudoElements.cpp
@@ -31,17 +31,18 @@ static const nsStaticAtom CSSPseudoEleme
NS_STATIC_ATOM(name_##_pseudo_element_buffer, (nsIAtom**)&nsCSSPseudoElements::name_),
#include "nsCSSPseudoElementList.h"
#undef CSS_PSEUDO_ELEMENT
};
// 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"
#undef CSS_PSEUDO_ELEMENT
};
void nsCSSPseudoElements::AddRefAtoms()
{
@@ -100,23 +101,14 @@ nsCSSPseudoElements::GetPseudoType(nsIAt
/* static */ nsIAtom*
nsCSSPseudoElements::GetPseudoAtom(Type aType)
{
NS_ASSERTION(aType < Type::Count, "Unexpected type");
return *CSSPseudoElements_info[
static_cast<CSSPseudoElementTypeBase>(aType)].mAtom;
}
-/* static */ uint32_t
-nsCSSPseudoElements::FlagsForPseudoElement(const Type aType)
-{
- CSSPseudoElementTypeBase index = static_cast<CSSPseudoElementTypeBase>(aType);
- NS_ASSERTION(index < ArrayLength(CSSPseudoElements_flags),
- "argument must be a pseudo-element");
- return CSSPseudoElements_flags[index];
-}
-
/* static */ bool
nsCSSPseudoElements::PseudoElementSupportsUserActionState(const Type aType)
{
return PseudoElementHasFlags(aType,
CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE);
}
--- a/layout/style/nsCSSPseudoElements.h
+++ b/layout/style/nsCSSPseudoElements.h
@@ -96,18 +96,19 @@ public:
static bool PseudoElementSupportsUserActionState(const Type aType);
static bool PseudoElementIsUASheetOnly(const Type aType) {
MOZ_ASSERT(aType < Type::Count);
return PseudoElementHasFlags(aType, CSS_PSEUDO_ELEMENT_UA_SHEET_ONLY);
}
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___ */