Bug 1554819 - Ensure fontgroups attached to CanvasRenderingContext2D get reset after a shared-fontlist rebuild. r=jwatt

Differential Revision: https://phabricator.services.mozilla.com/D53264

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jonathan Kew 2019-11-17 11:49:20 +00:00
Родитель 8f0c9950ab
Коммит e317a07882
5 изменённых файлов: 31 добавлений и 0 удалений

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

@ -3978,6 +3978,9 @@ gfxFontGroup* CanvasRenderingContext2D::GetCurrentFontStyle() {
NS_ERROR("Default canvas font is invalid");
}
}
} else {
// The fontgroup needs to check if its cached families/faces are valid.
CurrentState().fontGroup->CheckForUpdatedPlatformList();
}
return CurrentState().fontGroup;

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

@ -2319,5 +2319,9 @@ void gfxPlatformFontList::InitOtherFamilyNames(uint32_t aGeneration,
InitOtherFamilyNames(aDefer);
}
uint32_t gfxPlatformFontList::GetGeneration() const {
return SharedFontList() ? SharedFontList()->GetGeneration() : 0;
}
#undef LOG
#undef LOG_ENABLED

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

@ -444,6 +444,14 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
return mCodepointsWithNoFonts.test(aCh);
}
// If using the shared font list, returns a generation count that is
// incremented if/when the platform list is reinitialized (e.g. because
// fonts are installed/removed while the browser is running), such that
// existing references to shared font family or face objects and character
// maps will no longer be valid.
// (The legacy (non-shared) list just returns 0 here.)
uint32_t GetGeneration() const;
protected:
friend class mozilla::fontlist::FontList;
friend class InitOtherFamilyNamesForStylo;

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

@ -1734,6 +1734,8 @@ void gfxFontGroup::BuildFontList() {
AddFamilyToFontList(f.mFamily.mUnshared, f.mGeneric);
}
}
mFontListGeneration = pfl->GetGeneration();
}
void gfxFontGroup::AddPlatformFont(const nsACString& aName, bool aQuotedName,

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

@ -1049,6 +1049,17 @@ class gfxFontGroup final : public gfxTextRunFactory {
int32_t aAppUnitsPerDevPixel, mozilla::gfx::ShapedTextFlags aFlags,
LazyReferenceDrawTargetGetter& aRefDrawTargetGetter);
void CheckForUpdatedPlatformList() {
auto* pfl = gfxPlatformFontList::PlatformFontList();
if (mFontListGeneration != pfl->GetGeneration()) {
// Forget cached fonts that may no longer be valid.
mLastPrefFamily = FontFamily();
mLastPrefFont = nullptr;
mFonts.Clear();
BuildFontList();
}
}
protected:
friend class mozilla::PostTraversalTask;
@ -1357,6 +1368,9 @@ class gfxFontGroup final : public gfxTextRunFactory {
// download to complete (or fallback
// timer to fire)
uint32_t mFontListGeneration = 0; // platform font list generation for this
// fontgroup
/**
* Textrun creation short-cuts for special cases where we don't need to
* call a font shaper to generate glyphs.