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);
faceListPtr = faces.WithEntryHandle(keyName, [&](auto&& faceList) {
if (!faceList) {
faceList.OrInsert([]() { return new FaceInitArray; });
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));
}
faceListPtr = faceList.Data().get();
return faceList.Data().get();
});
}
char* s = (char*)FcNameUnparse(aPattern);
@ -1649,9 +1650,9 @@ void gfxFcPlatformFontList::InitSharedFontListForPlatform() {
keyName = otherFamilyName;
ToLowerCase(keyName);
auto faceList = faces.LookupForAdd(keyName);
faces.WithEntryHandle(keyName, [&](auto&& faceList) {
if (!faceList) {
faceList.OrInsert([]() { return new FaceInitArray; });
faceList.Insert(new FaceInitArray);
FontVisibility visibility =
aAppFont ? FontVisibility::Base : GetVisibilityForFamily(keyName);
families.AppendElement(fontlist::Family::InitData(
@ -1660,6 +1661,7 @@ void gfxFcPlatformFontList::InitSharedFontListForPlatform() {
}
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(