Bug 1289622 - Add the ability to store change hints on the style context. r=heycam
authorBobby Holley <bobbyholley@gmail.com>
Tue, 26 Jul 2016 12:58:43 -0700
changeset 346984 8801607503feb4314c1a8f9aaa96768fc3277f40
parent 346983 d5e026f11aa98bcce513ff357624dc4e3e610813
child 346985 196ddcbf522500350d90dfb8af8fbc6fb0f475c5
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1289622
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1289622 - Add the ability to store change hints on the style context. r=heycam
layout/style/nsStyleContext.cpp
layout/style/nsStyleContext.h
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -77,16 +77,22 @@ nsStyleContext::nsStyleContext(nsStyleCo
   , mPseudoTag(aPseudoTag)
   , mSource(Move(aSource))
 #ifdef MOZ_STYLO
   , mPresContext(nullptr)
 #endif
   , mCachedResetData(nullptr)
   , mBits(((uint64_t)aPseudoType) << NS_STYLE_CONTEXT_TYPE_SHIFT)
   , mRefCnt(0)
+#ifdef MOZ_STYLO
+  , mStoredChangeHint(nsChangeHint(0))
+#ifdef DEBUG
+  , mHasStoredChangeHint(false)
+#endif
+#endif
 #ifdef DEBUG
   , mFrameRefCnt(0)
   , mComputingStruct(nsStyleStructID_None)
 #endif
 {}
 
 nsStyleContext::nsStyleContext(nsStyleContext* aParent,
                                nsIAtom* aPseudoTag,
@@ -386,16 +392,20 @@ nsStyleContext::MoveTo(nsStyleContext* a
 }
 
 already_AddRefed<nsStyleContext>
 nsStyleContext::FindChildWithRules(const nsIAtom* aPseudoTag,
                                    NonOwningStyleContextSource aSource,
                                    NonOwningStyleContextSource aSourceIfVisited,
                                    bool aRelevantLinkVisited)
 {
+#ifdef MOZ_STYLO
+  MOZ_ASSERT(!mHasStoredChangeHint);
+#endif
+
   uint32_t threshold = 10; // The # of siblings we're willing to examine
                            // before just giving this whole thing up.
 
   RefPtr<nsStyleContext> result;
   nsStyleContext *list = aSource.MatchesNoRules() ? mEmptyChild : mChild;
 
   if (list) {
     nsStyleContext *child = list;
--- a/layout/style/nsStyleContext.h
+++ b/layout/style/nsStyleContext.h
@@ -522,16 +522,39 @@ public:
     } else {
       cachedData = mCachedInheritedData.mStyleStructs[aSID];
     }
     return cachedData;
   }
 
   mozilla::NonOwningStyleContextSource StyleSource() const { return mSource.AsRaw(); }
 
+#ifdef MOZ_STYLO
+  void StoreChangeHint(nsChangeHint aHint)
+  {
+    MOZ_ASSERT(!mHasStoredChangeHint);
+    MOZ_ASSERT(!IsShared());
+    mStoredChangeHint = aHint;
+#ifdef DEBUG
+    mHasStoredChangeHint = true;
+#endif
+  }
+
+  nsChangeHint ConsumeStoredChangeHint()
+  {
+    MOZ_ASSERT(mHasStoredChangeHint);
+    nsChangeHint result = mStoredChangeHint;
+    mStoredChangeHint = nsChangeHint(0);
+#ifdef DEBUG
+    mHasStoredChangeHint = false;
+#endif
+    return result;
+  }
+#endif
+
 private:
   // Private destructor, to discourage deletion outside of Release():
   ~nsStyleContext();
 
   // Delegated Helper constructor.
   nsStyleContext(nsStyleContext* aParent,
                  mozilla::OwningStyleContextSource&& aSource,
                  nsIAtom* aPseudoTag,
@@ -732,16 +755,25 @@ private:
   //    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;
 
   uint32_t                mRefCnt;
 
+  // For now we store change hints on the style context during parallel traversal.
+  // We should improve this - see bug 1289861.
+#ifdef MOZ_STYLO
+  nsChangeHint            mStoredChangeHint;
+#ifdef DEBUG
+  bool                    mHasStoredChangeHint;
+#endif
+#endif
+
 #ifdef DEBUG
   uint32_t                mFrameRefCnt; // number of frames that use this
                                         // as their style context
 
   nsStyleStructID         mComputingStruct;
 
   static bool DependencyAllowed(nsStyleStructID aOuterSID,
                                 nsStyleStructID aInnerSID)