Bug 960465 patch 4 - Track whether there are any pending non-animation restyles. r=birtles
authorL. David Baron <dbaron@dbaron.org>
Tue, 17 Feb 2015 11:15:02 +1300
changeset 243817 b36e2a0e902f4d7004220490778751442a7e9238
parent 243816 d5fa940bfd9ccb26df75b4a572094a640b7c90c5
child 243818 0288ff191edf0ae7be2a2036920d4e777c49174b
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-esr52@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs960465, 1087536
milestone38.0a1
Bug 960465 patch 4 - Track whether there are any pending non-animation restyles. r=birtles This depends on bug 1087536 patch 3, which posts animation restyles using the eRestyle_CSSTransitions and eRestyle_CSSAnimations hints. This is used by patch 6.
layout/base/RestyleManager.cpp
layout/base/RestyleManager.h
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -66,16 +66,17 @@ RestyleManager::RestyleManager(nsPresCon
   : mPresContext(aPresContext)
   , mDoRebuildAllStyleData(false)
   , mInRebuildAllStyleData(false)
   , mObservingRefreshDriver(false)
   , mInStyleRefresh(false)
   , mSkipAnimationRules(false)
   , mPostAnimationRestyles(false)
   , mIsProcessingAnimationStyleChange(false)
+  , mHavePendingNonAnimationRestyles(false)
   , mHoverGeneration(0)
   , mRebuildAllExtraHint(nsChangeHint(0))
   , mRebuildAllRestyleHint(nsRestyleHint(0))
   , mLastUpdateForThrottledAnimations(aPresContext->RefreshDriver()->
                                         MostRecentRefresh())
   , mAnimationGeneration(0)
   , mReframingStyleContexts(nullptr)
   , mPendingRestyles(ELEMENT_HAS_PENDING_RESTYLE |
@@ -1683,16 +1684,18 @@ RestyleManager::ProcessPendingRestyles()
 
 #ifdef DEBUG
   mIsProcessingRestyles = false;
 #endif
   NS_POSTCONDITION(mPendingRestyles.Count() == oldPendingRestyleCount,
                    "We should not have posted new non-animation restyles while "
                    "processing animation restyles");
 
+  mHavePendingNonAnimationRestyles = false;
+
   if (mDoRebuildAllStyleData) {
     // We probably wasted a lot of work up above, but this seems safest
     // and it should be rarely used.
     // This might add us as a refresh observer again; that's ok.
     ProcessPendingRestyles();
 
     NS_ASSERTION(!mDoRebuildAllStyleData,
                  "repeatedly setting mDoRebuildAllStyleData?");
@@ -1781,16 +1784,29 @@ RestyleManager::PostRestyleEventCommon(E
     // Nothing to do here
     return;
   }
 
   RestyleTracker& tracker =
     aForAnimation ? mPendingAnimationRestyles : mPendingRestyles;
   tracker.AddPendingRestyle(aElement, aRestyleHint, aMinChangeHint);
 
+  // Set mHavePendingNonAnimationRestyles for any restyle that could
+  // possibly contain non-animation styles.  Unfortunately there's one
+  // level of the cascade and associated change hint
+  // (eRestyle_StyleAttribute) where we don't fully distinguish.
+  // FIXME (bug 1133439): We could at least distinguish by having two
+  // separate eRestyle_StyleAttribute hints, one for animations and one
+  // for other things.
+  if (aRestyleHint & ~(eRestyle_CSSTransitions | eRestyle_CSSAnimations |
+                       eRestyle_ChangeAnimationPhase |
+                       eRestyle_SVGAttrAnimations)) {
+    mHavePendingNonAnimationRestyles = true;
+  }
+
   PostRestyleEventInternal(false);
 }
 
 void
 RestyleManager::PostRestyleEventInternal(bool aForLazyConstruction)
 {
   // Make sure we're not in a style refresh; if we are, we still have
   // a call to ProcessPendingRestyles coming and there's no need to
--- a/layout/base/RestyleManager.h
+++ b/layout/base/RestyleManager.h
@@ -512,16 +512,17 @@ private:
   bool mSkipAnimationRules : 1;
   // Whether rule matching should post animation restyles when it skips
   // styles associated with animation.  Only true when
   // mSkipAnimationRules is also true.
   bool mPostAnimationRestyles : 1;
   // Whether we're currently in the animation phase of restyle
   // processing (to be eliminated in bug 960465)
   bool mIsProcessingAnimationStyleChange : 1;
+  bool mHavePendingNonAnimationRestyles : 1;
 
   uint32_t mHoverGeneration;
   nsChangeHint mRebuildAllExtraHint;
   nsRestyleHint mRebuildAllRestyleHint;
 
   mozilla::TimeStamp mLastUpdateForThrottledAnimations;
 
   OverflowChangedTracker mOverflowChangedTracker;