From acfd59047ee5b64f9688c6638a51a6f8c9ec90ce Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Wed, 8 Oct 2014 14:26:57 -0700 Subject: [PATCH] Bug 1047928 patch 2 - Pass restyle hint to RestyleManager::RebuildAllStyleData. r=bzbarsky This patch is not intended to contain any changes in behavior. --- layout/base/RestyleManager.cpp | 18 +++++++++--------- layout/base/RestyleManager.h | 13 ++++++++++++- layout/base/nsPresContext.cpp | 3 ++- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp index dec6403d0447..4cf9204ac330 100644 --- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -69,6 +69,7 @@ RestyleManager::RestyleManager(nsPresContext* aPresContext) , mIsProcessingAnimationStyleChange(false) , mHoverGeneration(0) , mRebuildAllExtraHint(nsChangeHint(0)) + , mRebuildAllRestyleHint(nsRestyleHint(0)) , mLastUpdateForThrottledAnimations(aPresContext->RefreshDriver()-> MostRecentRefresh()) , mAnimationGeneration(0) @@ -1409,7 +1410,8 @@ RestyleManager::RestyleForRemove(Element* aContainer, } void -RestyleManager::RebuildAllStyleData(nsChangeHint aExtraHint) +RestyleManager::RebuildAllStyleData(nsChangeHint aExtraHint, + nsRestyleHint aRestyleHint) { NS_ASSERTION(!(aExtraHint & nsChangeHint_ReconstructFrame), "Should not reconstruct the root of the frame tree. " @@ -1417,7 +1419,9 @@ RestyleManager::RebuildAllStyleData(nsChangeHint aExtraHint) mRebuildAllStyleData = false; NS_UpdateHint(aExtraHint, mRebuildAllExtraHint); + aRestyleHint |= mRebuildAllRestyleHint; mRebuildAllExtraHint = nsChangeHint(0); + mRebuildAllRestyleHint = nsRestyleHint(0); nsIPresShell* presShell = mPresContext->GetPresShell(); if (!presShell || !presShell->GetRootFrame()) @@ -1448,13 +1452,7 @@ RestyleManager::RebuildAllStyleData(nsChangeHint aExtraHint) 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 - // hint passed in, and substantially improve the performance of things - // like pref changes and the restyling that we do for downloadable - // font loads. - DoRebuildAllStyleData(mPendingRestyles, aExtraHint, eRestyle_Subtree); + DoRebuildAllStyleData(mPendingRestyles, aExtraHint, aRestyleHint); mPostAnimationRestyles = false; mSkipAnimationRules = false; @@ -1589,7 +1587,7 @@ RestyleManager::ProcessPendingRestyles() // 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. - RebuildAllStyleData(nsChangeHint(0)); + RebuildAllStyleData(nsChangeHint(0), nsRestyleHint(0)); } } @@ -1699,6 +1697,8 @@ RestyleManager::PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint) mRebuildAllStyleData = true; NS_UpdateHint(mRebuildAllExtraHint, aExtraHint); + // FIXME: pass through from callers + mRebuildAllRestyleHint = eRestyle_Subtree; // Get a restyle event posted if necessary PostRestyleEventInternal(false); diff --git a/layout/base/RestyleManager.h b/layout/base/RestyleManager.h index a28dc7cd3683..c2f29892f59f 100644 --- a/layout/base/RestyleManager.h +++ b/layout/base/RestyleManager.h @@ -305,7 +305,17 @@ public: // Rebuilds all style data by throwing out the old rule tree and // building a new one, and additionally applying aExtraHint (which // must not contain nsChangeHint_ReconstructFrame) to the root frame. - void RebuildAllStyleData(nsChangeHint aExtraHint); + // + // aRestyleHint says which restyle hint to use for the computation; + // the only sensible values to use are eRestyle_Subtree (which says + // that the rebuild must run selector matching) and nsRestyleHint(0) + // (which says that rerunning selector matching is not required. (The + // method adds eRestyle_ForceDescendants internally, and including it + // in the restyle hint is harmless; some callers (e.g., + // nsPresContext::MediaFeatureValuesChanged) might do this for their + // own reasons.) + void RebuildAllStyleData(nsChangeHint aExtraHint, + nsRestyleHint aRestyleHint); // Helper that does part of the work of RebuildAllStyleData, shared by // RestyleElement for 'rem' handling. @@ -462,6 +472,7 @@ private: uint32_t mHoverGeneration; nsChangeHint mRebuildAllExtraHint; + nsRestyleHint mRebuildAllRestyleHint; mozilla::TimeStamp mLastUpdateForThrottledAnimations; diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 671e805048c2..7d1aea605b3f 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -1864,7 +1864,8 @@ nsPresContext::RebuildAllStyleData(nsChangeHint aExtraHint) RebuildUserFontSet(); RebuildCounterStyles(); - RestyleManager()->RebuildAllStyleData(aExtraHint); + // FIXME: Pass through from callers + RestyleManager()->RebuildAllStyleData(aExtraHint, eRestyle_Subtree); } void