Bug 1554208 - patch 3 - Rearrange gfxFT2Fonts code so that FindFonts() does just what it says, and other work is handled by the caller. r=jwatt

This makes the functional structure a bit cleaner, so that it'll be easier to slip in the alternative
codepath for the shared font-list.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jonathan Kew 2019-07-12 15:33:03 +00:00
Родитель 2469dbfb9d
Коммит 01e8403527
1 изменённых файлов: 25 добавлений и 24 удалений

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

@ -1249,29 +1249,7 @@ static void FinalizeFamilyMemberList(nsCStringHashKey::KeyType aKey,
}
void gfxFT2FontList::FindFonts() {
if (!XRE_IsParentProcess()) {
// Content process: ask the Chrome process to give us the list
nsTArray<FontListEntry> fonts;
mozilla::dom::ContentChild::GetSingleton()->SendReadFontList(&fonts);
for (uint32_t i = 0, n = fonts.Length(); i < n; ++i) {
// We don't need to identify "standard" font files here,
// as the faces are already sorted.
AppendFaceFromFontListEntry(fonts[i], kUnknown);
}
// Passing null for userdata tells Finalize that it does not need
// to sort faces (because they were already sorted by chrome,
// so we just maintain the existing order)
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
nsCStringHashKey::KeyType key = iter.Key();
RefPtr<gfxFontFamily>& family = iter.Data();
FinalizeFamilyMemberList(key, family, /* aSortFaces */ false);
}
LOG(("got font list from chrome process: %" PRIdPTR " faces in %" PRIu32
" families",
fonts.Length(), mFontFamilies.Count()));
return;
}
MOZ_ASSERT(XRE_IsParentProcess());
// Chrome process: get the cached list (if any)
if (!mFontNameCache) {
@ -1462,8 +1440,31 @@ static void LoadSkipSpaceLookupCheck(
nsresult gfxFT2FontList::InitFontListForPlatform() {
LoadSkipSpaceLookupCheck(mSkipSpaceLookupCheckFamilies);
FindFonts();
if (XRE_IsParentProcess()) {
FindFonts();
return NS_OK;
}
// Content process: ask the Chrome process to give us the list
nsTArray<FontListEntry> fonts;
mozilla::dom::ContentChild::GetSingleton()->SendReadFontList(&fonts); // sync
for (uint32_t i = 0, n = fonts.Length(); i < n; ++i) {
// We don't need to identify "standard" font files here,
// as the faces are already sorted.
AppendFaceFromFontListEntry(fonts[i], kUnknown);
}
// Passing null for userdata tells Finalize that it does not need
// to sort faces (because they were already sorted by chrome,
// so we just maintain the existing order)
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
nsCStringHashKey::KeyType key = iter.Key();
RefPtr<gfxFontFamily>& family = iter.Data();
FinalizeFamilyMemberList(key, family, /* aSortFaces */ false);
}
LOG(("got font list from chrome process: %" PRIdPTR " faces in %" PRIu32
" families",
fonts.Length(), mFontFamilies.Count()));
return NS_OK;
}