From ed7a380b0cca3f413292301328fd2b1bd2632a7e Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Sun, 5 Nov 2017 09:35:24 +0000 Subject: [PATCH] Backed out csets f9763adebe68, a1c1fe33a052, bf35d13e27f3, c6ad01bf0b66 (bug 1412090) for ASan failures. --- dom/ipc/ContentChild.cpp | 12 +- dom/ipc/ContentChild.h | 18 +- dom/ipc/ContentParent.cpp | 21 +- dom/ipc/ContentParent.h | 2 - dom/ipc/PContent.ipdl | 19 +- gfx/thebes/gfxFcPlatformFontList.cpp | 279 +++++++-------------------- gfx/thebes/gfxFcPlatformFontList.h | 31 +-- gfx/thebes/gfxMacPlatformFontList.h | 4 +- gfx/thebes/gfxMacPlatformFontList.mm | 56 +++--- gfx/thebes/gfxPlatform.h | 10 +- gfx/thebes/gfxPlatformGtk.cpp | 8 - gfx/thebes/gfxPlatformGtk.h | 9 - gfx/thebes/gfxPlatformMac.cpp | 9 +- gfx/thebes/gfxPlatformMac.h | 4 +- 14 files changed, 127 insertions(+), 355 deletions(-) diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 80b7a61d9f67..8505a42ce12d 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -548,14 +548,14 @@ mozilla::ipc::IPCResult ContentChild::RecvSetXPCOMProcessAttributes(const XPCOMInitData& aXPCOMInit, const StructuredCloneData& aInitialData, nsTArray&& aLookAndFeelIntCache, - nsTArray&& aFontList) + nsTArray&& aFontFamilyList) { if (!sShutdownCanary) { return IPC_OK(); } mLookAndFeelCache = Move(aLookAndFeelIntCache); - mFontList = Move(aFontList); + mFontFamilies = Move(aFontFamilyList); gfx::gfxVars::SetValuesForInitialize(aXPCOMInit.gfxNonDefaultVarUpdates()); InitXPCOM(aXPCOMInit, aInitialData); InitGraphicsDeviceData(aXPCOMInit.contentDeviceData()); @@ -2538,14 +2538,6 @@ ContentChild::RecvUpdateDictionaryList(InfallibleTArray&& aDictionarie return IPC_OK(); } -mozilla::ipc::IPCResult -ContentChild::RecvUpdateFontList(InfallibleTArray&& aFontList) -{ - mFontList = Move(aFontList); - gfxPlatform::GetPlatform()->UpdateFontList(); - return IPC_OK(); -} - mozilla::ipc::IPCResult ContentChild::RecvUpdateAppLocales(nsTArray&& aAppLocales) { diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index 9453e497b1df..9dd16234a8dd 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -399,8 +399,6 @@ public: virtual mozilla::ipc::IPCResult RecvUpdateDictionaryList(InfallibleTArray&& aDictionaries) override; - virtual mozilla::ipc::IPCResult RecvUpdateFontList(InfallibleTArray&& aFontList) override; - virtual mozilla::ipc::IPCResult RecvUpdateAppLocales(nsTArray&& aAppLocales) override; virtual mozilla::ipc::IPCResult RecvUpdateRequestedLocales(nsTArray&& aRequestedLocales) override; @@ -605,7 +603,7 @@ public: RecvSetXPCOMProcessAttributes(const XPCOMInitData& aXPCOMInit, const StructuredCloneData& aInitialData, nsTArray&& aLookAndFeelIntCache, - nsTArray&& aFontList) override; + nsTArray&& aFontFamilyList) override; virtual mozilla::ipc::IPCResult RecvProvideAnonymousTemporaryFile(const uint64_t& aID, const FileDescOrError& aFD) override; @@ -643,11 +641,11 @@ public: SendGetA11yContentId(); #endif // defined(XP_WIN) && defined(ACCESSIBILITY) - // Get a reference to the font list passed from the chrome process, + // Get a reference to the font family list passed from the chrome process, // for use during gfx initialization. - InfallibleTArray& - SystemFontList() { - return mFontList; + InfallibleTArray& + SystemFontFamilyList() { + return mFontFamilies; } // PURLClassifierChild @@ -751,10 +749,10 @@ private: InfallibleTArray mAvailableDictionaries; - // Temporary storage for a list of available fonts, passed from the + // Temporary storage for a list of available font families, passed from the // parent process and used to initialize gfx in the child. Currently used - // only on MacOSX and Linux. - InfallibleTArray mFontList; + // only on MacOSX. + InfallibleTArray mFontFamilies; // Temporary storage for nsXPLookAndFeel flags. nsTArray mLookAndFeelCache; diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index e1ecbdfe25b5..e4b625b11850 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -170,7 +170,6 @@ #include "nsDocShell.h" #include "nsOpenURIInFrameParams.h" #include "mozilla/net/NeckoMessageUtils.h" -#include "gfxPlatform.h" #include "gfxPrefs.h" #include "prio.h" #include "private/pprio.h" @@ -2223,10 +2222,9 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority, } } } - // This is only implemented (returns a non-empty list) by MacOSX and Linux - // at present. - nsTArray fontList; - gfxPlatform::GetPlatform()->ReadSystemFontList(&fontList); + // This is only implemented (returns a non-empty list) by MacOSX at present. + nsTArray fontFamilies; + gfxPlatform::GetPlatform()->GetSystemFontFamilyList(&fontFamilies); nsTArray lnfCache = LookAndFeel::GetIntCache(); // Content processes have no permission to access profile directory, so we @@ -2269,7 +2267,7 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority, screenManager.CopyScreensToRemote(this); Unused << SendSetXPCOMProcessAttributes(xpcomInit, initialData, lnfCache, - fontList); + fontFamilies); if (aSendRegisteredChrome) { nsCOMPtr registrySvc = nsChromeRegistry::GetService(); @@ -4266,17 +4264,6 @@ ContentParent::NotifyUpdatedDictionaries() } } -void -ContentParent::NotifyUpdatedFonts() -{ - InfallibleTArray fontList; - gfxPlatform::GetPlatform()->ReadSystemFontList(&fontList); - - for (auto* cp : AllProcesses(eLive)) { - Unused << cp->SendUpdateFontList(fontList); - } -} - /*static*/ void ContentParent::UnregisterRemoteFrame(const TabId& aTabId, const ContentParentId& aCpId, diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index e45e32e618a0..256b11e4e3ba 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -269,8 +269,6 @@ public: static void NotifyUpdatedDictionaries(); - static void NotifyUpdatedFonts(); - #if defined(XP_WIN) /** * Windows helper for firing off an update window request to a plugin diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 1760826ca7d9..c5c3e057a6e8 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -132,19 +132,6 @@ struct FontFamilyListEntry { uint8_t entryType; }; -// Used on Linux to pass list of font patterns from chrome to content. -struct FontPatternListEntry { - nsCString pattern; - bool appFontFamily; -}; - -// Wrap the Font*ListEntry records in a union so the SetXPCOMProcessAttributes -// message can pass an array of either type. -union SystemFontListEntry { - FontFamilyListEntry; - FontPatternListEntry; -}; - union PrefValue { nsCString; int32_t; @@ -442,8 +429,6 @@ child: async UpdateDictionaryList(nsString[] dictionaries); - async UpdateFontList(SystemFontListEntry[] fontList); - async UpdateAppLocales(nsCString[] appLocales); async UpdateRequestedLocales(nsCString[] requestedLocales); @@ -491,8 +476,8 @@ child: async SetXPCOMProcessAttributes(XPCOMInitData xpcomInit, StructuredCloneData initialData, LookAndFeelInt[] lookAndFeelIntCache, - /* used on MacOSX and Linux only: */ - SystemFontListEntry[] systemFontList); + /* used on MacOSX only: */ + FontFamilyListEntry[] fontFamilyList); // Notify child that last-pb-context-exited notification was observed async LastPrivateDocShellDestroyed(); diff --git a/gfx/thebes/gfxFcPlatformFontList.cpp b/gfx/thebes/gfxFcPlatformFontList.cpp index 7f6abb2aa973..5f844aac9ae9 100644 --- a/gfx/thebes/gfxFcPlatformFontList.cpp +++ b/gfx/thebes/gfxFcPlatformFontList.cpp @@ -12,8 +12,6 @@ #include "gfxFT2Utils.h" #include "gfxPlatform.h" #include "mozilla/ArrayUtils.h" -#include "mozilla/dom/ContentChild.h" -#include "mozilla/dom/ContentParent.h" #include "mozilla/Preferences.h" #include "mozilla/Sprintf.h" #include "mozilla/TimeStamp.h" @@ -24,12 +22,10 @@ #include "nsDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h" #include "nsCharSeparatedTokenizer.h" -#include "nsXULAppAPI.h" #include "mozilla/gfx/HelpersCairo.h" #include -#include #ifdef MOZ_WIDGET_GTK #include @@ -40,18 +36,10 @@ #include "mozilla/X11Util.h" #endif -#ifdef MOZ_CONTENT_SANDBOX -#include "mozilla/SandboxBrokerPolicyFactory.h" -#include "mozilla/SandboxSettings.h" -#endif - using namespace mozilla; using namespace mozilla::gfx; using namespace mozilla::unicode; -using mozilla::dom::SystemFontListEntry; -using mozilla::dom::FontPatternListEntry; - #ifndef FC_POSTSCRIPT_NAME #define FC_POSTSCRIPT_NAME "postscriptname" /* String */ #endif @@ -1217,33 +1205,6 @@ gfxFontconfigFontFamily::~gfxFontconfigFontFamily() MOZ_ASSERT(NS_IsMainThread()); } -void -gfxFontconfigFontFamily::AddFacesToFontList( - InfallibleTArray* aFontList) -{ - if (HasStyles()) { - for (auto& fe : mAvailableFonts) { - if (!fe) { - continue; - } - auto fce = static_cast(fe.get()); - char* pattern = (char*)FcNameUnparse(fce->GetPattern()); - nsDependentCString patternStr(pattern, strlen(pattern)); - aFontList->AppendElement(FontPatternListEntry(patternStr, - mContainsAppFonts)); - free(pattern); - } - } else { - for (auto& pat : mFontPatterns) { - char* pattern = (char*)FcNameUnparse(pat); - nsDependentCString patternStr(pattern, strlen(pattern)); - aFontList->AppendElement(FontPatternListEntry(patternStr, - mContainsAppFonts)); - free(pattern); - } - } -} - gfxFontconfigFont::gfxFontconfigFont(const RefPtr& aUnscaledFont, cairo_scaled_font_t *aScaledFont, FcPattern *aPattern, @@ -1283,20 +1244,18 @@ gfxFcPlatformFontList::gfxFcPlatformFontList() , mLastConfig(nullptr) , mAlwaysUseFontconfigGenerics(true) { - if (XRE_IsParentProcess()) { - // if the rescan interval is set, start the timer - int rescanInterval = FcConfigGetRescanInterval(nullptr); - if (rescanInterval) { - mLastConfig = FcConfigGetCurrent(); - NS_NewTimerWithFuncCallback(getter_AddRefs(mCheckFontUpdatesTimer), - CheckFontUpdates, - this, - (rescanInterval + 1) * 1000, - nsITimer::TYPE_REPEATING_SLACK, - "gfxFcPlatformFontList::gfxFcPlatformFontList"); - if (!mCheckFontUpdatesTimer) { - NS_WARNING("Failure to create font updates timer"); - } + // if the rescan interval is set, start the timer + int rescanInterval = FcConfigGetRescanInterval(nullptr); + if (rescanInterval) { + mLastConfig = FcConfigGetCurrent(); + NS_NewTimerWithFuncCallback(getter_AddRefs(mCheckFontUpdatesTimer), + CheckFontUpdates, + this, + (rescanInterval + 1) * 1000, + nsITimer::TYPE_REPEATING_SLACK, + "gfxFcPlatformFontList::gfxFcPlatformFontList"); + if (!mCheckFontUpdatesTimer) { + NS_WARNING("Failure to create font updates timer"); } } @@ -1314,15 +1273,14 @@ gfxFcPlatformFontList::~gfxFcPlatformFontList() } void -gfxFcPlatformFontList::AddFontSetFamilies(FcFontSet* aFontSet, - const SandboxPolicy* aPolicy, - bool aAppFonts) +gfxFcPlatformFontList::AddFontSetFamilies(FcFontSet* aFontSet, bool aAppFonts) { // This iterates over the fonts in a font set and adds in gfxFontFamily - // objects for each family. Individual gfxFontEntry objects for each face - // are not created here; the patterns are just stored in the family. When - // a family is actually used, it will be populated with gfxFontEntry - // records and the patterns moved to those. + // objects for each family. The patterns for individual fonts are not + // copied here. When a family is actually used, the fonts in the family + // are enumerated and the patterns copied. Note that we're explicitly + // excluding non-scalable fonts such as X11 bitmap fonts, which + // Chrome Skia/Webkit code does also. if (!aFontSet) { NS_WARNING("AddFontSetFamilies called with a null font set."); @@ -1333,165 +1291,88 @@ gfxFcPlatformFontList::AddFontSetFamilies(FcFontSet* aFontSet, RefPtr fontFamily; nsAutoString familyName; for (int f = 0; f < aFontSet->nfont; f++) { - FcPattern* pattern = aFontSet->fonts[f]; + FcPattern* font = aFontSet->fonts[f]; - // Skip any fonts that aren't readable for us (e.g. due to restrictive - // file ownership/permissions). - FcChar8* path; - if (FcPatternGetString(pattern, FC_FILE, 0, &path) != FcResultMatch) { - continue; - } - if (access(reinterpret_cast(path), F_OK | R_OK) != 0) { + // get canonical name + uint32_t cIndex = FindCanonicalNameIndex(font, FC_FAMILYLANG); + FcChar8* canonical = nullptr; + FcPatternGetString(font, FC_FAMILY, cIndex, &canonical); + if (!canonical) { continue; } -#ifdef MOZ_CONTENT_SANDBOX - // Skip any fonts that will be blocked by the content-process sandbox - // policy. - if (aPolicy && !(aPolicy->Lookup(reinterpret_cast(path)) & - SandboxBroker::Perms::MAY_READ)) { - continue; - } -#endif + // same as the last one? no need to add a new family, skip + if (FcStrCmp(canonical, lastFamilyName) != 0) { + lastFamilyName = canonical; - AddPatternToFontList(pattern, lastFamilyName, - familyName, fontFamily, aAppFonts); - } -} + // add new family if one doesn't already exist + familyName.Truncate(); + AppendUTF8toUTF16(ToCharPtr(canonical), familyName); + nsAutoString keyName(familyName); + ToLowerCase(keyName); -void -gfxFcPlatformFontList::AddPatternToFontList(FcPattern* aFont, - FcChar8*& aLastFamilyName, - nsAString& aFamilyName, - RefPtr& aFontFamily, - bool aAppFonts) -{ - // get canonical name - uint32_t cIndex = FindCanonicalNameIndex(aFont, FC_FAMILYLANG); - FcChar8* canonical = nullptr; - FcPatternGetString(aFont, FC_FAMILY, cIndex, &canonical); - if (!canonical) { - return; - } + fontFamily = static_cast + (mFontFamilies.GetWeak(keyName)); + if (!fontFamily) { + fontFamily = new gfxFontconfigFontFamily(familyName); + mFontFamilies.Put(keyName, fontFamily); + } + // Record if the family contains fonts from the app font set + // (in which case we won't rely on fontconfig's charmap, due to + // bug 1276594). + if (aAppFonts) { + fontFamily->SetFamilyContainsAppFonts(true); + } - // same as the last one? no need to add a new family, skip - if (FcStrCmp(canonical, aLastFamilyName) != 0) { - aLastFamilyName = canonical; - - // add new family if one doesn't already exist - aFamilyName.Truncate(); - AppendUTF8toUTF16(ToCharPtr(canonical), aFamilyName); - nsAutoString keyName(aFamilyName); - ToLowerCase(keyName); - - aFontFamily = static_cast - (mFontFamilies.GetWeak(keyName)); - if (!aFontFamily) { - aFontFamily = new gfxFontconfigFontFamily(aFamilyName); - mFontFamilies.Put(keyName, aFontFamily); - } - // Record if the family contains fonts from the app font set - // (in which case we won't rely on fontconfig's charmap, due to - // bug 1276594). - if (aAppFonts) { - aFontFamily->SetFamilyContainsAppFonts(true); - } - - // Add pointers to other localized family names. Most fonts - // only have a single name, so the first call to GetString - // will usually not match - FcChar8* otherName; - int n = (cIndex == 0 ? 1 : 0); - while (FcPatternGetString(aFont, FC_FAMILY, n, &otherName) == - FcResultMatch) { - NS_ConvertUTF8toUTF16 otherFamilyName(ToCharPtr(otherName)); - AddOtherFamilyName(aFontFamily, otherFamilyName); - n++; - if (n == int(cIndex)) { - n++; // skip over canonical name + // Add pointers to other localized family names. Most fonts + // only have a single name, so the first call to GetString + // will usually not match + FcChar8* otherName; + int n = (cIndex == 0 ? 1 : 0); + while (FcPatternGetString(font, FC_FAMILY, n, &otherName) == FcResultMatch) { + NS_ConvertUTF8toUTF16 otherFamilyName(ToCharPtr(otherName)); + AddOtherFamilyName(fontFamily, otherFamilyName); + n++; + if (n == int(cIndex)) { + n++; // skip over canonical name + } } } - } - MOZ_ASSERT(aFontFamily, "font must belong to a font family"); - aFontFamily->AddFontPattern(aFont); + NS_ASSERTION(fontFamily, "font must belong to a font family"); + fontFamily->AddFontPattern(font); - // map the psname, fullname ==> font family for local font lookups - nsAutoString psname, fullname; - GetFaceNames(aFont, aFamilyName, psname, fullname); - if (!psname.IsEmpty()) { - ToLowerCase(psname); - mLocalNames.Put(psname, aFont); - } - if (!fullname.IsEmpty()) { - ToLowerCase(fullname); - mLocalNames.Put(fullname, aFont); + // map the psname, fullname ==> font family for local font lookups + nsAutoString psname, fullname; + GetFaceNames(font, familyName, psname, fullname); + if (!psname.IsEmpty()) { + ToLowerCase(psname); + mLocalNames.Put(psname, font); + } + if (!fullname.IsEmpty()) { + ToLowerCase(fullname); + mLocalNames.Put(fullname, font); + } } } nsresult gfxFcPlatformFontList::InitFontListForPlatform() { -#ifdef MOZ_BUNDLED_FONTS - ActivateBundledFonts(); -#endif + mLastConfig = FcConfigGetCurrent(); mLocalNames.Clear(); mFcSubstituteCache.Clear(); - mAlwaysUseFontconfigGenerics = PrefFontListsUseOnlyGenerics(); - - if (!XRE_IsParentProcess()) { - // Content process: use the font list passed from the chrome process, - // because we can't rely on fontconfig in the presence of sandboxing; - // it may report fonts that we can't actually access. - - FcChar8* lastFamilyName = (FcChar8*)""; - RefPtr fontFamily; - nsAutoString familyName; - - // Get font list that was passed during XPCOM startup - // or in an UpdateFontList message. - auto& fontList = dom::ContentChild::GetSingleton()->SystemFontList(); - - for (SystemFontListEntry& fle : fontList) { - MOZ_ASSERT(fle.type() == - SystemFontListEntry::Type::TFontPatternListEntry); - FontPatternListEntry& fpe(fle); - FcPattern* pattern = - FcNameParse((const FcChar8*)fpe.pattern().get()); - AddPatternToFontList(pattern, lastFamilyName, familyName, - fontFamily, fpe.appFontFamily()); - } - - LOG_FONTLIST(("got font list from chrome process: " - "%u faces in %u families", - (unsigned)fontList.Length(), mFontFamilies.Count())); - - return NS_OK; - } - - mLastConfig = FcConfigGetCurrent(); - - UniquePtr policy; - -#ifdef MOZ_CONTENT_SANDBOX - // Create a temporary SandboxPolicy to check font paths; use a fake PID - // to avoid picking up any PID-specific rules by accident. - SandboxBrokerPolicyFactory policyFactory; - if (GetEffectiveContentSandboxLevel() > 0 && - !PR_GetEnv("MOZ_DISABLE_CONTENT_SANDBOX")) { - policy = policyFactory.GetContentPolicy(-1, false); - } -#endif - // iterate over available fonts FcFontSet* systemFonts = FcConfigGetFonts(nullptr, FcSetSystem); - AddFontSetFamilies(systemFonts, policy.get(), /* aAppFonts = */ false); + AddFontSetFamilies(systemFonts, /* aAppFonts = */ false); + mAlwaysUseFontconfigGenerics = PrefFontListsUseOnlyGenerics(); #ifdef MOZ_BUNDLED_FONTS + ActivateBundledFonts(); FcFontSet* appFonts = FcConfigGetFonts(nullptr, FcSetApplication); - AddFontSetFamilies(appFonts, policy.get(), /* aAppFonts = */ true); + AddFontSetFamilies(appFonts, /* aAppFonts = */ true); #endif mOtherFamilyNamesInitialized = true; @@ -1499,16 +1380,6 @@ gfxFcPlatformFontList::InitFontListForPlatform() return NS_OK; } -void -gfxFcPlatformFontList::ReadSystemFontList( - InfallibleTArray* retValue) -{ - for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) { - auto family = static_cast(iter.Data().get()); - family->AddFacesToFontList(retValue); - } -} - // For displaying the fontlist in UI, use explicit call to FcFontList. Using // FcFontList results in the list containing the localized names as dictated // by system defaults. @@ -2116,8 +1987,6 @@ gfxFcPlatformFontList::CheckFontUpdates(nsITimer *aTimer, void *aThis) if (current != pfl->GetLastConfig()) { pfl->UpdateFontList(); pfl->ForceGlobalReflow(); - - mozilla::dom::ContentParent::NotifyUpdatedFonts(); } } diff --git a/gfx/thebes/gfxFcPlatformFontList.h b/gfx/thebes/gfxFcPlatformFontList.h index 165c53125b50..a54db670d8bd 100644 --- a/gfx/thebes/gfxFcPlatformFontList.h +++ b/gfx/thebes/gfxFcPlatformFontList.h @@ -21,16 +21,6 @@ #include #include -#ifdef MOZ_CONTENT_SANDBOX -#include "mozilla/SandboxBroker.h" -#endif - -namespace mozilla { - namespace dom { - class SystemFontListEntry; - }; -}; - template <> class nsAutoRefTraits : public nsPointerRefTraits { @@ -192,9 +182,6 @@ public: mForceScalable(false) { } - void AddFacesToFontList( - InfallibleTArray* aFontList); - void FindStyleVariations(FontInfoData *aFontInfoData = nullptr) override; // Families are constructed initially with just references to patterns. @@ -267,8 +254,6 @@ public: const nsACString& aGenericFamily, nsTArray& aListOfFonts) override; - void ReadSystemFontList( - InfallibleTArray* retValue); gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, @@ -309,23 +294,9 @@ public: protected: virtual ~gfxFcPlatformFontList(); -#ifdef MOZ_CONTENT_SANDBOX - typedef mozilla::SandboxBroker::Policy SandboxPolicy; -#else - // Dummy type just so we can still have a SandboxPolicy* parameter. - struct SandboxPolicy; -#endif - // Add all the font families found in a font set. // aAppFonts indicates whether this is the system or application fontset. - void AddFontSetFamilies(FcFontSet* aFontSet, const SandboxPolicy* aPolicy, - bool aAppFonts); - - // Helper for above, to add a single font pattern. - void AddPatternToFontList(FcPattern* aFont, FcChar8*& aLastFamilyName, - nsAString& aFamilyName, - RefPtr& aFontFamily, - bool aAppFonts); + void AddFontSetFamilies(FcFontSet* aFontSet, bool aAppFonts); // figure out which families fontconfig maps a generic to // (aGeneric assumed already lowercase) diff --git a/gfx/thebes/gfxMacPlatformFontList.h b/gfx/thebes/gfxMacPlatformFontList.h index b26ef7589fa9..df2ba3638e86 100644 --- a/gfx/thebes/gfxMacPlatformFontList.h +++ b/gfx/thebes/gfxMacPlatformFontList.h @@ -159,8 +159,8 @@ public: kTextSizeSystemFontFamily = 2, // name of 'system' font at text sizes kDisplaySizeSystemFontFamily = 3 // 'system' font at display sizes }; - void ReadSystemFontList( - InfallibleTArray* aList); + void GetSystemFontFamilyList( + InfallibleTArray* aList); protected: gfxFontFamily* diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm index 81943586d773..b96e8e69df26 100644 --- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -64,7 +64,6 @@ #include "gfxFontConstants.h" #include "mozilla/dom/ContentChild.h" -#include "mozilla/dom/ContentParent.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Preferences.h" #include "mozilla/Sprintf.h" @@ -77,7 +76,6 @@ using namespace mozilla; using namespace mozilla::gfx; -using mozilla::dom::SystemFontListEntry; using mozilla::dom::FontFamilyListEntry; // indexes into the NSArray objects that the Cocoa font manager returns @@ -989,17 +987,12 @@ gfxMacPlatformFontList::gfxMacPlatformFontList() : } } - // Only the parent process listens for OS font-changed notifications; - // after rebuilding its list, it will update the content processes. - if (XRE_IsParentProcess()) { - ::CFNotificationCenterAddObserver( - ::CFNotificationCenterGetLocalCenter(), - this, - RegisteredFontsChangedNotificationCallback, - kCTFontManagerRegisteredFontsChangedNotification, - 0, - CFNotificationSuspensionBehaviorDeliverImmediately); - } + ::CFNotificationCenterAddObserver(::CFNotificationCenterGetLocalCenter(), + this, + RegisteredFontsChangedNotificationCallback, + kCTFontManagerRegisteredFontsChangedNotification, + 0, + CFNotificationSuspensionBehaviorDeliverImmediately); // cache this in a static variable so that MacOSFontFamily objects // don't have to repeatedly look it up @@ -1008,13 +1001,10 @@ gfxMacPlatformFontList::gfxMacPlatformFontList() : gfxMacPlatformFontList::~gfxMacPlatformFontList() { - if (XRE_IsParentProcess()) { - ::CFNotificationCenterRemoveObserver( - ::CFNotificationCenterGetLocalCenter(), - this, - kCTFontManagerRegisteredFontsChangedNotification, - 0); - } + ::CFNotificationCenterRemoveObserver(::CFNotificationCenterGetLocalCenter(), + this, + kCTFontManagerRegisteredFontsChangedNotification, + 0); if (mDefaultFont) { ::CFRelease(mDefaultFont); @@ -1066,8 +1056,8 @@ gfxMacPlatformFontList::AddFamily(CFStringRef aFamily) } void -gfxMacPlatformFontList::ReadSystemFontList( - InfallibleTArray* aList) +gfxMacPlatformFontList::GetSystemFontFamilyList( + InfallibleTArray* aList) { // Note: We rely on the records for mSystemTextFontFamilyName and // mSystemDisplayFontFamilyName (if present) being *before* the main @@ -1109,27 +1099,27 @@ gfxMacPlatformFontList::InitFontListForPlatform() // Content process: use font list passed from the chrome process via // the GetXPCOMProcessAttributes message, because it's much faster than // querying Core Text again in the child. - auto& fontList = dom::ContentChild::GetSingleton()->SystemFontList(); - for (SystemFontListEntry& fle : fontList) { - MOZ_ASSERT(fle.type() == - SystemFontListEntry::Type::TFontFamilyListEntry); - FontFamilyListEntry& ffe(fle); - switch (ffe.entryType()) { + mozilla::dom::ContentChild* cc = + mozilla::dom::ContentChild::GetSingleton(); + for (auto f : cc->SystemFontFamilyList()) { + switch (f.entryType()) { case kStandardFontFamily: - AddFamily(ffe.familyName(), false); + AddFamily(f.familyName(), false); break; case kHiddenSystemFontFamily: - AddFamily(ffe.familyName(), true); + AddFamily(f.familyName(), true); break; case kTextSizeSystemFontFamily: - mSystemTextFontFamilyName = ffe.familyName(); + mSystemTextFontFamilyName = f.familyName(); break; case kDisplaySizeSystemFontFamily: - mSystemDisplayFontFamilyName = ffe.familyName(); + mSystemDisplayFontFamilyName = f.familyName(); mUseSizeSensitiveSystemFont = true; break; } } + // The ContentChild doesn't need the font list any longer. + cc->SystemFontFamilyList().Clear(); } // If this is the chrome process, or if for some reason we failed to get @@ -1353,8 +1343,6 @@ gfxMacPlatformFontList::RegisteredFontsChangedNotificationCallback(CFNotificatio // modify a preference that will trigger reflow everywhere fl->ForceGlobalReflow(); - - mozilla::dom::ContentParent::NotifyUpdatedFonts(); } gfxFontEntry* diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index c000eac0ca1a..9d7191851cdb 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -64,7 +64,7 @@ BackendTypeBit(BackendType b) } // namespace gfx namespace dom { -class SystemFontListEntry; +class FontFamilyListEntry; } } // namespace mozilla @@ -337,12 +337,12 @@ public: nsTArray& aListOfFonts); /** - * Fill aFontList with a list of SystemFontListEntry records for the + * Fill aFontFamilies with a list of FontFamilyListEntry records for the * available fonts on the platform; used to pass the list from chrome to - * content process. Currently implemented only on MacOSX and Linux. + * content process. Currently implemented only on MacOSX. */ - virtual void ReadSystemFontList( - InfallibleTArray* aFontList) + virtual void GetSystemFontFamilyList( + InfallibleTArray* aFontFamilies) { } /** diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp index cd46dc26d73a..64773ebbfb94 100644 --- a/gfx/thebes/gfxPlatformGtk.cpp +++ b/gfx/thebes/gfxPlatformGtk.cpp @@ -65,7 +65,6 @@ using namespace mozilla; using namespace mozilla::gfx; using namespace mozilla::unicode; -using mozilla::dom::SystemFontListEntry; #if (MOZ_WIDGET_GTK == 2) static cairo_user_data_key_t cairo_gdk_drawable_key; @@ -250,13 +249,6 @@ gfxPlatformGtk::GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh, } } -void -gfxPlatformGtk::ReadSystemFontList( - InfallibleTArray* retValue) -{ - gfxFcPlatformFontList::PlatformFontList()->ReadSystemFontList(retValue); -} - gfxPlatformFontList* gfxPlatformGtk::CreatePlatformFontList() { diff --git a/gfx/thebes/gfxPlatformGtk.h b/gfx/thebes/gfxPlatformGtk.h index bc111782055a..bd1a59593934 100644 --- a/gfx/thebes/gfxPlatformGtk.h +++ b/gfx/thebes/gfxPlatformGtk.h @@ -22,12 +22,6 @@ struct _XDisplay; typedef struct _XDisplay Display; #endif // MOZ_X11 -namespace mozilla { - namespace dom { - class SystemFontListEntry; - }; -}; - class gfxPlatformGtk : public gfxPlatform { public: gfxPlatformGtk(); @@ -37,9 +31,6 @@ public: return (gfxPlatformGtk*) gfxPlatform::GetPlatform(); } - void ReadSystemFontList( - InfallibleTArray* retValue) override; - virtual already_AddRefed CreateOffscreenSurface(const IntSize& aSize, gfxImageFormat aFormat) override; diff --git a/gfx/thebes/gfxPlatformMac.cpp b/gfx/thebes/gfxPlatformMac.cpp index b3af8c3329d4..95d0ee8ba33d 100644 --- a/gfx/thebes/gfxPlatformMac.cpp +++ b/gfx/thebes/gfxPlatformMac.cpp @@ -30,7 +30,7 @@ using namespace mozilla; using namespace mozilla::gfx; -using mozilla::dom::SystemFontListEntry; +using mozilla::dom::FontFamilyListEntry; // cribbed from CTFontManager.h enum { @@ -113,10 +113,11 @@ gfxPlatformMac::CreatePlatformFontList() } void -gfxPlatformMac::ReadSystemFontList( - InfallibleTArray* aFontList) +gfxPlatformMac::GetSystemFontFamilyList( + InfallibleTArray* aFontFamilies) { - gfxMacPlatformFontList::PlatformFontList()->ReadSystemFontList(aFontList); + gfxMacPlatformFontList::PlatformFontList()-> + GetSystemFontFamilyList(aFontFamilies); } already_AddRefed diff --git a/gfx/thebes/gfxPlatformMac.h b/gfx/thebes/gfxPlatformMac.h index 0ad04b83d078..285f5a8fb7c5 100644 --- a/gfx/thebes/gfxPlatformMac.h +++ b/gfx/thebes/gfxPlatformMac.h @@ -40,8 +40,8 @@ public: virtual gfxPlatformFontList* CreatePlatformFontList() override; void - ReadSystemFontList(InfallibleTArray* - aFontList) override; + GetSystemFontFamilyList(InfallibleTArray* + aFontFamilies) override; bool IsFontFormatSupported(uint32_t aFormatFlags) override;