diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp index aaae80124d3..a736aacccfb 100644 --- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -64,6 +64,8 @@ RestyleManager::RestyleManager(nsPresContext* aPresContext) , mRebuildAllStyleData(false) , mObservingRefreshDriver(false) , mInStyleRefresh(false) + , mSkipAnimationRules(false) + , mPostAnimationRestyles(false) , mHoverGeneration(0) , mRebuildAllExtraHint(nsChangeHint(0)) , mLastUpdateForThrottledAnimations(aPresContext->RefreshDriver()-> @@ -1439,6 +1441,13 @@ RestyleManager::RebuildAllStyleData(nsChangeHint aExtraHint) #endif mPresContext->SetProcessingRestyles(true); + // Until we get rid of these phases in bug 960465, we need to skip + // animation restyles during the non-animation phase, and post + // animation restyles so that we restyle those elements again in the + // animation phase. + mSkipAnimationRules = true; + mPostAnimationRestyles = true; + // FIXME (bug 1047928): Many of the callers probably don't need // eRestyle_Subtree because they're changing things that affect data // computation rather than selector matching; we could have a restyle @@ -1449,6 +1458,8 @@ RestyleManager::RebuildAllStyleData(nsChangeHint aExtraHint) nsRestyleHint(eRestyle_Subtree | eRestyle_ForceDescendants)); + mPostAnimationRestyles = false; + mSkipAnimationRules = false; #ifdef DEBUG mIsProcessingRestyles = false; #endif @@ -1539,8 +1550,18 @@ RestyleManager::ProcessPendingRestyles() UpdateOnlyAnimationStyles(); } + // Until we get rid of these phases in bug 960465, we need to skip + // animation restyles during the non-animation phase, and post + // animation restyles so that we restyle those elements again in the + // animation phase. + mSkipAnimationRules = true; + mPostAnimationRestyles = true; + mPendingRestyles.ProcessRestyles(); + mPostAnimationRestyles = false; + mSkipAnimationRules = false; + #ifdef DEBUG uint32_t oldPendingRestyleCount = mPendingRestyles.Count(); #endif diff --git a/layout/base/RestyleManager.h b/layout/base/RestyleManager.h index a5610023880..6acc770aa2a 100644 --- a/layout/base/RestyleManager.h +++ b/layout/base/RestyleManager.h @@ -92,6 +92,22 @@ public: // track whether off-main-thread animations are up-to-date. uint64_t GetAnimationGeneration() const { return mAnimationGeneration; } + // Whether rule matching should skip styles associated with animation + bool SkipAnimationRules() const { + MOZ_ASSERT(mSkipAnimationRules || !mPostAnimationRestyles, + "inconsistent state"); + return mSkipAnimationRules; + } + + // Whether rule matching should post animation restyles when it skips + // styles associated with animation. Only true when + // SkipAnimationRules() is also true. + bool PostAnimationRestyles() const { + MOZ_ASSERT(mSkipAnimationRules || !mPostAnimationRestyles, + "inconsistent state"); + return mPostAnimationRestyles; + } + /** * Reparent the style contexts of this frame subtree. The parent frame of * aFrame must be changed to the new parent before this function is called; @@ -427,6 +443,13 @@ private: bool mObservingRefreshDriver : 1; // True if we're in the middle of a nsRefreshDriver refresh bool mInStyleRefresh : 1; + // Whether rule matching should skip styles associated with animation + 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; + uint32_t mHoverGeneration; nsChangeHint mRebuildAllExtraHint;