mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Backed out csets f9763adebe68, a1c1fe33a052, bf35d13e27f3, c6ad01bf0b66 (bug 1412090) for ASan failures.
This commit is contained in:
parent
da7918b9f1
commit
ed7a380b0c
@ -548,14 +548,14 @@ mozilla::ipc::IPCResult
|
||||
ContentChild::RecvSetXPCOMProcessAttributes(const XPCOMInitData& aXPCOMInit,
|
||||
const StructuredCloneData& aInitialData,
|
||||
nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache,
|
||||
nsTArray<SystemFontListEntry>&& aFontList)
|
||||
nsTArray<FontFamilyListEntry>&& 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<nsString>&& aDictionarie
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
ContentChild::RecvUpdateFontList(InfallibleTArray<SystemFontListEntry>&& aFontList)
|
||||
{
|
||||
mFontList = Move(aFontList);
|
||||
gfxPlatform::GetPlatform()->UpdateFontList();
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
ContentChild::RecvUpdateAppLocales(nsTArray<nsCString>&& aAppLocales)
|
||||
{
|
||||
|
@ -399,8 +399,6 @@ public:
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvUpdateDictionaryList(InfallibleTArray<nsString>&& aDictionaries) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvUpdateFontList(InfallibleTArray<SystemFontListEntry>&& aFontList) override;
|
||||
|
||||
virtual mozilla::ipc::IPCResult RecvUpdateAppLocales(nsTArray<nsCString>&& aAppLocales) override;
|
||||
virtual mozilla::ipc::IPCResult RecvUpdateRequestedLocales(nsTArray<nsCString>&& aRequestedLocales) override;
|
||||
|
||||
@ -605,7 +603,7 @@ public:
|
||||
RecvSetXPCOMProcessAttributes(const XPCOMInitData& aXPCOMInit,
|
||||
const StructuredCloneData& aInitialData,
|
||||
nsTArray<LookAndFeelInt>&& aLookAndFeelIntCache,
|
||||
nsTArray<SystemFontListEntry>&& aFontList) override;
|
||||
nsTArray<FontFamilyListEntry>&& 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<mozilla::dom::SystemFontListEntry>&
|
||||
SystemFontList() {
|
||||
return mFontList;
|
||||
InfallibleTArray<mozilla::dom::FontFamilyListEntry>&
|
||||
SystemFontFamilyList() {
|
||||
return mFontFamilies;
|
||||
}
|
||||
|
||||
// PURLClassifierChild
|
||||
@ -751,10 +749,10 @@ private:
|
||||
|
||||
InfallibleTArray<nsString> 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<mozilla::dom::SystemFontListEntry> mFontList;
|
||||
// only on MacOSX.
|
||||
InfallibleTArray<mozilla::dom::FontFamilyListEntry> mFontFamilies;
|
||||
// Temporary storage for nsXPLookAndFeel flags.
|
||||
nsTArray<LookAndFeelInt> mLookAndFeelCache;
|
||||
|
||||
|
@ -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<SystemFontListEntry> fontList;
|
||||
gfxPlatform::GetPlatform()->ReadSystemFontList(&fontList);
|
||||
// This is only implemented (returns a non-empty list) by MacOSX at present.
|
||||
nsTArray<FontFamilyListEntry> fontFamilies;
|
||||
gfxPlatform::GetPlatform()->GetSystemFontFamilyList(&fontFamilies);
|
||||
nsTArray<LookAndFeelInt> 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<nsIChromeRegistry> registrySvc = nsChromeRegistry::GetService();
|
||||
@ -4266,17 +4264,6 @@ ContentParent::NotifyUpdatedDictionaries()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ContentParent::NotifyUpdatedFonts()
|
||||
{
|
||||
InfallibleTArray<SystemFontListEntry> fontList;
|
||||
gfxPlatform::GetPlatform()->ReadSystemFontList(&fontList);
|
||||
|
||||
for (auto* cp : AllProcesses(eLive)) {
|
||||
Unused << cp->SendUpdateFontList(fontList);
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
ContentParent::UnregisterRemoteFrame(const TabId& aTabId,
|
||||
const ContentParentId& aCpId,
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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 <fontconfig/fcfreetype.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK
|
||||
#include <gdk/gdk.h>
|
||||
@ -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<SystemFontListEntry>* aFontList)
|
||||
{
|
||||
if (HasStyles()) {
|
||||
for (auto& fe : mAvailableFonts) {
|
||||
if (!fe) {
|
||||
continue;
|
||||
}
|
||||
auto fce = static_cast<gfxFontconfigFontEntry*>(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<UnscaledFontFontconfig>& 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<gfxFontconfigFontFamily> 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<const char*>(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<const char*>(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<gfxFontconfigFontFamily>& 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<gfxFontconfigFontFamily*>
|
||||
(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<gfxFontconfigFontFamily*>
|
||||
(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<gfxFontconfigFontFamily> 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<SandboxPolicy> 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<SystemFontListEntry>* retValue)
|
||||
{
|
||||
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
|
||||
auto family = static_cast<gfxFontconfigFontFamily*>(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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,16 +21,6 @@
|
||||
#include <cairo.h>
|
||||
#include <cairo-ft.h>
|
||||
|
||||
#ifdef MOZ_CONTENT_SANDBOX
|
||||
#include "mozilla/SandboxBroker.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class SystemFontListEntry;
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
class nsAutoRefTraits<FcPattern> : public nsPointerRefTraits<FcPattern>
|
||||
{
|
||||
@ -192,9 +182,6 @@ public:
|
||||
mForceScalable(false)
|
||||
{ }
|
||||
|
||||
void AddFacesToFontList(
|
||||
InfallibleTArray<mozilla::dom::SystemFontListEntry>* 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<nsString>& aListOfFonts) override;
|
||||
|
||||
void ReadSystemFontList(
|
||||
InfallibleTArray<mozilla::dom::SystemFontListEntry>* 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<gfxFontconfigFontFamily>& aFontFamily,
|
||||
bool aAppFonts);
|
||||
void AddFontSetFamilies(FcFontSet* aFontSet, bool aAppFonts);
|
||||
|
||||
// figure out which families fontconfig maps a generic to
|
||||
// (aGeneric assumed already lowercase)
|
||||
|
@ -159,8 +159,8 @@ public:
|
||||
kTextSizeSystemFontFamily = 2, // name of 'system' font at text sizes
|
||||
kDisplaySizeSystemFontFamily = 3 // 'system' font at display sizes
|
||||
};
|
||||
void ReadSystemFontList(
|
||||
InfallibleTArray<mozilla::dom::SystemFontListEntry>* aList);
|
||||
void GetSystemFontFamilyList(
|
||||
InfallibleTArray<mozilla::dom::FontFamilyListEntry>* aList);
|
||||
|
||||
protected:
|
||||
gfxFontFamily*
|
||||
|
@ -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<SystemFontListEntry>* aList)
|
||||
gfxMacPlatformFontList::GetSystemFontFamilyList(
|
||||
InfallibleTArray<FontFamilyListEntry>* 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*
|
||||
|
@ -64,7 +64,7 @@ BackendTypeBit(BackendType b)
|
||||
|
||||
} // namespace gfx
|
||||
namespace dom {
|
||||
class SystemFontListEntry;
|
||||
class FontFamilyListEntry;
|
||||
}
|
||||
} // namespace mozilla
|
||||
|
||||
@ -337,12 +337,12 @@ public:
|
||||
nsTArray<nsString>& 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<mozilla::dom::SystemFontListEntry>* aFontList)
|
||||
virtual void GetSystemFontFamilyList(
|
||||
InfallibleTArray<mozilla::dom::FontFamilyListEntry>* aFontFamilies)
|
||||
{ }
|
||||
|
||||
/**
|
||||
|
@ -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<SystemFontListEntry>* retValue)
|
||||
{
|
||||
gfxFcPlatformFontList::PlatformFontList()->ReadSystemFontList(retValue);
|
||||
}
|
||||
|
||||
gfxPlatformFontList*
|
||||
gfxPlatformGtk::CreatePlatformFontList()
|
||||
{
|
||||
|
@ -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<mozilla::dom::SystemFontListEntry>* retValue) override;
|
||||
|
||||
virtual already_AddRefed<gfxASurface>
|
||||
CreateOffscreenSurface(const IntSize& aSize,
|
||||
gfxImageFormat aFormat) override;
|
||||
|
@ -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<SystemFontListEntry>* aFontList)
|
||||
gfxPlatformMac::GetSystemFontFamilyList(
|
||||
InfallibleTArray<FontFamilyListEntry>* aFontFamilies)
|
||||
{
|
||||
gfxMacPlatformFontList::PlatformFontList()->ReadSystemFontList(aFontList);
|
||||
gfxMacPlatformFontList::PlatformFontList()->
|
||||
GetSystemFontFamilyList(aFontFamilies);
|
||||
}
|
||||
|
||||
already_AddRefed<gfxASurface>
|
||||
|
@ -40,8 +40,8 @@ public:
|
||||
virtual gfxPlatformFontList* CreatePlatformFontList() override;
|
||||
|
||||
void
|
||||
ReadSystemFontList(InfallibleTArray<mozilla::dom::SystemFontListEntry>*
|
||||
aFontList) override;
|
||||
GetSystemFontFamilyList(InfallibleTArray<mozilla::dom::FontFamilyListEntry>*
|
||||
aFontFamilies) override;
|
||||
|
||||
bool IsFontFormatSupported(uint32_t aFormatFlags) override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user