Bug 1419709 - Move a few nsStyleStructID-related static methods out of nsRuleNode.h r=emilio draft
authorCameron McCormack <cam@mcc.id.au>
Wed, 22 Nov 2017 18:08:33 +0800
changeset 701815 82923198db53f444e96419818c1da0b26179cbc0
parent 701687 59339a088272a6f3a637934b75d71f5ff23682ff
child 741289 ee88f4aa8db93d5c62f33d087cf609c059939be2
push id90297
push userbmo:cam@mcc.id.au
push dateWed, 22 Nov 2017 10:12:01 +0000
reviewersemilio
bugs1419709
milestone59.0a1
Bug 1419709 - Move a few nsStyleStructID-related static methods out of nsRuleNode.h r=emilio MozReview-Commit-ID: GyEMmvlH4mh
layout/inspector/inDOMUtils.cpp
layout/style/nsCSSProps.cpp
layout/style/nsStyleContext.h
--- a/layout/inspector/inDOMUtils.cpp
+++ b/layout/inspector/inDOMUtils.cpp
@@ -487,17 +487,17 @@ inDOMUtils::IsInheritedProperty(const ns
     return NS_OK;
   }
 
   if (nsCSSProps::IsShorthand(prop)) {
     prop = nsCSSProps::SubpropertyEntryFor(prop)[0];
   }
 
   nsStyleStructID sid = nsCSSProps::kSIDTable[prop];
-  *_retval = !nsCachedStyleData::IsReset(sid);
+  *_retval = !nsStyleContext::IsReset(sid);
   return NS_OK;
 }
 
 extern const char* const kCSSRawProperties[];
 
 NS_IMETHODIMP
 inDOMUtils::GetCSSPropertyNames(uint32_t aFlags, uint32_t* aCount,
                                 char16_t*** aProps)
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -494,17 +494,17 @@ nsCSSProps::ReleaseTable(void)
 }
 
 /* static */ bool
 nsCSSProps::IsInherited(nsCSSPropertyID aProperty)
 {
   MOZ_ASSERT(!IsShorthand(aProperty));
 
   nsStyleStructID sid = kSIDTable[aProperty];
-  return nsCachedStyleData::IsInherited(sid);
+  return nsStyleContext::IsInherited(sid);
 }
 
 /* static */ bool
 nsCSSProps::IsCustomPropertyName(const nsACString& aProperty)
 {
   // Custom properties don't need to have a character after the "--" prefix.
   return aProperty.Length() >= CSS_CUSTOM_NAME_PREFIX_LENGTH &&
          StringBeginsWith(aProperty, NS_LITERAL_CSTRING("--"));
--- a/layout/style/nsStyleContext.h
+++ b/layout/style/nsStyleContext.h
@@ -192,17 +192,17 @@ public:
 
   /**
    * Returns whether this style context has cached style data for a
    * given style struct and it does NOT own that struct.  This can
    * happen because it was inherited from the parent style context, or
    * because it was stored conditionally on the rule node.
    */
   bool HasCachedDependentStyleData(nsStyleStructID aSID) {
-    return mBits & nsCachedStyleData::GetBitForSID(aSID);
+    return mBits & GetBitForSID(aSID);
   }
 
   inline nsRuleNode* RuleNode();
   inline const ServoComputedData* ComputedData();
 
   void AddStyleBit(const uint64_t& aBit) { mBits |= aBit; }
 
   /**
@@ -287,16 +287,24 @@ public:
   static nscolor CombineVisitedColors(nscolor *aColors,
                                       bool aLinkIsVisited);
 
   /**
    * Start the background image loads for this style context.
    */
   inline void StartBackgroundImageLoads();
 
+  static bool IsReset(const nsStyleStructID aSID) {
+    MOZ_ASSERT(0 <= aSID && aSID < nsStyleStructID_Length,
+               "must be an inherited or reset SID");
+    return nsStyleStructID_Reset_Start <= aSID;
+  }
+  static bool IsInherited(const nsStyleStructID aSID) { return !IsReset(aSID); }
+  static uint32_t GetBitForSID(const nsStyleStructID aSID) { return 1 << aSID; }
+
 #ifdef DEBUG
   void List(FILE* out, int32_t aIndent, bool aListDescendants = true);
   static const char* StructName(nsStyleStructID aSID);
   static bool LookupStruct(const nsACString& aName, nsStyleStructID& aResult);
 #endif
 
 protected:
   // protected destructor to discourage deletion outside of Release()
@@ -329,18 +337,17 @@ protected:
   //  - It also stores the additional bits listed at the top of
   //    nsStyleStruct.h.
   uint64_t                mBits;
 
 #ifdef DEBUG
   static bool DependencyAllowed(nsStyleStructID aOuterSID,
                                 nsStyleStructID aInnerSID)
   {
-    return !!(sDependencyTable[aOuterSID] &
-              nsCachedStyleData::GetBitForSID(aInnerSID));
+    return !!(sDependencyTable[aOuterSID] & GetBitForSID(aInnerSID));
   }
 
   static const uint32_t sDependencyTable[];
 #endif
 };
 
 already_AddRefed<mozilla::GeckoStyleContext>
 NS_NewStyleContext(mozilla::GeckoStyleContext* aParentContext,