mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 12:50:09 +00:00
Backed out changeset 473b37f1e3e2 (bug 1693541) for causing gfx crashes. a=backout
This commit is contained in:
parent
c24ecdc6f5
commit
464bef8dad
@ -260,73 +260,70 @@ Maybe<wr::FontInstanceKey> WebRenderBridgeChild::GetFontKeyForScaledFont(
|
||||
MOZ_ASSERT(aScaledFont);
|
||||
MOZ_ASSERT(aScaledFont->CanSerialize());
|
||||
|
||||
return mFontInstanceKeys.WithEntryHandle(
|
||||
aScaledFont, [&](auto&& entry) -> Maybe<wr::FontInstanceKey> {
|
||||
if (!entry) {
|
||||
Maybe<wr::IpcResourceUpdateQueue> resources =
|
||||
aResources ? Nothing() : Some(wr::IpcResourceUpdateQueue(this));
|
||||
aResources = resources.ptrOr(aResources);
|
||||
wr::FontInstanceKey instanceKey = {wr::IdNamespace{0}, 0};
|
||||
if (mFontInstanceKeys.Get(aScaledFont, &instanceKey)) {
|
||||
return Some(instanceKey);
|
||||
}
|
||||
|
||||
Maybe<wr::FontKey> fontKey = GetFontKeyForUnscaledFont(
|
||||
aScaledFont->GetUnscaledFont(), aResources);
|
||||
if (fontKey.isNothing()) {
|
||||
return Nothing();
|
||||
}
|
||||
Maybe<wr::IpcResourceUpdateQueue> resources =
|
||||
aResources ? Nothing() : Some(wr::IpcResourceUpdateQueue(this));
|
||||
aResources = resources.ptrOr(aResources);
|
||||
|
||||
wr::FontInstanceKey instanceKey = GetNextFontInstanceKey();
|
||||
Maybe<wr::FontKey> fontKey =
|
||||
GetFontKeyForUnscaledFont(aScaledFont->GetUnscaledFont(), aResources);
|
||||
if (fontKey.isNothing()) {
|
||||
return Nothing();
|
||||
}
|
||||
|
||||
Maybe<wr::FontInstanceOptions> options;
|
||||
Maybe<wr::FontInstancePlatformOptions> platformOptions;
|
||||
std::vector<FontVariation> variations;
|
||||
aScaledFont->GetWRFontInstanceOptions(&options, &platformOptions,
|
||||
&variations);
|
||||
instanceKey = GetNextFontInstanceKey();
|
||||
|
||||
aResources->AddFontInstance(
|
||||
instanceKey, fontKey.value(), aScaledFont->GetSize(),
|
||||
options.ptrOr(nullptr), platformOptions.ptrOr(nullptr),
|
||||
Range<const FontVariation>(variations.data(), variations.size()));
|
||||
if (resources.isSome()) {
|
||||
UpdateResources(resources.ref());
|
||||
}
|
||||
Maybe<wr::FontInstanceOptions> options;
|
||||
Maybe<wr::FontInstancePlatformOptions> platformOptions;
|
||||
std::vector<FontVariation> variations;
|
||||
aScaledFont->GetWRFontInstanceOptions(&options, &platformOptions,
|
||||
&variations);
|
||||
|
||||
entry.Insert(instanceKey);
|
||||
}
|
||||
aResources->AddFontInstance(
|
||||
instanceKey, fontKey.value(), aScaledFont->GetSize(),
|
||||
options.ptrOr(nullptr), platformOptions.ptrOr(nullptr),
|
||||
Range<const FontVariation>(variations.data(), variations.size()));
|
||||
if (resources.isSome()) {
|
||||
UpdateResources(resources.ref());
|
||||
}
|
||||
|
||||
return Some(*entry);
|
||||
});
|
||||
mFontInstanceKeys.InsertOrUpdate(aScaledFont, instanceKey);
|
||||
|
||||
return Some(instanceKey);
|
||||
}
|
||||
|
||||
Maybe<wr::FontKey> WebRenderBridgeChild::GetFontKeyForUnscaledFont(
|
||||
gfx::UnscaledFont* aUnscaled, wr::IpcResourceUpdateQueue* aResources) {
|
||||
MOZ_ASSERT(!mDestroyed);
|
||||
|
||||
return mFontKeys.WithEntryHandle(
|
||||
aUnscaled, [&](auto&& entry) -> Maybe<wr::FontKey> {
|
||||
if (!entry) {
|
||||
Maybe<wr::IpcResourceUpdateQueue> resources =
|
||||
aResources ? Nothing() : Some(wr::IpcResourceUpdateQueue(this));
|
||||
wr::FontKey fontKey = {wr::IdNamespace{0}, 0};
|
||||
if (!mFontKeys.Get(aUnscaled, &fontKey)) {
|
||||
Maybe<wr::IpcResourceUpdateQueue> resources =
|
||||
aResources ? Nothing() : Some(wr::IpcResourceUpdateQueue(this));
|
||||
|
||||
wr::FontKey fontKey = {wr::IdNamespace{0}, 0};
|
||||
FontFileDataSink sink = {&fontKey, this, resources.ptrOr(aResources)};
|
||||
// First try to retrieve a descriptor for the font, as this is much
|
||||
// cheaper to send over IPC than the full raw font data. If this is
|
||||
// not possible, then and only then fall back to getting the raw font
|
||||
// file data. If that fails, then the only thing left to do is signal
|
||||
// failure by returning a null font key.
|
||||
if (!aUnscaled->GetFontDescriptor(WriteFontDescriptor, &sink) &&
|
||||
!aUnscaled->GetFontFileData(WriteFontFileData, &sink)) {
|
||||
return Nothing();
|
||||
}
|
||||
FontFileDataSink sink = {&fontKey, this, resources.ptrOr(aResources)};
|
||||
// First try to retrieve a descriptor for the font, as this is much cheaper
|
||||
// to send over IPC than the full raw font data. If this is not possible,
|
||||
// then and only then fall back to getting the raw font file data. If that
|
||||
// fails, then the only thing left to do is signal failure by returning a
|
||||
// null font key.
|
||||
if (!aUnscaled->GetFontDescriptor(WriteFontDescriptor, &sink) &&
|
||||
!aUnscaled->GetFontFileData(WriteFontFileData, &sink)) {
|
||||
return Nothing();
|
||||
}
|
||||
|
||||
if (resources.isSome()) {
|
||||
UpdateResources(resources.ref());
|
||||
}
|
||||
if (resources.isSome()) {
|
||||
UpdateResources(resources.ref());
|
||||
}
|
||||
|
||||
entry.Insert(fontKey);
|
||||
}
|
||||
mFontKeys.InsertOrUpdate(aUnscaled, fontKey);
|
||||
}
|
||||
|
||||
return Some(*entry);
|
||||
});
|
||||
return Some(fontKey);
|
||||
}
|
||||
|
||||
void WebRenderBridgeChild::RemoveExpiredFontKeys(
|
||||
|
@ -472,8 +472,14 @@ int32_t gfxDWriteFont::GetGlyphWidth(uint16_t aGID) {
|
||||
mGlyphWidths = MakeUnique<nsDataHashtable<nsUint32HashKey, int32_t>>(128);
|
||||
}
|
||||
|
||||
return mGlyphWidths->LookupOrInsertWith(
|
||||
aGID, [&] { return NS_lround(MeasureGlyphWidth(aGID) * 65536.0); });
|
||||
int32_t width = -1;
|
||||
if (mGlyphWidths->Get(aGID, &width)) {
|
||||
return width;
|
||||
}
|
||||
|
||||
width = NS_lround(MeasureGlyphWidth(aGID) * 65536.0);
|
||||
mGlyphWidths->InsertOrUpdate(aGID, width);
|
||||
return width;
|
||||
}
|
||||
|
||||
bool gfxDWriteFont::GetForceGDIClassic() const {
|
||||
|
@ -636,19 +636,20 @@ void gfxFT2FontList::CollectInitData(const FontListEntry& aFLE,
|
||||
StandardFile aStdFile) {
|
||||
nsAutoCString key(aFLE.familyName());
|
||||
BuildKeyNameFromFontName(key);
|
||||
mFaceInitData
|
||||
.LookupOrInsertWith(
|
||||
key,
|
||||
[&] {
|
||||
mFamilyInitData.AppendElement(
|
||||
fontlist::Family::InitData{key, aFLE.familyName()});
|
||||
return MakeUnique<nsTArray<fontlist::Face::InitData>>();
|
||||
})
|
||||
->AppendElement(fontlist::Face::InitData{
|
||||
aFLE.filepath(), aFLE.index(), false,
|
||||
WeightRange::FromScalar(aFLE.weightRange()),
|
||||
StretchRange::FromScalar(aFLE.stretchRange()),
|
||||
SlantStyleRange::FromScalar(aFLE.styleRange())});
|
||||
auto faceList = mFaceInitData.Get(key);
|
||||
if (!faceList) {
|
||||
faceList = mFaceInitData
|
||||
.InsertOrUpdate(
|
||||
key, MakeUnique<nsTArray<fontlist::Face::InitData>>())
|
||||
.get();
|
||||
mFamilyInitData.AppendElement(
|
||||
fontlist::Family::InitData{key, aFLE.familyName()});
|
||||
}
|
||||
faceList->AppendElement(
|
||||
fontlist::Face::InitData{aFLE.filepath(), aFLE.index(), false,
|
||||
WeightRange::FromScalar(aFLE.weightRange()),
|
||||
StretchRange::FromScalar(aFLE.stretchRange()),
|
||||
SlantStyleRange::FromScalar(aFLE.styleRange())});
|
||||
nsAutoCString psname(aPSName), fullname(aFullName);
|
||||
if (!psname.IsEmpty()) {
|
||||
ToLowerCase(psname);
|
||||
@ -1283,17 +1284,17 @@ void gfxFT2FontList::AddFaceToList(const nsCString& aEntryName, uint32_t aIndex,
|
||||
visibility);
|
||||
CollectInitData(fle, psname, fullname, aStdFile);
|
||||
} else {
|
||||
RefPtr<gfxFontFamily> family =
|
||||
mFontFamilies.LookupOrInsertWith(familyKey, [&] {
|
||||
auto family = MakeRefPtr<FT2FontFamily>(familyName, visibility);
|
||||
if (mSkipSpaceLookupCheckFamilies.Contains(familyKey)) {
|
||||
family->SetSkipSpaceFeatureCheck(true);
|
||||
}
|
||||
if (mBadUnderlineFamilyNames.ContainsSorted(familyKey)) {
|
||||
family->SetBadUnderlineFamily();
|
||||
}
|
||||
return family;
|
||||
});
|
||||
RefPtr<gfxFontFamily> family = mFontFamilies.GetWeak(familyKey);
|
||||
if (!family) {
|
||||
family = new FT2FontFamily(familyName, visibility);
|
||||
mFontFamilies.InsertOrUpdate(familyKey, RefPtr{family});
|
||||
if (mSkipSpaceLookupCheckFamilies.Contains(familyKey)) {
|
||||
family->SetSkipSpaceFeatureCheck(true);
|
||||
}
|
||||
if (mBadUnderlineFamilyNames.ContainsSorted(familyKey)) {
|
||||
family->SetBadUnderlineFamily();
|
||||
}
|
||||
}
|
||||
family->AddFontEntry(fe);
|
||||
fe->CheckForBrokenFont(family);
|
||||
}
|
||||
@ -1592,17 +1593,17 @@ void gfxFT2FontList::AppendFaceFromFontListEntry(const FontListEntry& aFLE,
|
||||
nsAutoCString key(aFLE.familyName());
|
||||
BuildKeyNameFromFontName(key);
|
||||
fe->mStandardFace = (aStdFile == kStandard);
|
||||
RefPtr<gfxFontFamily> family = mFontFamilies.LookupOrInsertWith(key, [&] {
|
||||
auto family =
|
||||
MakeRefPtr<FT2FontFamily>(aFLE.familyName(), aFLE.visibility());
|
||||
RefPtr<gfxFontFamily> family = mFontFamilies.GetWeak(key);
|
||||
if (!family) {
|
||||
family = new FT2FontFamily(aFLE.familyName(), aFLE.visibility());
|
||||
mFontFamilies.InsertOrUpdate(key, RefPtr{family});
|
||||
if (mSkipSpaceLookupCheckFamilies.Contains(key)) {
|
||||
family->SetSkipSpaceFeatureCheck(true);
|
||||
}
|
||||
if (mBadUnderlineFamilyNames.ContainsSorted(key)) {
|
||||
family->SetBadUnderlineFamily();
|
||||
}
|
||||
return family;
|
||||
});
|
||||
}
|
||||
family->AddFontEntry(fe);
|
||||
|
||||
fe->CheckForBrokenFont(family);
|
||||
|
@ -1337,18 +1337,14 @@ void gfxFcPlatformFontList::AddPatternToFontList(
|
||||
nsAutoCString keyName(aFamilyName);
|
||||
ToLowerCase(keyName);
|
||||
|
||||
aFontFamily = static_cast<gfxFontconfigFontFamily*>(
|
||||
mFontFamilies
|
||||
.LookupOrInsertWith(keyName,
|
||||
[&] {
|
||||
FontVisibility visibility =
|
||||
aAppFonts
|
||||
? FontVisibility::Base
|
||||
: GetVisibilityForFamily(keyName);
|
||||
return MakeRefPtr<gfxFontconfigFontFamily>(
|
||||
aFamilyName, visibility);
|
||||
})
|
||||
.get());
|
||||
aFontFamily =
|
||||
static_cast<gfxFontconfigFontFamily*>(mFontFamilies.GetWeak(keyName));
|
||||
if (!aFontFamily) {
|
||||
FontVisibility visibility =
|
||||
aAppFonts ? FontVisibility::Base : GetVisibilityForFamily(keyName);
|
||||
aFontFamily = new gfxFontconfigFontFamily(aFamilyName, visibility);
|
||||
mFontFamilies.InsertOrUpdate(keyName, RefPtr{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).
|
||||
@ -1975,41 +1971,45 @@ bool gfxFcPlatformFontList::FindAndAddFamilies(
|
||||
|
||||
// Because the FcConfigSubstitute call is quite expensive, we cache the
|
||||
// actual font families found via this process. So check the cache first:
|
||||
const auto& cachedFamilies =
|
||||
mFcSubstituteCache.LookupOrInsertWith(familyName, [&] {
|
||||
// It wasn't in the cache, so we need to ask fontconfig...
|
||||
const FcChar8* kSentinelName = ToFcChar8Ptr("-moz-sentinel");
|
||||
FcChar8* sentinelFirstFamily = nullptr;
|
||||
RefPtr<FcPattern> sentinelSubst = dont_AddRef(FcPatternCreate());
|
||||
FcPatternAddString(sentinelSubst, FC_FAMILY, kSentinelName);
|
||||
FcConfigSubstitute(nullptr, sentinelSubst, FcMatchPattern);
|
||||
FcPatternGetString(sentinelSubst, FC_FAMILY, 0, &sentinelFirstFamily);
|
||||
if (auto* cachedFamilies = mFcSubstituteCache.GetValue(familyName)) {
|
||||
if (cachedFamilies->IsEmpty()) {
|
||||
return false;
|
||||
}
|
||||
aOutput->AppendElements(*cachedFamilies);
|
||||
return true;
|
||||
}
|
||||
|
||||
// substitutions for font, -moz-sentinel pattern
|
||||
RefPtr<FcPattern> fontWithSentinel = dont_AddRef(FcPatternCreate());
|
||||
FcPatternAddString(fontWithSentinel, FC_FAMILY,
|
||||
ToFcChar8Ptr(familyName.get()));
|
||||
FcPatternAddString(fontWithSentinel, FC_FAMILY, kSentinelName);
|
||||
FcConfigSubstitute(nullptr, fontWithSentinel, FcMatchPattern);
|
||||
// It wasn't in the cache, so we need to ask fontconfig...
|
||||
const FcChar8* kSentinelName = ToFcChar8Ptr("-moz-sentinel");
|
||||
FcChar8* sentinelFirstFamily = nullptr;
|
||||
RefPtr<FcPattern> sentinelSubst = dont_AddRef(FcPatternCreate());
|
||||
FcPatternAddString(sentinelSubst, FC_FAMILY, kSentinelName);
|
||||
FcConfigSubstitute(nullptr, sentinelSubst, FcMatchPattern);
|
||||
FcPatternGetString(sentinelSubst, FC_FAMILY, 0, &sentinelFirstFamily);
|
||||
|
||||
// Add all font family matches until reaching the sentinel.
|
||||
nsTArray<FamilyAndGeneric> cachedFamilies;
|
||||
FcChar8* substName = nullptr;
|
||||
for (int i = 0; FcPatternGetString(fontWithSentinel, FC_FAMILY, i,
|
||||
&substName) == FcResultMatch;
|
||||
i++) {
|
||||
if (sentinelFirstFamily &&
|
||||
FcStrCmp(substName, sentinelFirstFamily) == 0) {
|
||||
break;
|
||||
}
|
||||
gfxPlatformFontList::FindAndAddFamilies(
|
||||
aGeneric, nsDependentCString(ToCharPtr(substName)),
|
||||
&cachedFamilies, aFlags, aStyle, aLanguage);
|
||||
}
|
||||
// substitutions for font, -moz-sentinel pattern
|
||||
RefPtr<FcPattern> fontWithSentinel = dont_AddRef(FcPatternCreate());
|
||||
FcPatternAddString(fontWithSentinel, FC_FAMILY,
|
||||
ToFcChar8Ptr(familyName.get()));
|
||||
FcPatternAddString(fontWithSentinel, FC_FAMILY, kSentinelName);
|
||||
FcConfigSubstitute(nullptr, fontWithSentinel, FcMatchPattern);
|
||||
|
||||
// Cache the resulting list, so we don't have to do this again.
|
||||
return cachedFamilies;
|
||||
});
|
||||
// Add all font family matches until reaching the sentinel.
|
||||
AutoTArray<FamilyAndGeneric, 10> cachedFamilies;
|
||||
FcChar8* substName = nullptr;
|
||||
for (int i = 0; FcPatternGetString(fontWithSentinel, FC_FAMILY, i,
|
||||
&substName) == FcResultMatch;
|
||||
i++) {
|
||||
if (sentinelFirstFamily && FcStrCmp(substName, sentinelFirstFamily) == 0) {
|
||||
break;
|
||||
}
|
||||
gfxPlatformFontList::FindAndAddFamilies(
|
||||
aGeneric, nsDependentCString(ToCharPtr(substName)), &cachedFamilies,
|
||||
aFlags, aStyle, aLanguage);
|
||||
}
|
||||
|
||||
// Cache the resulting list, so we don't have to do this again.
|
||||
mFcSubstituteCache.InsertOrUpdate(familyName, cachedFamilies);
|
||||
|
||||
if (cachedFamilies.IsEmpty()) {
|
||||
return false;
|
||||
|
@ -361,7 +361,7 @@ class gfxFcPlatformFontList final : public gfxPlatformFontList {
|
||||
// font list is rebuilt (e.g. due to a fontconfig configuration change),
|
||||
// these pointers will be invalidated. InitFontList() flushes the cache
|
||||
// in this case.
|
||||
nsDataHashtable<nsCStringHashKey, nsTArray<FamilyAndGeneric>>
|
||||
nsDataHashtable<nsCStringHashKey, CopyableTArray<FamilyAndGeneric>>
|
||||
mFcSubstituteCache;
|
||||
|
||||
nsCOMPtr<nsITimer> mCheckFontUpdatesTimer;
|
||||
|
@ -855,44 +855,52 @@ bool gfxFontEntry::SupportsOpenTypeFeature(Script aScript,
|
||||
"need to bump the size of the feature shift");
|
||||
|
||||
uint32_t scriptFeature = SCRIPT_FEATURE(aScript, aFeatureTag);
|
||||
return mSupportedFeatures->LookupOrInsertWith(scriptFeature, [&] {
|
||||
bool result = false;
|
||||
hb_face_t* face = GetHBFace();
|
||||
bool result;
|
||||
if (mSupportedFeatures->Get(scriptFeature, &result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (hb_ot_layout_has_substitution(face)) {
|
||||
hb_script_t hbScript =
|
||||
gfxHarfBuzzShaper::GetHBScriptUsedForShaping(aScript);
|
||||
result = false;
|
||||
|
||||
// Get the OpenType tag(s) that match this script code
|
||||
unsigned int scriptCount = 4;
|
||||
hb_tag_t scriptTags[4];
|
||||
hb_ot_tags_from_script_and_language(hbScript, HB_LANGUAGE_INVALID,
|
||||
&scriptCount, scriptTags, nullptr,
|
||||
nullptr);
|
||||
hb_face_t* face = GetHBFace();
|
||||
|
||||
// Append DEFAULT to the returned tags, if room
|
||||
if (scriptCount < 4) {
|
||||
scriptTags[scriptCount++] = HB_OT_TAG_DEFAULT_SCRIPT;
|
||||
}
|
||||
if (hb_ot_layout_has_substitution(face)) {
|
||||
hb_script_t hbScript =
|
||||
gfxHarfBuzzShaper::GetHBScriptUsedForShaping(aScript);
|
||||
|
||||
// Now check for 'smcp' under the first of those scripts that is present
|
||||
const hb_tag_t kGSUB = HB_TAG('G', 'S', 'U', 'B');
|
||||
result = std::any_of(scriptTags, scriptTags + scriptCount,
|
||||
[&](const hb_tag_t& scriptTag) {
|
||||
unsigned int scriptIndex;
|
||||
return hb_ot_layout_table_find_script(
|
||||
face, kGSUB, scriptTag, &scriptIndex) &&
|
||||
hb_ot_layout_language_find_feature(
|
||||
face, kGSUB, scriptIndex,
|
||||
HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX,
|
||||
aFeatureTag, nullptr);
|
||||
});
|
||||
// Get the OpenType tag(s) that match this script code
|
||||
unsigned int scriptCount = 4;
|
||||
hb_tag_t scriptTags[4];
|
||||
hb_ot_tags_from_script_and_language(hbScript, HB_LANGUAGE_INVALID,
|
||||
&scriptCount, scriptTags, nullptr,
|
||||
nullptr);
|
||||
|
||||
// Append DEFAULT to the returned tags, if room
|
||||
if (scriptCount < 4) {
|
||||
scriptTags[scriptCount++] = HB_OT_TAG_DEFAULT_SCRIPT;
|
||||
}
|
||||
|
||||
hb_face_destroy(face);
|
||||
// Now check for 'smcp' under the first of those scripts that is present
|
||||
const hb_tag_t kGSUB = HB_TAG('G', 'S', 'U', 'B');
|
||||
for (unsigned int i = 0; i < scriptCount; i++) {
|
||||
unsigned int scriptIndex;
|
||||
if (hb_ot_layout_table_find_script(face, kGSUB, scriptTags[i],
|
||||
&scriptIndex)) {
|
||||
if (hb_ot_layout_language_find_feature(
|
||||
face, kGSUB, scriptIndex, HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX,
|
||||
aFeatureTag, nullptr)) {
|
||||
result = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
hb_face_destroy(face);
|
||||
|
||||
mSupportedFeatures->InsertOrUpdate(scriptFeature, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const hb_set_t* gfxFontEntry::InputsForOpenTypeFeature(Script aScript,
|
||||
|
@ -416,21 +416,24 @@ int32_t gfxGDIFont::GetGlyphWidth(uint16_t aGID) {
|
||||
mGlyphWidths = MakeUnique<nsDataHashtable<nsUint32HashKey, int32_t>>(128);
|
||||
}
|
||||
|
||||
return mGlyphWidths->WithEntryHandle(aGID, [&](auto&& entry) {
|
||||
if (!entry) {
|
||||
DCForMetrics dc;
|
||||
AutoSelectFont fs(dc, GetHFONT());
|
||||
int32_t width;
|
||||
if (mGlyphWidths->Get(aGID, &width)) {
|
||||
return width;
|
||||
}
|
||||
|
||||
int devWidth;
|
||||
if (!GetCharWidthI(dc, aGID, 1, nullptr, &devWidth)) {
|
||||
return -1;
|
||||
}
|
||||
// clamp value to range [0..0x7fff], and convert to 16.16 fixed-point
|
||||
devWidth = std::min(std::max(0, devWidth), 0x7fff);
|
||||
entry.Insert(devWidth << 16);
|
||||
}
|
||||
return *entry;
|
||||
});
|
||||
DCForMetrics dc;
|
||||
AutoSelectFont fs(dc, GetHFONT());
|
||||
|
||||
int devWidth;
|
||||
if (GetCharWidthI(dc, aGID, 1, nullptr, &devWidth)) {
|
||||
// clamp value to range [0..0x7fff], and convert to 16.16 fixed-point
|
||||
devWidth = std::min(std::max(0, devWidth), 0x7fff);
|
||||
width = devWidth << 16;
|
||||
mGlyphWidths->InsertOrUpdate(aGID, width);
|
||||
return width;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool gfxGDIFont::GetGlyphBounds(uint16_t aGID, gfxRect* aBounds, bool aTight) {
|
||||
|
@ -633,7 +633,7 @@ int CALLBACK gfxGDIFontList::EnumFontFamExProc(ENUMLOGFONTEXW* lpelfe,
|
||||
|
||||
gfxGDIFontList* fontList = PlatformFontList();
|
||||
|
||||
if (!fontList->mFontFamilies.Contains(key)) {
|
||||
if (!fontList->mFontFamilies.GetWeak(key)) {
|
||||
NS_ConvertUTF16toUTF8 faceName(lf.lfFaceName);
|
||||
FontVisibility visibility = FontVisibility::Unknown; // TODO
|
||||
RefPtr<GDIFontFamily> family = new GDIFontFamily(faceName, visibility);
|
||||
|
@ -419,19 +419,15 @@ bool gfxPlatformFontList::AddWithLegacyFamilyName(const nsACString& aLegacyName,
|
||||
bool added = false;
|
||||
nsAutoCString key;
|
||||
ToLowerCase(aLegacyName, key);
|
||||
mOtherFamilyNames
|
||||
.LookupOrInsertWith(
|
||||
key,
|
||||
[&] {
|
||||
RefPtr<gfxFontFamily> family =
|
||||
CreateFontFamily(aLegacyName, aVisibility);
|
||||
family->SetHasStyles(
|
||||
true); // we don't want the family to search for
|
||||
// faces, we're adding them directly here
|
||||
added = true;
|
||||
return family;
|
||||
})
|
||||
->AddFontEntry(aFontEntry->Clone());
|
||||
gfxFontFamily* family = mOtherFamilyNames.GetWeak(key);
|
||||
if (!family) {
|
||||
family = CreateFontFamily(aLegacyName, aVisibility);
|
||||
family->SetHasStyles(true); // we don't want the family to search for
|
||||
// faces, we're adding them directly here
|
||||
mOtherFamilyNames.InsertOrUpdate(key, RefPtr{family});
|
||||
added = true;
|
||||
}
|
||||
family->AddFontEntry(aFontEntry->Clone());
|
||||
return added;
|
||||
}
|
||||
|
||||
@ -1603,7 +1599,8 @@ void gfxPlatformFontList::AddOtherFamilyName(
|
||||
nsAutoCString key;
|
||||
GenerateFontListKey(aOtherFamilyName, key);
|
||||
|
||||
mOtherFamilyNames.LookupOrInsertWith(key, [&] {
|
||||
if (!mOtherFamilyNames.GetWeak(key)) {
|
||||
mOtherFamilyNames.InsertOrUpdate(key, RefPtr{aFamilyEntry});
|
||||
LOG_FONTLIST(
|
||||
("(fontlist-otherfamily) canonical family: %s, "
|
||||
"other family: %s\n",
|
||||
@ -1611,26 +1608,26 @@ void gfxPlatformFontList::AddOtherFamilyName(
|
||||
if (mBadUnderlineFamilyNames.ContainsSorted(key)) {
|
||||
aFamilyEntry->SetBadUnderlineFamily();
|
||||
}
|
||||
return RefPtr{aFamilyEntry};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void gfxPlatformFontList::AddFullname(gfxFontEntry* aFontEntry,
|
||||
const nsCString& aFullname) {
|
||||
mExtraNames->mFullnames.LookupOrInsertWith(aFullname, [&] {
|
||||
if (!mExtraNames->mFullnames.GetWeak(aFullname)) {
|
||||
mExtraNames->mFullnames.InsertOrUpdate(aFullname, RefPtr{aFontEntry});
|
||||
LOG_FONTLIST(("(fontlist-fullname) name: %s, fullname: %s\n",
|
||||
aFontEntry->Name().get(), aFullname.get()));
|
||||
return RefPtr{aFontEntry};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void gfxPlatformFontList::AddPostscriptName(gfxFontEntry* aFontEntry,
|
||||
const nsCString& aPostscriptName) {
|
||||
mExtraNames->mPostscriptNames.LookupOrInsertWith(aPostscriptName, [&] {
|
||||
if (!mExtraNames->mPostscriptNames.GetWeak(aPostscriptName)) {
|
||||
mExtraNames->mPostscriptNames.InsertOrUpdate(aPostscriptName,
|
||||
RefPtr{aFontEntry});
|
||||
LOG_FONTLIST(("(fontlist-postscript) name: %s, psname: %s\n",
|
||||
aFontEntry->Name().get(), aPostscriptName.get()));
|
||||
return RefPtr{aFontEntry};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
bool gfxPlatformFontList::GetStandardFamilyName(const nsCString& aFontName,
|
||||
|
@ -224,13 +224,17 @@ bool gfxSVGGlyphs::GetGlyphExtents(uint32_t aGlyphId,
|
||||
}
|
||||
|
||||
Element* gfxSVGGlyphs::GetGlyphElement(uint32_t aGlyphId) {
|
||||
return mGlyphIdMap.LookupOrInsertWith(aGlyphId, [&] {
|
||||
Element* elem = nullptr;
|
||||
Element* elem;
|
||||
|
||||
if (!mGlyphIdMap.Get(aGlyphId, &elem)) {
|
||||
elem = nullptr;
|
||||
if (gfxSVGGlyphsDocument* set = FindOrCreateGlyphsDocument(aGlyphId)) {
|
||||
elem = set->GetGlyphElement(aGlyphId);
|
||||
}
|
||||
return elem;
|
||||
});
|
||||
mGlyphIdMap.InsertOrUpdate(aGlyphId, elem);
|
||||
}
|
||||
|
||||
return elem;
|
||||
}
|
||||
|
||||
bool gfxSVGGlyphs::HasSVGGlyph(uint32_t aGlyphId) {
|
||||
|
@ -1018,8 +1018,12 @@ gfxUserFontFamily* gfxUserFontSet::GetFamily(const nsACString& aFamilyName) {
|
||||
nsAutoCString key(aFamilyName);
|
||||
ToLowerCase(key);
|
||||
|
||||
return mFontFamilies.LookupOrInsertWith(
|
||||
key, [&] { return MakeRefPtr<gfxUserFontFamily>(aFamilyName); });
|
||||
gfxUserFontFamily* family = mFontFamilies.GetWeak(key);
|
||||
if (!family) {
|
||||
family = new gfxUserFontFamily(aFamilyName);
|
||||
mFontFamilies.InsertOrUpdate(key, RefPtr{family});
|
||||
}
|
||||
return family;
|
||||
}
|
||||
|
||||
void gfxUserFontSet::ForgetLocalFaces() {
|
||||
|
@ -603,7 +603,7 @@ void VRManagerChild::HandleFatalError(const char* aMsg) const {
|
||||
}
|
||||
|
||||
void VRManagerChild::AddPromise(const uint32_t& aID, dom::Promise* aPromise) {
|
||||
MOZ_ASSERT(!mGamepadPromiseList.Contains(aID));
|
||||
MOZ_ASSERT(!mGamepadPromiseList.Get(aID, nullptr));
|
||||
mGamepadPromiseList.InsertOrUpdate(aID, RefPtr{aPromise});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user