Bug 1203766 - Part 4: Add a "restyle generation" counter, which increments whenever we process pending restyles. r=bzbarsky

This commit is contained in:
Cameron McCormack 2015-09-17 12:08:20 +10:00
parent 5cd9b296f7
commit 54e04d5eff
4 changed files with 26 additions and 0 deletions

View File

@ -83,6 +83,7 @@ RestyleManager::RestyleManager(nsPresContext* aPresContext)
, mInStyleRefresh(false)
, mSkipAnimationRules(false)
, mHavePendingNonAnimationRestyles(false)
, mRestyleGeneration(1)
, mHoverGeneration(0)
, mRebuildAllExtraHint(nsChangeHint(0))
, mRebuildAllRestyleHint(nsRestyleHint(0))

View File

@ -91,6 +91,10 @@ public:
int32_t aModType,
const nsAttrValue* aOldValue);
// Get an integer that increments every time we process pending restyles.
// The value is never 0.
uint32_t GetRestyleGeneration() const { return mRestyleGeneration; }
// Get an integer that increments every time there is a style change
// as a result of a change to the :hover content state.
uint32_t GetHoverGeneration() const { return mHoverGeneration; }
@ -519,6 +523,12 @@ private:
// Fast-path the common case (esp. for the animation restyle
// tracker) of not having anything to do.
if (aRestyleTracker.Count() || ShouldStartRebuildAllFor(aRestyleTracker)) {
if (++mRestyleGeneration == 0) {
// Keep mRestyleGeneration from being 0, since that's what
// nsPresContext::GetRestyleGeneration returns when it no
// longer has a RestyleManager.
++mRestyleGeneration;
}
aRestyleTracker.DoProcessRestyles();
}
}
@ -539,6 +549,7 @@ private:
bool mSkipAnimationRules : 1;
bool mHavePendingNonAnimationRestyles : 1;
uint32_t mRestyleGeneration;
uint32_t mHoverGeneration;
nsChangeHint mRebuildAllExtraHint;
nsRestyleHint mRebuildAllRestyleHint;

View File

@ -2844,6 +2844,15 @@ nsPresContext::IsDeviceSizePageSize()
return isDeviceSizePageSize;
}
uint64_t
nsPresContext::GetRestyleGeneration() const
{
if (!mRestyleManager) {
return 0;
}
return mRestyleManager->GetRestyleGeneration();
}
nsRootPresContext::nsRootPresContext(nsIDocument* aDocument,
nsPresContextType aType)
: nsPresContext(aDocument, aType),

View File

@ -915,6 +915,11 @@ public:
mAllInvalidated = false;
}
/**
* Returns the RestyleManager's restyle generation counter.
*/
uint64_t GetRestyleGeneration() const;
/**
* Returns whether there are any pending restyles or reflows.
*/