Bug 1047928 patch 10 - Pass restyle hint to nsPresContext::MediaFeatureValuesChanged. r=bzbarsky

This patch is not intended to contain any changes in behavior.

The behavior changes in these callers are in the following 4 patches.
This commit is contained in:
L. David Baron 2014-10-08 14:27:03 -07:00
parent aedbfdef2c
commit b1ad6a1d08
3 changed files with 31 additions and 24 deletions

View File

@ -4382,7 +4382,7 @@ nsDocShell::SetDeviceSizeIsPageSize(bool aValue)
nsRefPtr<nsPresContext> presContext;
GetPresContext(getter_AddRefs(presContext));
if (presContext) {
presContext->MediaFeatureValuesChanged(presContext->eAlwaysRebuildStyle);
presContext->MediaFeatureValuesChanged(eRestyle_Subtree);
}
}
return NS_OK;

View File

@ -847,7 +847,7 @@ nsPresContext::AppUnitsPerDevPixelChanged()
if (HasCachedStyleData()) {
// All cached style data must be recomputed.
MediaFeatureValuesChanged(eAlwaysRebuildStyle, NS_STYLE_HINT_REFLOW);
MediaFeatureValuesChanged(eRestyle_Subtree, NS_STYLE_HINT_REFLOW);
}
mCurAppUnitsPerDevPixel = AppUnitsPerDevPixel();
@ -1711,7 +1711,7 @@ nsPresContext::ThemeChangedInternal()
// properly reflected in computed style data), system fonts (whose
// changes are not), and -moz-appearance (whose changes likewise are
// not), so we need to reflow.
MediaFeatureValuesChanged(eAlwaysRebuildStyle, NS_STYLE_HINT_REFLOW);
MediaFeatureValuesChanged(eRestyle_Subtree, NS_STYLE_HINT_REFLOW);
}
void
@ -1840,7 +1840,7 @@ nsPresContext::EmulateMedium(const nsAString& aMediaType)
mMediaEmulated = do_GetAtom(mediaType);
if (mMediaEmulated != previousMedium && mShell) {
MediaFeatureValuesChanged(eRebuildStyleIfNeeded, nsChangeHint(0));
MediaFeatureValuesChanged(nsRestyleHint(0), nsChangeHint(0));
}
}
@ -1849,7 +1849,7 @@ void nsPresContext::StopEmulatingMedium()
nsIAtom* previousMedium = Medium();
mIsEmulatingMedia = false;
if (Medium() != previousMedium) {
MediaFeatureValuesChanged(eRebuildStyleIfNeeded, nsChangeHint(0));
MediaFeatureValuesChanged(nsRestyleHint(0), nsChangeHint(0));
}
}
@ -1882,18 +1882,11 @@ nsPresContext::PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
}
void
nsPresContext::MediaFeatureValuesChanged(StyleRebuildType aShouldRebuild,
nsPresContext::MediaFeatureValuesChanged(nsRestyleHint aRestyleHint,
nsChangeHint aChangeHint)
{
mPendingMediaFeatureValuesChanged = false;
nsRestyleHint aRestyleHint = nsRestyleHint(0);
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;
@ -1979,7 +1972,7 @@ nsPresContext::HandleMediaFeatureValuesChangedEvent()
// Null-check mShell in case the shell has been destroyed (and the
// event is the only thing holding the pres context alive).
if (mPendingMediaFeatureValuesChanged && mShell) {
MediaFeatureValuesChanged(eRebuildStyleIfNeeded);
MediaFeatureValuesChanged(nsRestyleHint(0));
}
}

View File

@ -151,12 +151,6 @@ public:
eContext_PageLayout // paginated & editable.
};
// Policies for rebuilding style data.
enum StyleRebuildType {
eRebuildStyleIfNeeded,
eAlwaysRebuildStyle
};
nsPresContext(nsIDocument* aDocument, nsPresContextType aType);
/**
@ -265,13 +259,33 @@ public:
void PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
nsRestyleHint aRestyleHint);
void MediaFeatureValuesChanged(StyleRebuildType aShouldRebuild,
/**
* Handle changes in the values of media features (used in media
* queries).
*
* There are three sensible values to use for aRestyleHint:
* * nsRestyleHint(0) to rebuild style data, with rerunning of
* selector matching, only if media features have changed
* * eRestyle_ForceDescendants to force rebuilding of style data (but
* still only rerun selector matching if media query results have
* changed). (RebuildAllStyleData always adds
* eRestyle_ForceDescendants internally, so here we're only using
* it to distinguish from nsRestyleHint(0) whether we need to call
* RebuildAllStyleData at all.)
* * eRestyle_Subtree to force rebuilding of style data with
* rerunning of selector matching
*
* For aChangeHint, see RestyleManager::RebuildAllStyleData. (Passing
* a nonzero aChangeHint forces rebuilding style data even if
* nsRestyleHint(0) is passed.)
*/
void MediaFeatureValuesChanged(nsRestyleHint aRestyleHint,
nsChangeHint aChangeHint = nsChangeHint(0));
void PostMediaFeatureValuesChangedEvent();
void HandleMediaFeatureValuesChangedEvent();
void FlushPendingMediaFeatureValuesChanged() {
if (mPendingMediaFeatureValuesChanged)
MediaFeatureValuesChanged(eRebuildStyleIfNeeded);
MediaFeatureValuesChanged(nsRestyleHint(0));
}
/**
@ -535,7 +549,7 @@ public:
if (HasCachedStyleData()) {
// Media queries could have changed, since we changed the meaning
// of 'em' units in them.
MediaFeatureValuesChanged(eAlwaysRebuildStyle, NS_STYLE_HINT_REFLOW);
MediaFeatureValuesChanged(eRestyle_Subtree, NS_STYLE_HINT_REFLOW);
}
}
@ -570,7 +584,7 @@ public:
if (HasCachedStyleData()) {
// Media queries could have changed, since we changed the meaning
// of 'em' units in them.
MediaFeatureValuesChanged(eAlwaysRebuildStyle, NS_STYLE_HINT_REFLOW);
MediaFeatureValuesChanged(eRestyle_Subtree, NS_STYLE_HINT_REFLOW);
}
}