mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 00:32:11 +00:00
Bug 1708768 - Preliminary cleanup of gfxPlatformFontList creation/initialization code; no functional change. r=lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D114863
This commit is contained in:
parent
276f5ab72c
commit
18310539bf
@ -258,13 +258,8 @@ void gfxAndroidPlatform::GetCommonFallbackFonts(
|
||||
aFontList.AppendElement("Droid Sans Fallback");
|
||||
}
|
||||
|
||||
gfxPlatformFontList* gfxAndroidPlatform::CreatePlatformFontList() {
|
||||
gfxPlatformFontList* list = new gfxFT2FontList();
|
||||
if (NS_SUCCEEDED(list->InitFontList())) {
|
||||
return list;
|
||||
}
|
||||
gfxPlatformFontList::Shutdown();
|
||||
return nullptr;
|
||||
bool gfxAndroidPlatform::CreatePlatformFontList() {
|
||||
return gfxPlatformFontList::Initialize(new gfxFT2FontList);
|
||||
}
|
||||
|
||||
void gfxAndroidPlatform::ReadSystemFontList(
|
||||
|
@ -26,7 +26,7 @@ class gfxAndroidPlatform final : public gfxPlatform {
|
||||
gfxImageFormat GetOffscreenFormat() override { return mOffscreenFormat; }
|
||||
|
||||
// platform implementations of font functions
|
||||
gfxPlatformFontList* CreatePlatformFontList() override;
|
||||
bool CreatePlatformFontList() override;
|
||||
|
||||
void ReadSystemFontList(mozilla::dom::SystemFontList*) override;
|
||||
|
||||
|
@ -369,7 +369,8 @@ class gfxDWriteFontList final : public gfxPlatformFontList {
|
||||
gfxDWriteFontList();
|
||||
|
||||
static gfxDWriteFontList* PlatformFontList() {
|
||||
return static_cast<gfxDWriteFontList*>(sPlatformFontList);
|
||||
return static_cast<gfxDWriteFontList*>(
|
||||
gfxPlatformFontList::PlatformFontList());
|
||||
}
|
||||
|
||||
// initialize font lists
|
||||
|
@ -239,7 +239,8 @@ class gfxFcPlatformFontList final : public gfxPlatformFontList {
|
||||
gfxFcPlatformFontList();
|
||||
|
||||
static gfxFcPlatformFontList* PlatformFontList() {
|
||||
return static_cast<gfxFcPlatformFontList*>(sPlatformFontList);
|
||||
return static_cast<gfxFcPlatformFontList*>(
|
||||
gfxPlatformFontList::PlatformFontList());
|
||||
}
|
||||
|
||||
// initialize font lists
|
||||
|
@ -294,7 +294,8 @@ class GDIFontFamily final : public gfxFontFamily {
|
||||
class gfxGDIFontList final : public gfxPlatformFontList {
|
||||
public:
|
||||
static gfxGDIFontList* PlatformFontList() {
|
||||
return static_cast<gfxGDIFontList*>(sPlatformFontList);
|
||||
return static_cast<gfxGDIFontList*>(
|
||||
gfxPlatformFontList::PlatformFontList());
|
||||
}
|
||||
|
||||
// initialize font lists
|
||||
|
@ -118,7 +118,8 @@ class gfxMacPlatformFontList final : public gfxPlatformFontList {
|
||||
|
||||
public:
|
||||
static gfxMacPlatformFontList* PlatformFontList() {
|
||||
return static_cast<gfxMacPlatformFontList*>(sPlatformFontList);
|
||||
return static_cast<gfxMacPlatformFontList*>(
|
||||
gfxPlatformFontList::PlatformFontList());
|
||||
}
|
||||
|
||||
gfxFontFamily* CreateFontFamily(const nsACString& aName,
|
||||
|
@ -968,9 +968,7 @@ void gfxPlatform::Init() {
|
||||
|
||||
gPlatform->mHasVariationFontSupport = gPlatform->CheckVariationFontSupport();
|
||||
|
||||
nsresult rv;
|
||||
rv = gfxPlatformFontList::Init();
|
||||
if (NS_FAILED(rv)) {
|
||||
if (!gPlatform->CreatePlatformFontList()) {
|
||||
MOZ_CRASH("Could not initialize gfxPlatformFontList");
|
||||
}
|
||||
|
||||
@ -993,8 +991,7 @@ void gfxPlatform::Init() {
|
||||
}
|
||||
}
|
||||
|
||||
rv = gfxFontCache::Init();
|
||||
if (NS_FAILED(rv)) {
|
||||
if (NS_FAILED(gfxFontCache::Init())) {
|
||||
MOZ_CRASH("Could not initialize gfxFontCache");
|
||||
}
|
||||
|
||||
|
@ -377,12 +377,7 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
|
||||
* subclass). This function is responsible to create the appropriate subclass
|
||||
* of gfxPlatformFontList *and* to call its InitFontList() method.
|
||||
*/
|
||||
virtual gfxPlatformFontList* CreatePlatformFontList() {
|
||||
MOZ_ASSERT_UNREACHABLE(
|
||||
"oops, this platform doesn't have a "
|
||||
"gfxPlatformFontList implementation");
|
||||
return nullptr;
|
||||
}
|
||||
virtual bool CreatePlatformFontList() = 0;
|
||||
|
||||
/**
|
||||
* Resolving a font name to family name. The result MUST be in the result of
|
||||
|
@ -436,7 +436,7 @@ bool gfxPlatformFontList::AddWithLegacyFamilyName(const nsACString& aLegacyName,
|
||||
return added;
|
||||
}
|
||||
|
||||
nsresult gfxPlatformFontList::InitFontList() {
|
||||
bool gfxPlatformFontList::InitFontList() {
|
||||
// This shouldn't be called from stylo threads!
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
@ -486,8 +486,6 @@ nsresult gfxPlatformFontList::InitFontList() {
|
||||
mVisibilityLevel = FontVisibility::Unknown;
|
||||
SetVisibilityLevel();
|
||||
|
||||
sPlatformFontList = this;
|
||||
|
||||
// Try to initialize the cross-process shared font list if enabled by prefs,
|
||||
// but not if we're running in Safe Mode.
|
||||
if (StaticPrefs::gfx_e10s_font_list_shared_AtStartup() &&
|
||||
@ -516,18 +514,15 @@ nsresult gfxPlatformFontList::InitFontList() {
|
||||
"falling back to in-process list.";
|
||||
mSharedFontList.reset(nullptr);
|
||||
}
|
||||
if (oldSharedList) {
|
||||
if (XRE_IsParentProcess()) {
|
||||
// notify all children of the change
|
||||
dom::ContentParent::NotifyUpdatedFonts(true);
|
||||
}
|
||||
if (oldSharedList && XRE_IsParentProcess()) {
|
||||
// notify all children of the change
|
||||
dom::ContentParent::NotifyUpdatedFonts(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!SharedFontList()) {
|
||||
nsresult rv = InitFontListForPlatform();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
if (NS_FAILED(InitFontListForPlatform())) {
|
||||
return false;
|
||||
}
|
||||
ApplyWhitelist();
|
||||
}
|
||||
@ -538,16 +533,13 @@ nsresult gfxPlatformFontList::InitFontList() {
|
||||
FontFamily fam = GetDefaultFont(&defStyle);
|
||||
if (fam.mIsShared) {
|
||||
auto face = fam.mShared->FindFaceForStyle(SharedFontList(), defStyle);
|
||||
if (!face) {
|
||||
mDefaultFontEntry = nullptr;
|
||||
} else {
|
||||
mDefaultFontEntry = GetOrCreateFontEntry(face, fam.mShared);
|
||||
}
|
||||
mDefaultFontEntry =
|
||||
face ? GetOrCreateFontEntry(face, fam.mShared) : nullptr;
|
||||
} else {
|
||||
mDefaultFontEntry = fam.mUnshared->FindFontForStyle(defStyle);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
void gfxPlatformFontList::InitializeCodepointsWithNoFonts() {
|
||||
|
@ -171,13 +171,13 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
|
||||
|
||||
static gfxPlatformFontList* PlatformFontList() { return sPlatformFontList; }
|
||||
|
||||
static nsresult Init() {
|
||||
NS_ASSERTION(!sPlatformFontList, "What's this doing here?");
|
||||
gfxPlatform::GetPlatform()->CreatePlatformFontList();
|
||||
if (!sPlatformFontList) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
static bool Initialize(gfxPlatformFontList* aList) {
|
||||
sPlatformFontList = aList;
|
||||
if (aList->InitFontList()) {
|
||||
return true;
|
||||
}
|
||||
return NS_OK;
|
||||
Shutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
static void Shutdown() {
|
||||
@ -187,8 +187,8 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
|
||||
|
||||
virtual ~gfxPlatformFontList();
|
||||
|
||||
// initialize font lists
|
||||
nsresult InitFontList();
|
||||
// Initialize font lists; return true on success, false if something fails.
|
||||
bool InitFontList();
|
||||
|
||||
void FontListChanged();
|
||||
|
||||
|
@ -370,13 +370,8 @@ void gfxPlatformGtk::ReadSystemFontList(
|
||||
gfxFcPlatformFontList::PlatformFontList()->ReadSystemFontList(retValue);
|
||||
}
|
||||
|
||||
gfxPlatformFontList* gfxPlatformGtk::CreatePlatformFontList() {
|
||||
gfxPlatformFontList* list = new gfxFcPlatformFontList();
|
||||
if (NS_SUCCEEDED(list->InitFontList())) {
|
||||
return list;
|
||||
}
|
||||
gfxPlatformFontList::Shutdown();
|
||||
return nullptr;
|
||||
bool gfxPlatformGtk::CreatePlatformFontList() {
|
||||
return gfxPlatformFontList::Initialize(new gfxFcPlatformFontList);
|
||||
}
|
||||
|
||||
int32_t gfxPlatformGtk::GetFontScaleDPI() {
|
||||
|
@ -37,7 +37,7 @@ class gfxPlatformGtk final : public gfxPlatform {
|
||||
eFontPresentation aPresentation,
|
||||
nsTArray<const char*>& aFontList) override;
|
||||
|
||||
gfxPlatformFontList* CreatePlatformFontList() override;
|
||||
bool CreatePlatformFontList() override;
|
||||
|
||||
/**
|
||||
* Calls XFlush if xrender is enabled.
|
||||
|
@ -238,13 +238,8 @@ bool gfxPlatformMac::UsesTiling() const {
|
||||
|
||||
bool gfxPlatformMac::ContentUsesTiling() const { return UsesTiling(); }
|
||||
|
||||
gfxPlatformFontList* gfxPlatformMac::CreatePlatformFontList() {
|
||||
gfxPlatformFontList* list = new gfxMacPlatformFontList();
|
||||
if (NS_SUCCEEDED(list->InitFontList())) {
|
||||
return list;
|
||||
}
|
||||
gfxPlatformFontList::Shutdown();
|
||||
return nullptr;
|
||||
bool gfxPlatformMac::CreatePlatformFontList() {
|
||||
return gfxPlatformFontList::Initialize(new gfxMacPlatformFontList);
|
||||
}
|
||||
|
||||
void gfxPlatformMac::ReadSystemFontList(SystemFontList* aFontList) {
|
||||
|
@ -43,7 +43,7 @@ class gfxPlatformMac : public gfxPlatform {
|
||||
already_AddRefed<gfxASurface> CreateOffscreenSurface(
|
||||
const IntSize& aSize, gfxImageFormat aFormat) override;
|
||||
|
||||
gfxPlatformFontList* CreatePlatformFontList() override;
|
||||
bool CreatePlatformFontList() override;
|
||||
|
||||
void ReadSystemFontList(mozilla::dom::SystemFontList* aFontList) override;
|
||||
|
||||
|
@ -558,20 +558,16 @@ mozilla::gfx::BackendType gfxWindowsPlatform::GetPreferredCanvasBackend() {
|
||||
return backend;
|
||||
}
|
||||
|
||||
gfxPlatformFontList* gfxWindowsPlatform::CreatePlatformFontList() {
|
||||
gfxPlatformFontList* pfl;
|
||||
|
||||
bool gfxWindowsPlatform::CreatePlatformFontList() {
|
||||
// bug 630201 - older pre-RTM versions of Direct2D/DirectWrite cause odd
|
||||
// crashers so block them altogether
|
||||
if (IsNotWin7PreRTM() && DWriteEnabled()) {
|
||||
pfl = new gfxDWriteFontList();
|
||||
if (NS_SUCCEEDED(pfl->InitFontList())) {
|
||||
return pfl;
|
||||
if (gfxPlatformFontList::Initialize(new gfxDWriteFontList)) {
|
||||
return true;
|
||||
}
|
||||
// DWrite font initialization failed! Don't know why this would happen,
|
||||
// but apparently it can - see bug 594865.
|
||||
// So we're going to fall back to GDI fonts & rendering.
|
||||
gfxPlatformFontList::Shutdown();
|
||||
DisableD2D(FeatureStatus::Failed, "Failed to initialize fonts",
|
||||
"FEATURE_FAILURE_FONT_FAIL"_ns);
|
||||
}
|
||||
@ -580,14 +576,7 @@ gfxPlatformFontList* gfxWindowsPlatform::CreatePlatformFontList() {
|
||||
// permit it, as we're using GDI fonts.
|
||||
mHasVariationFontSupport = false;
|
||||
|
||||
pfl = new gfxGDIFontList();
|
||||
|
||||
if (NS_SUCCEEDED(pfl->InitFontList())) {
|
||||
return pfl;
|
||||
}
|
||||
|
||||
gfxPlatformFontList::Shutdown();
|
||||
return nullptr;
|
||||
return gfxPlatformFontList::Initialize(new gfxGDIFontList);
|
||||
}
|
||||
|
||||
// This function will permanently disable D2D for the session. It's intended to
|
||||
|
@ -107,7 +107,7 @@ class gfxWindowsPlatform final : public gfxPlatform {
|
||||
void EnsureDevicesInitialized() override;
|
||||
bool DevicesInitialized() override;
|
||||
|
||||
gfxPlatformFontList* CreatePlatformFontList() override;
|
||||
bool CreatePlatformFontList() override;
|
||||
|
||||
virtual already_AddRefed<gfxASurface> CreateOffscreenSurface(
|
||||
const IntSize& aSize, gfxImageFormat aFormat) override;
|
||||
|
Loading…
Reference in New Issue
Block a user