diff --git a/layout/style/FontFaceSet.cpp b/layout/style/FontFaceSet.cpp index 9348111dffde..9fd9614a7f78 100644 --- a/layout/style/FontFaceSet.cpp +++ b/layout/style/FontFaceSet.cpp @@ -662,21 +662,6 @@ FontFaceSet::StartLoad(gfxUserFontEntry* aUserFontEntry, return rv; } -static PLDHashOperator DetachFontEntries(const nsAString& aKey, - RefPtr& aFamily, - void* aUserArg) -{ - aFamily->DetachFontEntries(); - return PL_DHASH_NEXT; -} - -static PLDHashOperator RemoveIfEmpty(const nsAString& aKey, - RefPtr& aFamily, - void* aUserArg) -{ - return aFamily->GetFontList().Length() ? PL_DHASH_NEXT : PL_DHASH_REMOVE; -} - bool FontFaceSet::UpdateRules(const nsTArray& aRules) { @@ -711,7 +696,9 @@ FontFaceSet::UpdateRules(const nsTArray& aRules) // the same font entries as before. (The order can affect font selection // where multiple faces match the requested style, perhaps with overlapping // unicode-range coverage.) - mUserFontSet->mFontFamilies.Enumerate(DetachFontEntries, nullptr); + for (auto it = mUserFontSet->mFontFamilies.Iter(); !it.Done(); it.Next()) { + it.Data()->DetachFontEntries(); + } // Sometimes aRules has duplicate @font-face rules in it; we should make // that not happen, but in the meantime, don't try to insert the same @@ -743,7 +730,11 @@ FontFaceSet::UpdateRules(const nsTArray& aRules) // Remove any residual families that have no font entries (i.e., they were // not defined at all by the updated set of @font-face rules). - mUserFontSet->mFontFamilies.Enumerate(RemoveIfEmpty, nullptr); + for (auto it = mUserFontSet->mFontFamilies.Iter(); !it.Done(); it.Next()) { + if (it.Data()->GetFontList().IsEmpty()) { + it.Remove(); + } + } // If any FontFace objects for rules are left in the old list, note that the // set has changed (even if the new set was built entirely by migrating old