mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1031202 - Factor out gfxMixedFontFamily lookup/creation into a helper function. r=jdaggett
This commit is contained in:
parent
c811f2428c
commit
f66a3c2e9d
@ -5180,7 +5180,7 @@ gfxFontGroup::FindPlatformFont(const nsAString& aName,
|
||||
// If the fontSet matches the family, but the font has not yet finished
|
||||
// loading (nor has its load timeout fired), the fontGroup should wait
|
||||
// for the download, and not actually draw its text yet.
|
||||
family = mUserFontSet->GetFamily(aName);
|
||||
family = mUserFontSet->LookupFamily(aName);
|
||||
if (family) {
|
||||
bool waitForUserFont = false;
|
||||
fe = mUserFontSet->FindFontEntry(family, mStyle,
|
||||
|
@ -794,7 +794,7 @@ FindFontPatterns(gfxUserFontSet *mUserFontSet,
|
||||
style.stretch = aStretch;
|
||||
|
||||
gfxUserFcFontEntry *fontEntry = nullptr;
|
||||
gfxFontFamily *family = mUserFontSet->GetFamily(utf16Family);
|
||||
gfxFontFamily *family = mUserFontSet->LookupFamily(utf16Family);
|
||||
if (family) {
|
||||
fontEntry = static_cast<gfxUserFcFontEntry*>
|
||||
(mUserFontSet->FindFontEntry(family, style, needsBold,
|
||||
|
@ -595,18 +595,9 @@ gfxUserFontSet::AddFontFace(const nsAString& aFamilyName,
|
||||
MOZ_ASSERT(aWeight != 0,
|
||||
"aWeight must not be 0; use NS_FONT_WEIGHT_NORMAL instead");
|
||||
|
||||
nsAutoString key(aFamilyName);
|
||||
ToLowerCase(key);
|
||||
|
||||
bool found;
|
||||
|
||||
// stretch, italic/oblique ==> zero implies normal
|
||||
|
||||
gfxMixedFontFamily *family = mFontFamilies.GetWeak(key, &found);
|
||||
if (!family) {
|
||||
family = new gfxMixedFontFamily(aFamilyName);
|
||||
mFontFamilies.Put(key, family);
|
||||
}
|
||||
gfxMixedFontFamily* family = GetFamily(aFamilyName);
|
||||
|
||||
// If there's already a proxy in the family whose descriptors all match,
|
||||
// we can just move it to the end of the list instead of adding a new
|
||||
@ -663,17 +654,7 @@ void
|
||||
gfxUserFontSet::AddFontFace(const nsAString& aFamilyName,
|
||||
gfxFontEntry *aFontEntry)
|
||||
{
|
||||
nsAutoString key(aFamilyName);
|
||||
ToLowerCase(key);
|
||||
|
||||
bool found;
|
||||
|
||||
gfxMixedFontFamily *family = mFontFamilies.GetWeak(key, &found);
|
||||
if (!family) {
|
||||
family = new gfxMixedFontFamily(aFamilyName);
|
||||
mFontFamilies.Put(key, family);
|
||||
}
|
||||
|
||||
gfxMixedFontFamily* family = GetFamily(aFamilyName);
|
||||
family->AddFontEntry(aFontEntry);
|
||||
}
|
||||
|
||||
@ -787,8 +768,8 @@ gfxUserFontSet::RebuildLocalRules()
|
||||
}
|
||||
}
|
||||
|
||||
gfxFontFamily*
|
||||
gfxUserFontSet::GetFamily(const nsAString& aFamilyName) const
|
||||
gfxMixedFontFamily*
|
||||
gfxUserFontSet::LookupFamily(const nsAString& aFamilyName) const
|
||||
{
|
||||
nsAutoString key(aFamilyName);
|
||||
ToLowerCase(key);
|
||||
@ -796,6 +777,20 @@ gfxUserFontSet::GetFamily(const nsAString& aFamilyName) const
|
||||
return mFontFamilies.GetWeak(key);
|
||||
}
|
||||
|
||||
gfxMixedFontFamily*
|
||||
gfxUserFontSet::GetFamily(const nsAString& aFamilyName)
|
||||
{
|
||||
nsAutoString key(aFamilyName);
|
||||
ToLowerCase(key);
|
||||
|
||||
gfxMixedFontFamily* family = mFontFamilies.GetWeak(key);
|
||||
if (!family) {
|
||||
family = new gfxMixedFontFamily(aFamilyName);
|
||||
mFontFamilies.Put(key, family);
|
||||
}
|
||||
return family;
|
||||
}
|
||||
|
||||
struct FindFamilyCallbackData {
|
||||
gfxFontEntry *mFontEntry;
|
||||
gfxFontFamily *mFamily;
|
||||
|
@ -188,13 +188,15 @@ public:
|
||||
// Whether there is a face with this family name
|
||||
bool HasFamily(const nsAString& aFamilyName) const
|
||||
{
|
||||
return GetFamily(aFamilyName) != nullptr;
|
||||
return LookupFamily(aFamilyName) != nullptr;
|
||||
}
|
||||
|
||||
gfxFontFamily *GetFamily(const nsAString& aName) const;
|
||||
// Look up and return the gfxMixedFontFamily in mFontFamilies with
|
||||
// the given name
|
||||
gfxMixedFontFamily* LookupFamily(const nsAString& aName) const;
|
||||
|
||||
// Lookup a font entry for a given style, returns null if not loaded.
|
||||
// aFamily must be a family returned by our GetFamily method.
|
||||
// aFamily must be a family returned by our LookupFamily method.
|
||||
gfxFontEntry *FindFontEntry(gfxFontFamily *aFamily,
|
||||
const gfxFontStyle& aFontStyle,
|
||||
bool& aNeedsBold,
|
||||
@ -430,6 +432,10 @@ protected:
|
||||
// helper method for performing the actual userfont set rebuild
|
||||
virtual void DoRebuildUserFontSet() = 0;
|
||||
|
||||
// creates a new gfxMixedFontFamily in mFontFamilies, or returns an existing
|
||||
// family if there is one
|
||||
gfxMixedFontFamily* GetFamily(const nsAString& aFamilyName);
|
||||
|
||||
// font families defined by @font-face rules
|
||||
nsRefPtrHashtable<nsStringHashKey, gfxMixedFontFamily> mFontFamilies;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user