Bug 1075137 patch 2 - Add new booleans for whether to skip animation styles and whether to post animation restyles. r=birtles

This commit is contained in:
L. David Baron 2014-10-02 21:53:23 -07:00
parent e4428de7bf
commit ad2b0a920f
2 changed files with 44 additions and 0 deletions

View File

@ -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

View File

@ -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;