зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1533428 - patch 7 - Create a FontFamily type that wraps either a gfxFontFamily pointer or a mozilla::fontlist::Family pointer (to be used by the shared font list), and use this in various places where we need to pass families around. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D22934 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
5f45afb7ec
Коммит
d2a3361fa4
|
@ -837,12 +837,12 @@ gfxDWriteFontList::gfxDWriteFontList() : mForceGDIClassicMaxFontSize(0.0) {}
|
|||
// I/O strain during cold startup due to dwrite caching bugs. Default to
|
||||
// Arial to avoid this.
|
||||
|
||||
gfxFontFamily* gfxDWriteFontList::GetDefaultFontForPlatform(
|
||||
FontFamily gfxDWriteFontList::GetDefaultFontForPlatform(
|
||||
const gfxFontStyle* aStyle) {
|
||||
// try Arial first
|
||||
gfxFontFamily* ff;
|
||||
if ((ff = FindFamily(NS_LITERAL_CSTRING("Arial")))) {
|
||||
return ff;
|
||||
return FontFamily(ff);
|
||||
}
|
||||
|
||||
// otherwise, use local default
|
||||
|
@ -854,11 +854,11 @@ gfxFontFamily* gfxDWriteFontList::GetDefaultFontForPlatform(
|
|||
if (status) {
|
||||
ff = FindFamily(NS_ConvertUTF16toUTF8(ncm.lfMessageFont.lfFaceName));
|
||||
if (ff) {
|
||||
return ff;
|
||||
return FontFamily(ff);
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return FontFamily();
|
||||
}
|
||||
|
||||
gfxFontEntry* gfxDWriteFontList::LookupLocalFont(
|
||||
|
@ -1417,7 +1417,7 @@ IFACEMETHODIMP DWriteFontFallbackRenderer::DrawGlyphRun(
|
|||
|
||||
gfxFontEntry* gfxDWriteFontList::PlatformGlobalFontFallback(
|
||||
const uint32_t aCh, Script aRunScript, const gfxFontStyle* aMatchStyle,
|
||||
gfxFontFamily** aMatchedFamily) {
|
||||
FontFamily* aMatchedFamily) {
|
||||
HRESULT hr;
|
||||
|
||||
RefPtr<IDWriteFactory> dwFactory = Factory::GetDWriteFactory();
|
||||
|
@ -1477,7 +1477,7 @@ gfxFontEntry* gfxDWriteFontList::PlatformGlobalFontFallback(
|
|||
gfxFontEntry* fontEntry;
|
||||
fontEntry = family->FindFontForStyle(*aMatchStyle);
|
||||
if (fontEntry && fontEntry->HasCharacter(aCh)) {
|
||||
*aMatchedFamily = family;
|
||||
*aMatchedFamily = FontFamily(family);
|
||||
return fontEntry;
|
||||
}
|
||||
Telemetry::Accumulate(Telemetry::BAD_FALLBACK_FONT, true);
|
||||
|
|
|
@ -404,14 +404,14 @@ class gfxDWriteFontList : public gfxPlatformFontList {
|
|||
FontListSizes* aSizes) const;
|
||||
|
||||
protected:
|
||||
virtual gfxFontFamily* GetDefaultFontForPlatform(
|
||||
const gfxFontStyle* aStyle) override;
|
||||
FontFamily GetDefaultFontForPlatform(const gfxFontStyle* aStyle) override;
|
||||
|
||||
// attempt to use platform-specific fallback for the given character,
|
||||
// return null if no usable result found
|
||||
gfxFontEntry* PlatformGlobalFontFallback(
|
||||
const uint32_t aCh, Script aRunScript, const gfxFontStyle* aMatchStyle,
|
||||
gfxFontFamily** aMatchedFamily) override;
|
||||
gfxFontEntry* PlatformGlobalFontFallback(const uint32_t aCh,
|
||||
Script aRunScript,
|
||||
const gfxFontStyle* aMatchStyle,
|
||||
FontFamily* aMatchedFamily) override;
|
||||
|
||||
private:
|
||||
friend class gfxDWriteFontFamily;
|
||||
|
|
|
@ -1505,7 +1505,7 @@ searchDone:
|
|||
return fe;
|
||||
}
|
||||
|
||||
gfxFontFamily* gfxFT2FontList::GetDefaultFontForPlatform(
|
||||
FontFamily gfxFT2FontList::GetDefaultFontForPlatform(
|
||||
const gfxFontStyle* aStyle) {
|
||||
gfxFontFamily* ff = nullptr;
|
||||
#if defined(MOZ_WIDGET_ANDROID)
|
||||
|
@ -1515,7 +1515,7 @@ gfxFontFamily* gfxFT2FontList::GetDefaultFontForPlatform(
|
|||
}
|
||||
#endif
|
||||
/* TODO: what about Qt or other platforms that may use this? */
|
||||
return ff;
|
||||
return FontFamily(ff);
|
||||
}
|
||||
|
||||
gfxFontEntry* gfxFT2FontList::MakePlatformFont(const nsACString& aFontName,
|
||||
|
|
|
@ -176,8 +176,7 @@ class gfxFT2FontList : public gfxPlatformFontList {
|
|||
|
||||
void FindFontsInDir(const nsCString& aDir, FontNameCache* aFNC);
|
||||
|
||||
virtual gfxFontFamily* GetDefaultFontForPlatform(
|
||||
const gfxFontStyle* aStyle) override;
|
||||
FontFamily GetDefaultFontForPlatform(const gfxFontStyle* aStyle) override;
|
||||
|
||||
nsTHashtable<nsCStringHashKey> mSkipSpaceLookupCheckFamilies;
|
||||
|
||||
|
|
|
@ -1739,7 +1739,7 @@ void gfxFcPlatformFontList::GetFontList(nsAtom* aLangGroup,
|
|||
if (serif) aListOfFonts.InsertElementAt(0, NS_LITERAL_STRING("serif"));
|
||||
}
|
||||
|
||||
gfxFontFamily* gfxFcPlatformFontList::GetDefaultFontForPlatform(
|
||||
FontFamily gfxFcPlatformFontList::GetDefaultFontForPlatform(
|
||||
const gfxFontStyle* aStyle) {
|
||||
// Get the default font by using a fake name to retrieve the first
|
||||
// scalable font that fontconfig suggests for the given language.
|
||||
|
@ -1749,7 +1749,7 @@ gfxFontFamily* gfxFcPlatformFontList::GetDefaultFontForPlatform(
|
|||
if (prefFonts && !prefFonts->IsEmpty()) {
|
||||
return (*prefFonts)[0];
|
||||
}
|
||||
return nullptr;
|
||||
return FontFamily();
|
||||
}
|
||||
|
||||
gfxFontEntry* gfxFcPlatformFontList::LookupLocalFont(
|
||||
|
@ -2030,7 +2030,7 @@ void gfxFcPlatformFontList::AddGenericFonts(
|
|||
NS_ASSERTION(prefFonts, "null generic font list");
|
||||
aFamilyList.SetCapacity(aFamilyList.Length() + prefFonts->Length());
|
||||
for (auto& f : *prefFonts) {
|
||||
aFamilyList.AppendElement(FamilyAndGeneric(f.get(), aGenericType));
|
||||
aFamilyList.AppendElement(FamilyAndGeneric(f, aGenericType));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -349,8 +349,7 @@ class gfxFcPlatformFontList : public gfxPlatformFontList {
|
|||
|
||||
static void CheckFontUpdates(nsITimer* aTimer, void* aThis);
|
||||
|
||||
virtual gfxFontFamily* GetDefaultFontForPlatform(
|
||||
const gfxFontStyle* aStyle) override;
|
||||
FontFamily GetDefaultFontForPlatform(const gfxFontStyle* aStyle) override;
|
||||
|
||||
gfxFontFamily* CreateFontFamily(const nsACString& aName) const override;
|
||||
|
||||
|
|
|
@ -45,7 +45,11 @@ class nsAtom;
|
|||
|
||||
namespace mozilla {
|
||||
class SVGContextPaint;
|
||||
};
|
||||
namespace fontlist {
|
||||
struct Family;
|
||||
struct Face;
|
||||
} // namespace fontlist
|
||||
} // namespace mozilla
|
||||
|
||||
#define NO_FONT_LANGUAGE_OVERRIDE 0
|
||||
|
||||
|
@ -906,19 +910,61 @@ class gfxFontFamily {
|
|||
};
|
||||
};
|
||||
|
||||
// Wrapper for either a mozilla::fontlist::Family in the shared font list or an
|
||||
// unshared gfxFontFamily that belongs just to the current process. This does
|
||||
// not own a reference, it just wraps a raw pointer and records the type.
|
||||
struct FontFamily {
|
||||
FontFamily() : mUnshared(nullptr), mIsShared(false) {}
|
||||
|
||||
FontFamily(const FontFamily& aOther) = default;
|
||||
|
||||
explicit FontFamily(gfxFontFamily* aFamily)
|
||||
: mUnshared(aFamily), mIsShared(false) {}
|
||||
|
||||
explicit FontFamily(mozilla::fontlist::Family* aFamily)
|
||||
: mShared(aFamily), mIsShared(true) {}
|
||||
|
||||
bool operator==(const FontFamily& aOther) const {
|
||||
return mIsShared == aOther.mIsShared &&
|
||||
(mIsShared ? mShared == aOther.mShared
|
||||
: mUnshared == aOther.mUnshared);
|
||||
}
|
||||
|
||||
bool IsNull() const { return mIsShared ? !mShared : !mUnshared; }
|
||||
|
||||
union {
|
||||
gfxFontFamily* mUnshared;
|
||||
mozilla::fontlist::Family* mShared;
|
||||
};
|
||||
bool mIsShared;
|
||||
};
|
||||
|
||||
// Struct used in the gfxFontGroup font list to keep track of a font family
|
||||
// together with the CSS generic (if any) that was mapped to it in this
|
||||
// particular case (so it can be reported to the DevTools font inspector).
|
||||
struct FamilyAndGeneric final {
|
||||
FamilyAndGeneric()
|
||||
: mFamily(nullptr), mGeneric(mozilla::FontFamilyType::eFamily_none) {}
|
||||
: mFamily(), mGeneric(mozilla::FontFamilyType::eFamily_none) {}
|
||||
FamilyAndGeneric(const FamilyAndGeneric& aOther)
|
||||
: mFamily(aOther.mFamily), mGeneric(aOther.mGeneric) {}
|
||||
explicit FamilyAndGeneric(
|
||||
gfxFontFamily* aFamily,
|
||||
mozilla::FontFamilyType aGeneric = mozilla::FontFamilyType::eFamily_none)
|
||||
: mFamily(aFamily), mGeneric(aGeneric) {}
|
||||
gfxFontFamily* mFamily;
|
||||
explicit FamilyAndGeneric(
|
||||
mozilla::fontlist::Family* aFamily,
|
||||
mozilla::FontFamilyType aGeneric = mozilla::FontFamilyType::eFamily_none)
|
||||
: mFamily(aFamily), mGeneric(aGeneric) {}
|
||||
explicit FamilyAndGeneric(
|
||||
const FontFamily& aFamily,
|
||||
mozilla::FontFamilyType aGeneric = mozilla::FontFamilyType::eFamily_none)
|
||||
: mFamily(aFamily), mGeneric(aGeneric) {}
|
||||
|
||||
bool operator==(const FamilyAndGeneric& aOther) const {
|
||||
return (mFamily == aOther.mFamily && mGeneric == aOther.mGeneric);
|
||||
}
|
||||
|
||||
FontFamily mFamily;
|
||||
mozilla::FontFamilyType mGeneric;
|
||||
};
|
||||
|
||||
|
|
|
@ -843,7 +843,7 @@ bool gfxGDIFontList::FindAndAddFamilies(const nsACString& aFamily,
|
|||
aStyle, aDevToCssSize);
|
||||
}
|
||||
|
||||
gfxFontFamily* gfxGDIFontList::GetDefaultFontForPlatform(
|
||||
FontFamily gfxGDIFontList::GetDefaultFontForPlatform(
|
||||
const gfxFontStyle* aStyle) {
|
||||
gfxFontFamily* ff = nullptr;
|
||||
|
||||
|
@ -855,7 +855,7 @@ gfxFontFamily* gfxGDIFontList::GetDefaultFontForPlatform(
|
|||
if (status) {
|
||||
ff = FindFamily(NS_ConvertUTF16toUTF8(ncm.lfMessageFont.lfFaceName));
|
||||
if (ff) {
|
||||
return ff;
|
||||
return FontFamily(ff);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -866,7 +866,7 @@ gfxFontFamily* gfxGDIFontList::GetDefaultFontForPlatform(
|
|||
ff = FindFamily(NS_ConvertUTF16toUTF8(logFont.lfFaceName));
|
||||
}
|
||||
|
||||
return ff;
|
||||
return FontFamily(ff);
|
||||
}
|
||||
|
||||
void gfxGDIFontList::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
|
|
|
@ -323,8 +323,7 @@ class gfxGDIFontList : public gfxPlatformFontList {
|
|||
FontListSizes* aSizes) const;
|
||||
|
||||
protected:
|
||||
virtual gfxFontFamily* GetDefaultFontForPlatform(
|
||||
const gfxFontStyle* aStyle) override;
|
||||
FontFamily GetDefaultFontForPlatform(const gfxFontStyle* aStyle) override;
|
||||
|
||||
private:
|
||||
friend class gfxWindowsPlatform;
|
||||
|
|
|
@ -178,7 +178,7 @@ class gfxMacPlatformFontList : public gfxPlatformFontList {
|
|||
InfallibleTArray<mozilla::dom::SystemFontListEntry>* aList);
|
||||
|
||||
protected:
|
||||
gfxFontFamily* GetDefaultFontForPlatform(const gfxFontStyle* aStyle) override;
|
||||
FontFamily GetDefaultFontForPlatform(const gfxFontStyle* aStyle) override;
|
||||
|
||||
private:
|
||||
friend class gfxPlatformMac;
|
||||
|
@ -204,9 +204,10 @@ class gfxMacPlatformFontList : public gfxPlatformFontList {
|
|||
|
||||
// attempt to use platform-specific fallback for the given character
|
||||
// return null if no usable result found
|
||||
gfxFontEntry* PlatformGlobalFontFallback(
|
||||
const uint32_t aCh, Script aRunScript, const gfxFontStyle* aMatchStyle,
|
||||
gfxFontFamily** aMatchedFamily) override;
|
||||
gfxFontEntry* PlatformGlobalFontFallback(const uint32_t aCh,
|
||||
Script aRunScript,
|
||||
const gfxFontStyle* aMatchStyle,
|
||||
FontFamily* aMatchedFamily) override;
|
||||
|
||||
bool UsesSystemFallback() override { return true; }
|
||||
|
||||
|
|
|
@ -1283,7 +1283,7 @@ void gfxMacPlatformFontList::RegisteredFontsChangedNotificationCallback(
|
|||
gfxFontEntry* gfxMacPlatformFontList::PlatformGlobalFontFallback(const uint32_t aCh,
|
||||
Script aRunScript,
|
||||
const gfxFontStyle* aMatchStyle,
|
||||
gfxFontFamily** aMatchedFamily) {
|
||||
FontFamily* aMatchedFamily) {
|
||||
CFStringRef str;
|
||||
UniChar ch[2];
|
||||
CFIndex length = 1;
|
||||
|
@ -1335,7 +1335,7 @@ gfxFontEntry* gfxMacPlatformFontList::PlatformGlobalFontFallback(const uint32_t
|
|||
fontEntry = family->FindFontForStyle(*aMatchStyle);
|
||||
if (fontEntry) {
|
||||
if (fontEntry->HasCharacter(aCh)) {
|
||||
*aMatchedFamily = family;
|
||||
*aMatchedFamily = FontFamily(family);
|
||||
} else {
|
||||
fontEntry = nullptr;
|
||||
cantUseFallbackFont = true;
|
||||
|
@ -1358,14 +1358,14 @@ gfxFontEntry* gfxMacPlatformFontList::PlatformGlobalFontFallback(const uint32_t
|
|||
return fontEntry;
|
||||
}
|
||||
|
||||
gfxFontFamily* gfxMacPlatformFontList::GetDefaultFontForPlatform(const gfxFontStyle* aStyle) {
|
||||
FontFamily gfxMacPlatformFontList::GetDefaultFontForPlatform(const gfxFontStyle* aStyle) {
|
||||
nsAutoreleasePool localPool;
|
||||
|
||||
NSString* defaultFamily = [[NSFont userFontOfSize:aStyle->size] familyName];
|
||||
nsAutoString familyName;
|
||||
|
||||
GetStringForNSString(defaultFamily, familyName);
|
||||
return FindFamily(NS_ConvertUTF16toUTF8(familyName));
|
||||
return FontFamily(FindFamily(NS_ConvertUTF16toUTF8(familyName)));
|
||||
}
|
||||
|
||||
int32_t gfxMacPlatformFontList::AppleWeightToCSSWeight(int32_t aAppleWeight) {
|
||||
|
|
|
@ -355,7 +355,6 @@ nsresult gfxPlatformFontList::InitFontList() {
|
|||
}
|
||||
mFaceNameListsInitialized = false;
|
||||
ClearLangGroupPrefFonts();
|
||||
mReplacementCharFallbackFamily = nullptr;
|
||||
CancelLoader();
|
||||
|
||||
// initialize ranges of characters for which system-wide font search should be
|
||||
|
@ -568,8 +567,12 @@ gfxFontEntry* gfxPlatformFontList::SystemFindFontForChar(
|
|||
// encoding errors: just use cached family from last time U+FFFD was seen.
|
||||
// This helps speed up pages with lots of encoding errors, binary-as-text,
|
||||
// etc.
|
||||
if (aCh == 0xFFFD && mReplacementCharFallbackFamily) {
|
||||
fontEntry = mReplacementCharFallbackFamily->FindFontForStyle(*aStyle);
|
||||
if (aCh == 0xFFFD) {
|
||||
if (!mReplacementCharFallbackFamily.mIsShared &&
|
||||
mReplacementCharFallbackFamily.mUnshared) {
|
||||
fontEntry =
|
||||
mReplacementCharFallbackFamily.mUnshared->FindFontForStyle(*aStyle);
|
||||
}
|
||||
|
||||
// this should never fail, as we must have found U+FFFD in order to set
|
||||
// mReplacementCharFallbackFamily at all, but better play it safe
|
||||
|
@ -582,7 +585,7 @@ gfxFontEntry* gfxPlatformFontList::SystemFindFontForChar(
|
|||
|
||||
// search commonly available fonts
|
||||
bool common = true;
|
||||
gfxFontFamily* fallbackFamily = nullptr;
|
||||
FontFamily fallbackFamily;
|
||||
fontEntry =
|
||||
CommonFontFallback(aCh, aNextCh, aRunScript, aStyle, &fallbackFamily);
|
||||
|
||||
|
@ -613,7 +616,7 @@ gfxFontEntry* gfxPlatformFontList::SystemFindFontForChar(
|
|||
// no match? add to set of non-matching codepoints
|
||||
if (!fontEntry) {
|
||||
mCodepointsWithNoFonts.set(aCh);
|
||||
} else if (aCh == 0xFFFD && fontEntry && fallbackFamily) {
|
||||
} else if (aCh == 0xFFFD && fontEntry) {
|
||||
mReplacementCharFallbackFamily = fallbackFamily;
|
||||
}
|
||||
|
||||
|
@ -638,7 +641,7 @@ gfxFontEntry* gfxPlatformFontList::SystemFindFontForChar(
|
|||
|
||||
gfxFontEntry* gfxPlatformFontList::CommonFontFallback(
|
||||
uint32_t aCh, uint32_t aNextCh, Script aRunScript,
|
||||
const gfxFontStyle* aMatchStyle, gfxFontFamily** aMatchedFamily) {
|
||||
const gfxFontStyle* aMatchStyle, FontFamily* aMatchedFamily) {
|
||||
AutoTArray<const char*, NUM_FALLBACK_FONTS> defaultFallbacks;
|
||||
gfxPlatform::GetPlatform()->GetCommonFallbackFonts(aCh, aNextCh, aRunScript,
|
||||
defaultFallbacks);
|
||||
|
@ -649,7 +652,7 @@ gfxFontEntry* gfxPlatformFontList::CommonFontFallback(
|
|||
if (fallback) {
|
||||
fallback->FindFontForChar(&data);
|
||||
if (data.mBestMatch) {
|
||||
*aMatchedFamily = fallback;
|
||||
*aMatchedFamily = FontFamily(fallback);
|
||||
return data.mBestMatch;
|
||||
}
|
||||
}
|
||||
|
@ -659,7 +662,7 @@ gfxFontEntry* gfxPlatformFontList::CommonFontFallback(
|
|||
|
||||
gfxFontEntry* gfxPlatformFontList::GlobalFontFallback(
|
||||
const uint32_t aCh, Script aRunScript, const gfxFontStyle* aMatchStyle,
|
||||
uint32_t& aCmapCount, gfxFontFamily** aMatchedFamily) {
|
||||
uint32_t& aCmapCount, FontFamily* aMatchedFamily) {
|
||||
bool useCmaps = IsFontFamilyWhitelistActive() ||
|
||||
gfxPlatform::GetPlatform()->UseCmapsDuringSystemFallback();
|
||||
if (!useCmaps) {
|
||||
|
@ -686,7 +689,7 @@ gfxFontEntry* gfxPlatformFontList::GlobalFontFallback(
|
|||
}
|
||||
|
||||
aCmapCount = data.mCmapsTested;
|
||||
*aMatchedFamily = data.mMatchedFamily;
|
||||
*aMatchedFamily = FontFamily(data.mMatchedFamily);
|
||||
|
||||
return data.mBestMatch;
|
||||
}
|
||||
|
@ -995,7 +998,7 @@ void gfxPlatformFontList::AddGenericFonts(
|
|||
if (!prefFonts->IsEmpty()) {
|
||||
aFamilyList.SetCapacity(aFamilyList.Length() + prefFonts->Length());
|
||||
for (auto& f : *prefFonts) {
|
||||
aFamilyList.AppendElement(FamilyAndGeneric(f.get(), aGenericType));
|
||||
aFamilyList.AppendElement(FamilyAndGeneric(f, aGenericType));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1307,16 +1310,16 @@ mozilla::FontFamilyType gfxPlatformFontList::GetDefaultGeneric(
|
|||
return eFamily_serif;
|
||||
}
|
||||
|
||||
gfxFontFamily* gfxPlatformFontList::GetDefaultFont(const gfxFontStyle* aStyle) {
|
||||
gfxFontFamily* family = GetDefaultFontForPlatform(aStyle);
|
||||
if (family) {
|
||||
FontFamily gfxPlatformFontList::GetDefaultFont(const gfxFontStyle* aStyle) {
|
||||
FontFamily family = GetDefaultFontForPlatform(aStyle);
|
||||
if (!family.mIsShared && family.mUnshared) {
|
||||
return family;
|
||||
}
|
||||
// Something has gone wrong and we were unable to retrieve a default font
|
||||
// from the platform. (Likely the whitelist has blocked all potential
|
||||
// default fonts.) As a last resort, we return the first font listed in
|
||||
// mFontFamilies.
|
||||
return mFontFamilies.Iter().Data();
|
||||
return FontFamily(mFontFamilies.Iter().Data());
|
||||
}
|
||||
|
||||
void gfxPlatformFontList::GetFontFamilyNames(
|
||||
|
|
|
@ -100,7 +100,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
|
|||
// For font family lists loaded from user preferences (prefs such as
|
||||
// font.name-list.<generic>.<langGroup>) that map CSS generics to
|
||||
// platform-specific font families.
|
||||
typedef nsTArray<RefPtr<gfxFontFamily>> PrefFontList;
|
||||
typedef nsTArray<FontFamily> PrefFontList;
|
||||
|
||||
static gfxPlatformFontList* PlatformFontList() { return sPlatformFontList; }
|
||||
|
||||
|
@ -184,7 +184,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
|
|||
// pure virtual functions, to be provided by concrete subclasses
|
||||
|
||||
// get the system default font family
|
||||
gfxFontFamily* GetDefaultFont(const gfxFontStyle* aStyle);
|
||||
FontFamily GetDefaultFont(const gfxFontStyle* aStyle);
|
||||
|
||||
/**
|
||||
* Look up a font by name on the host platform.
|
||||
|
@ -396,7 +396,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
|
|||
gfxFloat aDevToCssSize = 1.0) {
|
||||
AutoTArray<FamilyAndGeneric, 1> families;
|
||||
return FindAndAddFamilies(aFamily, &families, aFlags, aStyle, aDevToCssSize)
|
||||
? families[0].mFamily
|
||||
? families[0].mFamily.mUnshared
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
|
@ -416,20 +416,20 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
|
|||
gfxFontEntry* CommonFontFallback(uint32_t aCh, uint32_t aNextCh,
|
||||
Script aRunScript,
|
||||
const gfxFontStyle* aMatchStyle,
|
||||
gfxFontFamily** aMatchedFamily);
|
||||
FontFamily* aMatchedFamily);
|
||||
|
||||
// Search fonts system-wide for a given character, null if not found.
|
||||
gfxFontEntry* GlobalFontFallback(const uint32_t aCh, Script aRunScript,
|
||||
const gfxFontStyle* aMatchStyle,
|
||||
uint32_t& aCmapCount,
|
||||
gfxFontFamily** aMatchedFamily);
|
||||
FontFamily* aMatchedFamily);
|
||||
|
||||
// Platform-specific implementation of global font fallback, if any;
|
||||
// this may return nullptr in which case the default cmap-based fallback
|
||||
// will be performed.
|
||||
virtual gfxFontEntry* PlatformGlobalFontFallback(
|
||||
const uint32_t aCh, Script aRunScript, const gfxFontStyle* aMatchStyle,
|
||||
gfxFontFamily** aMatchedFamily) {
|
||||
FontFamily* aMatchedFamily) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -514,8 +514,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
|
|||
const FontEntryTable& aTable, mozilla::MallocSizeOf aMallocSizeOf);
|
||||
|
||||
// Platform-specific helper for GetDefaultFont(...).
|
||||
virtual gfxFontFamily* GetDefaultFontForPlatform(
|
||||
const gfxFontStyle* aStyle) = 0;
|
||||
virtual FontFamily GetDefaultFontForPlatform(const gfxFontStyle* aStyle) = 0;
|
||||
|
||||
// Protects mFontFamilies.
|
||||
mozilla::Mutex mFontFamiliesMutex;
|
||||
|
@ -567,7 +566,7 @@ class gfxPlatformFontList : public gfxFontInfoLoader {
|
|||
|
||||
// the family to use for U+FFFD fallback, to avoid expensive search every time
|
||||
// on pages with lots of problems
|
||||
RefPtr<gfxFontFamily> mReplacementCharFallbackFamily;
|
||||
FontFamily mReplacementCharFallbackFamily;
|
||||
|
||||
// Sorted array of lowercased family names; use ContainsSorted to test
|
||||
nsTArray<nsCString> mBadUnderlineFamilyNames;
|
||||
|
|
|
@ -1734,7 +1734,7 @@ void gfxFontGroup::BuildFontList() {
|
|||
|
||||
// build the fontlist from the specified families
|
||||
for (const auto& f : fonts) {
|
||||
AddFamilyToFontList(f.mFamily, f.mGeneric);
|
||||
AddFamilyToFontList(f.mFamily.mUnshared, f.mGeneric);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1897,12 +1897,12 @@ gfxFont* gfxFontGroup::GetDefaultFont() {
|
|||
}
|
||||
|
||||
gfxPlatformFontList* pfl = gfxPlatformFontList::PlatformFontList();
|
||||
gfxFontFamily* defaultFamily = pfl->GetDefaultFont(&mStyle);
|
||||
NS_ASSERTION(defaultFamily,
|
||||
FontFamily defaultFamily = pfl->GetDefaultFont(&mStyle);
|
||||
NS_ASSERTION(!defaultFamily.mIsShared && defaultFamily.mUnshared,
|
||||
"invalid default font returned by GetDefaultFont");
|
||||
|
||||
if (defaultFamily) {
|
||||
gfxFontEntry* fe = defaultFamily->FindFontForStyle(mStyle, true);
|
||||
if (defaultFamily.mUnshared) {
|
||||
gfxFontEntry* fe = defaultFamily.mUnshared->FindFontForStyle(mStyle, true);
|
||||
if (fe) {
|
||||
mDefaultFont = fe->FindOrMakeFont(&mStyle);
|
||||
}
|
||||
|
@ -3186,8 +3186,8 @@ gfxFont* gfxFontGroup::WhichPrefFontSupportsChar(uint32_t aCh,
|
|||
numPrefs = families->Length();
|
||||
for (j = 0; j < numPrefs; j++) {
|
||||
// look up the appropriate face
|
||||
gfxFontFamily* family = (*families)[j];
|
||||
if (!family) {
|
||||
FontFamily family = (*families)[j];
|
||||
if (family.IsNull()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -3199,7 +3199,7 @@ gfxFont* gfxFontGroup::WhichPrefFontSupportsChar(uint32_t aCh,
|
|||
return mLastPrefFont;
|
||||
}
|
||||
|
||||
gfxFontEntry* fe = family->FindFontForStyle(mStyle);
|
||||
gfxFontEntry* fe = family.mUnshared->FindFontForStyle(mStyle);
|
||||
if (!fe) {
|
||||
continue;
|
||||
}
|
||||
|
@ -3219,7 +3219,7 @@ gfxFont* gfxFontGroup::WhichPrefFontSupportsChar(uint32_t aCh,
|
|||
|
||||
// If the char was not available, see if we can fall back to an
|
||||
// alternative face in the same family.
|
||||
gfxFont* prefFont = FindFallbackFaceForChar(family, aCh);
|
||||
gfxFont* prefFont = FindFallbackFaceForChar(family.mUnshared, aCh);
|
||||
if (prefFont) {
|
||||
mLastPrefFamily = family;
|
||||
mLastPrefFont = prefFont;
|
||||
|
|
|
@ -1186,7 +1186,7 @@ class gfxFontGroup final : public gfxTextRunFactory {
|
|||
RefPtr<gfxTextRun> mCachedEllipsisTextRun;
|
||||
|
||||
// cache the most recent pref font to avoid general pref font lookup
|
||||
RefPtr<gfxFontFamily> mLastPrefFamily;
|
||||
FontFamily mLastPrefFamily;
|
||||
RefPtr<gfxFont> mLastPrefFont;
|
||||
eFontPrefLang mLastPrefLang; // lang group for last pref font
|
||||
eFontPrefLang mPageLang;
|
||||
|
|
Загрузка…
Ссылка в новой задаче