Bug 1647573 - On font-list reinitialization, reconstruct frames rather than just restyling. r=jwatt

As a bonus, this also fixes a pre-existing bug that we never cleared the
mPrefChangePendingNeedsReflow flag after using it, so future pref changes
that shouldn't need a reflow would still trigger one.

Depends on D84518

Differential Revision: https://phabricator.services.mozilla.com/D84519
This commit is contained in:
Jonathan Kew 2020-07-24 21:10:09 +00:00
parent 60bda2f7ba
commit 4e8b62706e
2 changed files with 18 additions and 32 deletions

View File

@ -189,6 +189,7 @@ nsPresContext::nsPresContext(dom::Document* aDocument, nsPresContextType aType)
mFramesConstructed(0),
mFramesReflowed(0),
mInteractionTimeEnabled(true),
mChangeHintForPrefChange(nsChangeHint(0)),
mHasPendingInterrupt(false),
mPendingInterruptFromTest(false),
mInterruptsEnabled(false),
@ -204,7 +205,6 @@ nsPresContext::nsPresContext(dom::Document* aDocument, nsPresContextType aType)
mPrefScrollbarSide(0),
mPendingThemeChanged(false),
mPendingUIResolutionChanged(false),
mPrefChangePendingNeedsReflow(false),
mPostedPrefChangedRunnable(false),
mIsGlyph(false),
mUsesExChUnits(false),
@ -513,7 +513,7 @@ void nsPresContext::PreferenceChanged(const char* aPrefName) {
if (!mMissingFonts) {
mMissingFonts = MakeUnique<gfxMissingFontRecorder>();
// trigger reflow to detect missing fonts on the current page
mPrefChangePendingNeedsReflow = true;
mChangeHintForPrefChange |= NS_STYLE_HINT_REFLOW;
}
} else {
if (mMissingFonts) {
@ -522,28 +522,18 @@ void nsPresContext::PreferenceChanged(const char* aPrefName) {
mMissingFonts = nullptr;
}
}
if (StringBeginsWith(prefName, "font."_ns) ||
prefName.EqualsLiteral("intl.accept_languages")) {
// Changes to font family preferences don't change anything in the
// computed style data, so the style system won't generate a reflow
// hint for us. We need to do that manually.
// FIXME We could probably also handle changes to
// browser.display.auto_quality_min_font_size here, but that
// probably also requires clearing the text run cache, so don't
// bother (yet, anyway).
mPrefChangePendingNeedsReflow = true;
}
if (StringBeginsWith(prefName, "bidi."_ns)) {
// Changes to bidi prefs need to trigger a reflow (see bug 443629)
mPrefChangePendingNeedsReflow = true;
// Changes to bidi.numeral also needs to empty the text run cache.
// This is handled in gfxTextRunWordCache.cpp.
}
if (StringBeginsWith(prefName, "gfx.font_rendering."_ns)) {
// Changes to font_rendering prefs need to trigger a reflow
mPrefChangePendingNeedsReflow = true;
if (prefName.EqualsLiteral("font.internaluseonly.changed")) {
mChangeHintForPrefChange |= nsChangeHint_ReconstructFrame;
} else if (StringBeginsWith(prefName, "font."_ns) ||
// Changes to font family preferences don't change anything in the
// computed style data, so the style system won't generate a reflow
// hint for us. We need to do that manually.
prefName.EqualsLiteral("intl.accept_languages") ||
// Changes to bidi prefs need to trigger a reflow (see bug 443629)
StringBeginsWith(prefName, "bidi."_ns) ||
// Changes to font_rendering prefs need to trigger a reflow
StringBeginsWith(prefName, "gfx.font_rendering."_ns)) {
mChangeHintForPrefChange |= NS_STYLE_HINT_REFLOW;
}
// We will end up calling InvalidatePreferenceSheets one from each pres
@ -600,15 +590,10 @@ void nsPresContext::UpdateAfterPreferencesChanged() {
InvalidatePaintedLayers();
mDeviceContext->FlushFontCache();
nsChangeHint hint = nsChangeHint(0);
if (mPrefChangePendingNeedsReflow) {
hint |= NS_STYLE_HINT_REFLOW;
}
// Preferences require rerunning selector matching because we rebuild
// the pref style sheet for some preference changes.
RebuildAllStyleData(hint, RestyleHint::RestyleSubtree());
RebuildAllStyleData(mChangeHintForPrefChange, RestyleHint::RestyleSubtree());
mChangeHintForPrefChange = nsChangeHint(0);
}
nsresult nsPresContext::Init(nsDeviceContext* aDeviceContext) {

View File

@ -1264,6 +1264,8 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr {
// last time we did a full style flush
mozilla::TimeStamp mLastStyleUpdateForAllAnimations;
nsChangeHint mChangeHintForPrefChange;
unsigned mHasPendingInterrupt : 1;
unsigned mPendingInterruptFromTest : 1;
unsigned mInterruptsEnabled : 1;
@ -1279,7 +1281,6 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr {
unsigned mPrefScrollbarSide : 2;
unsigned mPendingThemeChanged : 1;
unsigned mPendingUIResolutionChanged : 1;
unsigned mPrefChangePendingNeedsReflow : 1;
unsigned mPostedPrefChangedRunnable : 1;
// Are we currently drawing an SVG glyph?