Bug 1269976 part 1 - Move CSSPseudoElements_flags to a static array in nsCSSPseudoElements. r=heycam draft
authorXidorn Quan <quanxunzhen@gmail.com>
Thu, 05 May 2016 13:35:10 +1000
changeset 364715 0bb39430699c0af285372e3a65caa4c2f7181535
parent 364714 3c2419b9a29d11cfcc8dcf7a4a48f5373c021af7
child 364716 f1ced8cda86ceab01c4e770d7fa15498852c51dc
push id17555
push userxquan@mozilla.com
push dateMon, 09 May 2016 07:00:07 +0000
reviewersheycam
bugs1269976
milestone49.0a1
Bug 1269976 part 1 - Move CSSPseudoElements_flags to a static array in nsCSSPseudoElements. r=heycam MozReview-Commit-ID: HWMuRrakCia
layout/style/nsCSSPseudoElements.cpp
layout/style/nsCSSPseudoElements.h
--- 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___ */