diff --git a/gfx/thebes/gfxFcPlatformFontList.cpp b/gfx/thebes/gfxFcPlatformFontList.cpp index baec762d707e..34db63699efb 100644 --- a/gfx/thebes/gfxFcPlatformFontList.cpp +++ b/gfx/thebes/gfxFcPlatformFontList.cpp @@ -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)) { diff --git a/gfx/thebes/gfxPlatformFontList.cpp b/gfx/thebes/gfxPlatformFontList.cpp index c8f9c3cc2f10..0385495eff95 100644 --- a/gfx/thebes/gfxPlatformFontList.cpp +++ b/gfx/thebes/gfxPlatformFontList.cpp @@ -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(