Bug 1403808 - Move mFrameRefCount to GeckoStyleContext; r?emilio draft
authorManish Goregaokar <manishearth@gmail.com>
Wed, 27 Sep 2017 20:22:52 -0700
changeset 671587 d4e68df87847dff3914be97f7b1de4bb109f15ef
parent 671268 756e10aa8bbd416cbc49b7739f78fb81d5525477
child 733559 858f15ce71eb1578204c85c6c9d7d3aed3bd0c61
push id81981
push userbmo:manishearth@gmail.com
push dateThu, 28 Sep 2017 03:23:03 +0000
reviewersemilio
bugs1403808
milestone58.0a1
Bug 1403808 - Move mFrameRefCount to GeckoStyleContext; r?emilio MozReview-Commit-ID: 3ZlvXVlgR6i
layout/style/GeckoStyleContext.cpp
layout/style/GeckoStyleContext.h
layout/style/nsStyleContext.cpp
layout/style/nsStyleContext.h
--- a/layout/style/GeckoStyleContext.cpp
+++ b/layout/style/GeckoStyleContext.cpp
@@ -40,16 +40,17 @@ GeckoStyleContext::GeckoStyleContext(Gec
   , mCachedResetData(nullptr)
   , mRefCnt(0)
   , mChild(nullptr)
   , mEmptyChild(nullptr)
   , mRuleNode(Move(aRuleNode))
   , mParent(aParent)
 #ifdef DEBUG
   , mComputingStruct(nsStyleStructID_None)
+  , mFrameRefCnt(0)
 #endif
 {
   mBits |= NS_STYLE_CONTEXT_IS_GECKO;
 
   if (aParent) {
 #ifdef DEBUG
     nsRuleNode *r1 = mParent->RuleNode(), *r2 = mRuleNode;
     while (r1->GetParent())
--- a/layout/style/GeckoStyleContext.h
+++ b/layout/style/GeckoStyleContext.h
@@ -285,21 +285,34 @@ public:
     }
 
     ~AutoCheckDependency()
     {
       mStyleContext->mComputingStruct = mOuterSID;
     }
   };
 
+  void FrameAddRef() {
+    ++mFrameRefCnt;
+  }
+
+  void FrameRelease() {
+    --mFrameRefCnt;
+  }
+
+  uint32_t FrameRefCnt() const {
+    return mFrameRefCnt;
+  }
 private:
   // Used to check for undeclared dependencies.
   // See AUTO_CHECK_DEPENDENCY in nsStyleContextInlines.h.
   nsStyleStructID         mComputingStruct;
 
+  uint32_t                mFrameRefCnt; // number of frames that use this
+                                        // as their style context
 #define AUTO_CHECK_DEPENDENCY(gecko_, sid_) \
   mozilla::GeckoStyleContext::AutoCheckDependency checkNesting_(gecko_, sid_)
 #else
 #define AUTO_CHECK_DEPENDENCY(gecko_, sid_)
 #endif
 };
 }
 
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -77,19 +77,16 @@ const uint32_t nsStyleContext::sDependen
 };
 
 #endif
 
 nsStyleContext::nsStyleContext(nsIAtom* aPseudoTag,
                                CSSPseudoElementType aPseudoType)
   : mPseudoTag(aPseudoTag)
   , mBits(((uint64_t)aPseudoType) << NS_STYLE_CONTEXT_TYPE_SHIFT)
-#ifdef DEBUG
-  , mFrameRefCnt(0)
-#endif
 {
   // This check has to be done "backward", because if it were written the
   // more natural way it wouldn't fail even when it needed to.
   static_assert((UINT64_MAX >> NS_STYLE_CONTEXT_TYPE_SHIFT) >=
                  static_cast<CSSPseudoElementTypeBase>(
                    CSSPseudoElementType::MAX),
                 "pseudo element bits no longer fit in a uint64_t");
 
@@ -562,9 +559,25 @@ nsStyleContext::LookupStruct(const nsACS
   else if (aName.EqualsLiteral(#name_))                                       \
     aResult = eStyleStruct_##name_;
 #include "nsStyleStructList.h"
 #undef STYLE_STRUCT
   else
     return false;
   return true;
 }
+
+void
+nsStyleContext::FrameAddRef()
+{
+  if (auto gecko = GetAsGecko()) {
+    gecko->FrameAddRef();
+  }
+}
+
+void
+nsStyleContext::FrameRelease()
+{
+  if (auto gecko = GetAsGecko()) {
+    gecko->FrameRelease();
+  }
+}
 #endif
--- a/layout/style/nsStyleContext.h
+++ b/layout/style/nsStyleContext.h
@@ -68,27 +68,18 @@ public:
     return mozilla::eArenaObjectID_GeckoStyleContext;
   }
   nsIPresShell* Arena();
 
   inline void AddRef();
   inline void Release();
 
 #ifdef DEBUG
-  void FrameAddRef() {
-    ++mFrameRefCnt;
-  }
-
-  void FrameRelease() {
-    --mFrameRefCnt;
-  }
-
-  uint32_t FrameRefCnt() const {
-    return mFrameRefCnt;
-  }
+  void FrameAddRef();
+  void FrameRelease();
 #endif
 
   inline nsPresContext* PresContext() const;
 
   nsIAtom* GetPseudo() const { return mPseudoTag; }
   mozilla::CSSPseudoElementType GetPseudoType() const {
     return static_cast<mozilla::CSSPseudoElementType>(
              mBits >> NS_STYLE_CONTEXT_TYPE_SHIFT);
@@ -345,19 +336,16 @@ protected:
   //  - It records (using the style struct bits) which structs are
   //    inherited from the parent context or owned by the rule node (i.e.,
   //    not owned by the style context).
   //  - It also stores the additional bits listed at the top of
   //    nsStyleStruct.h.
   uint64_t                mBits;
 
 #ifdef DEBUG
-  uint32_t                mFrameRefCnt; // number of frames that use this
-                                        // as their style context
-
   static bool DependencyAllowed(nsStyleStructID aOuterSID,
                                 nsStyleStructID aInnerSID)
   {
     return !!(sDependencyTable[aOuterSID] &
               nsCachedStyleData::GetBitForSID(aInnerSID));
   }
 
   static const uint32_t sDependencyTable[];