Bug 1688833 - Migrate LookupForAdd to WithEntryHandle in gfx/thebes. r=lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D104215
This commit is contained in:
Simon Giesecke 2021-02-09 18:19:39 +00:00
Родитель d4f7649e81
Коммит 010633d2d1
2 изменённых файлов: 27 добавлений и 23 удалений

Просмотреть файл

@ -1591,16 +1591,17 @@ void gfxFcPlatformFontList::InitSharedFontListForPlatform() {
aFamilyName = ToCharPtr(canonical);
// Add new family record if one doesn't already exist.
auto faceList = faces.LookupForAdd(keyName);
if (!faceList) {
faceList.OrInsert([]() { return new FaceInitArray; });
FontVisibility visibility =
aAppFont ? FontVisibility::Base : GetVisibilityForFamily(keyName);
families.AppendElement(fontlist::Family::InitData(
keyName, aFamilyName, fontlist::Family::kNoIndex, visibility,
/*bundled*/ aAppFont, /*badUnderline*/ false));
}
faceListPtr = faceList.Data().get();
faceListPtr = faces.WithEntryHandle(keyName, [&](auto&& faceList) {
if (!faceList) {
faceList.Insert(new FaceInitArray);
FontVisibility visibility =
aAppFont ? FontVisibility::Base : GetVisibilityForFamily(keyName);
families.AppendElement(fontlist::Family::InitData(
keyName, aFamilyName, fontlist::Family::kNoIndex, visibility,
/*bundled*/ aAppFont, /*badUnderline*/ false));
}
return faceList.Data().get();
});
}
char* s = (char*)FcNameUnparse(aPattern);
@ -1649,17 +1650,18 @@ void gfxFcPlatformFontList::InitSharedFontListForPlatform() {
keyName = otherFamilyName;
ToLowerCase(keyName);
auto faceList = faces.LookupForAdd(keyName);
if (!faceList) {
faceList.OrInsert([]() { return new FaceInitArray; });
FontVisibility visibility =
aAppFont ? FontVisibility::Base : GetVisibilityForFamily(keyName);
families.AppendElement(fontlist::Family::InitData(
keyName, otherFamilyName, fontlist::Family::kNoIndex, visibility,
/*bundled*/ aAppFont, /*badUnderline*/ false));
}
faceList.Data()->AppendElement(fontlist::Face::InitData{
descriptor, 0, false, weight, stretch, style});
faces.WithEntryHandle(keyName, [&](auto&& faceList) {
if (!faceList) {
faceList.Insert(new FaceInitArray);
FontVisibility visibility =
aAppFont ? FontVisibility::Base : GetVisibilityForFamily(keyName);
families.AppendElement(fontlist::Family::InitData(
keyName, otherFamilyName, fontlist::Family::kNoIndex, visibility,
/*bundled*/ aAppFont, /*badUnderline*/ false));
}
faceList.Data()->AppendElement(fontlist::Face::InitData{
descriptor, 0, false, weight, stretch, style});
});
n++;
if (n == int(cIndex)) {

Просмотреть файл

@ -1584,8 +1584,10 @@ gfxFontEntry* gfxPlatformFontList::FindFontForFamily(
gfxFontEntry* gfxPlatformFontList::GetOrCreateFontEntry(
fontlist::Face* aFace, const fontlist::Family* aFamily) {
return mFontEntries.LookupForAdd(aFace).OrInsert(
[=]() { return CreateFontEntry(aFace, aFamily); });
return mFontEntries.WithEntryHandle(aFace, [&](auto&& entry) {
return entry.OrInsertWith([=] { return CreateFontEntry(aFace, aFamily); })
.get();
});
}
void gfxPlatformFontList::AddOtherFamilyName(