Bug 1362599 - Remember which languages were used and force-cache when reset; r=heycam

This commit is contained in:
Manish Goregaokar 2017-05-20 21:47:36 +02:00 коммит произвёл Bobby Holley
Родитель bf23cb1d19
Коммит 9ac08154b7
4 изменённых файлов: 38 добавлений и 2 удалений

Просмотреть файл

@ -237,6 +237,7 @@ nsPresContext::nsPresContext(nsIDocument* aDocument, nsPresContextType aType)
mExistThrottledUpdates(false),
// mImageAnimationMode is initialised below, in constructor body
mImageAnimationModePref(imgIContainer::kNormalAnimMode),
mFontGroupCacheDirty(true),
mInterruptChecksToSkip(0),
mElementsRestyled(0),
mFramesConstructed(0),
@ -623,6 +624,7 @@ nsPresContext::GetUserPreferences()
mPrefScrollbarSide = Preferences::GetInt("layout.scrollbar.side");
mLangGroupFontPrefs.Reset();
mFontGroupCacheDirty = true;
StaticPresData::Get()->ResetCachedFontPrefs();
// * image animation
@ -1066,6 +1068,7 @@ nsPresContext::UpdateCharSet(const nsCString& aCharSet)
mLanguage = mLangService->GetLocaleLanguage();
}
mLangGroupFontPrefs.Reset();
mFontGroupCacheDirty = true;
}
switch (GET_BIDI_OPTION_TEXTTYPE(GetBidi())) {
@ -1975,6 +1978,33 @@ void nsPresContext::StopEmulatingMedium()
}
}
void
nsPresContext::ForceCacheLang(nsIAtom *aLanguage)
{
// force it to be cached
GetDefaultFont(kPresContext_DefaultVariableFont_ID, aLanguage);
if (!mLanguagesUsed.Contains(aLanguage)) {
mLanguagesUsed.PutEntry(aLanguage);
}
}
void
nsPresContext::CacheAllLangs()
{
if (mFontGroupCacheDirty) {
nsCOMPtr<nsIAtom> thisLang = nsStyleFont::GetLanguage(this);
GetDefaultFont(kPresContext_DefaultVariableFont_ID, thisLang.get());
GetDefaultFont(kPresContext_DefaultVariableFont_ID, nsGkAtoms::x_math);
// https://bugzilla.mozilla.org/show_bug.cgi?id=1362599#c12
GetDefaultFont(kPresContext_DefaultVariableFont_ID, nsGkAtoms::Unicode);
for (auto iter = mLanguagesUsed.Iter(); !iter.Done(); iter.Next()) {
GetDefaultFont(kPresContext_DefaultVariableFont_ID, iter.Get()->GetKey());
}
}
mFontGroupCacheDirty = false;
}
void
nsPresContext::RebuildAllStyleData(nsChangeHint aExtraHint,
nsRestyleHint aRestyleHint)

Просмотреть файл

@ -373,6 +373,9 @@ public:
GetFontPrefsForLang(lang));
}
void ForceCacheLang(nsIAtom *aLanguage);
void CacheAllLangs();
/** Get a cached boolean pref, by its type */
// * - initially created for bugs 31816, 20760, 22963
bool GetCachedBoolPref(nsPresContext_CachedBoolPrefType aPrefType) const
@ -1420,6 +1423,9 @@ protected:
// link items.
LangGroupFontPrefs mLangGroupFontPrefs;
bool mFontGroupCacheDirty;
nsTHashtable<nsRefPtrHashKey<nsIAtom>> mLanguagesUsed;
nscoord mBorderWidthTable[3];
uint32_t mInterruptChecksToSkip;

Просмотреть файл

@ -51,8 +51,7 @@ ServoSpecifiedValues::SetIdentStringValue(nsCSSPropertyID aId,
if (aId == eCSSProperty__x_lang) {
// This forces the lang prefs result to be cached
// so that we can access them off main thread during traversal
mPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID,
atom);
mPresContext->ForceCacheLang(atom);
}
}

Просмотреть файл

@ -267,6 +267,7 @@ ServoStyleSet::PreTraverseSync()
mPresContext->Document()->GetUserFontSet();
UpdateStylistIfNeeded();
mPresContext->CacheAllLangs();
}
void