From aedbfdef2c89058e13797fce3910f4c5f9544267 Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Wed, 8 Oct 2014 14:27:03 -0700 Subject: [PATCH] Bug 1047928 patch 9 - Don't rerun selector matching for viewport units. r=bzbarsky --- layout/base/nsPresContext.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 2063441a42c..60084ab3bb6 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -1885,19 +1885,27 @@ void nsPresContext::MediaFeatureValuesChanged(StyleRebuildType aShouldRebuild, nsChangeHint aChangeHint) { - NS_ASSERTION(aShouldRebuild == eAlwaysRebuildStyle || aChangeHint == 0, - "If you don't know if we need a rebuild, how can you provide a hint?"); - mPendingMediaFeatureValuesChanged = false; - // MediumFeaturesChanged updates the applied rules, so it always gets called. - bool mediaFeaturesDidChange = mShell ? mShell->StyleSet()->MediumFeaturesChanged(this) - : false; + nsRestyleHint aRestyleHint = nsRestyleHint(0); - if (aShouldRebuild == eAlwaysRebuildStyle || - mediaFeaturesDidChange || - (mUsesViewportUnits && mPendingViewportChange)) { - RebuildAllStyleData(aChangeHint, eRestyle_Subtree); + if (aShouldRebuild == eAlwaysRebuildStyle) { + // FIXME: Pass restyle hint from caller. + aRestyleHint |= eRestyle_Subtree; + } + + // MediumFeaturesChanged updates the applied rules, so it always gets called. + if (mShell && mShell->StyleSet()->MediumFeaturesChanged(this)) { + aRestyleHint |= eRestyle_Subtree; + } + + if (mUsesViewportUnits && mPendingViewportChange) { + // Rebuild all style data without rerunning selector matching. + aRestyleHint |= eRestyle_ForceDescendants; + } + + if (aRestyleHint || aChangeHint) { + RebuildAllStyleData(aChangeHint, aRestyleHint); } mPendingViewportChange = false;