Title: [281648] trunk/Source/WebCore
Revision
281648
Author
[email protected]
Date
2021-08-26 13:21:27 -0700 (Thu, 26 Aug 2021)

Log Message

REGRESSION(r256659): We try to remove fonts from the CSSFontFace which were never added
https://bugs.webkit.org/show_bug.cgi?id=229535
<rdar://problem/78857440>

Reviewed by Darin Adler.

After r256659, asking for a failed CSSFontFace's families() returns nullopt. It's possible to add
a failed font to a CSSFontFaceSet (of course). When we do that, we recognize the font is failed
and don't update our internal data structures, because there's no need to - we can't do anything
useful with a failed font.

If you _then_ try to remove the font from the CSSFontFace, we don't call families(), but instead
just pull out the raw m_families member, and look in our internal data structures for it, but we
don't find it, because it was never added.

* css/CSSFontFaceSet.cpp:
(WebCore::CSSFontFaceSet::addToFacesLookupTable):
(WebCore::CSSFontFaceSet::removeFromFacesLookupTable):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (281647 => 281648)


--- trunk/Source/WebCore/ChangeLog	2021-08-26 19:37:16 UTC (rev 281647)
+++ trunk/Source/WebCore/ChangeLog	2021-08-26 20:21:27 UTC (rev 281648)
@@ -1,3 +1,24 @@
+2021-08-26  Myles C. Maxfield  <[email protected]>
+
+        REGRESSION(r256659): We try to remove fonts from the CSSFontFace which were never added
+        https://bugs.webkit.org/show_bug.cgi?id=229535
+        <rdar://problem/78857440>
+
+        Reviewed by Darin Adler.
+
+        After r256659, asking for a failed CSSFontFace's families() returns nullopt. It's possible to add
+        a failed font to a CSSFontFaceSet (of course). When we do that, we recognize the font is failed
+        and don't update our internal data structures, because there's no need to - we can't do anything
+        useful with a failed font.
+
+        If you _then_ try to remove the font from the CSSFontFace, we don't call families(), but instead
+        just pull out the raw m_families member, and look in our internal data structures for it, but we
+        don't find it, because it was never added.
+
+        * css/CSSFontFaceSet.cpp:
+        (WebCore::CSSFontFaceSet::addToFacesLookupTable):
+        (WebCore::CSSFontFaceSet::removeFromFacesLookupTable):
+
 2021-08-26  Alan Bujtas  <[email protected]>
 
         [IFC] Use the inline run list in showRenderTree to print inline level box information

Modified: trunk/Source/WebCore/css/CSSFontFaceSet.cpp (281647 => 281648)


--- trunk/Source/WebCore/css/CSSFontFaceSet.cpp	2021-08-26 19:37:16 UTC (rev 281647)
+++ trunk/Source/WebCore/css/CSSFontFaceSet.cpp	2021-08-26 20:21:27 UTC (rev 281648)
@@ -162,8 +162,11 @@
 
 void CSSFontFaceSet::addToFacesLookupTable(CSSFontFace& face)
 {
-    if (!face.families())
+    if (!face.families()) {
+        // If the font has failed, there's no point in actually adding it to m_facesLookupTable,
+        // because no font requests can actually use it for anything. So, let's just ... not add it.
         return;
+    }
     auto families = face.families().value();
 
     for (auto& item : *families) {
@@ -220,7 +223,12 @@
             continue;
 
         auto iterator = m_facesLookupTable.find(familyName);
-        ASSERT(iterator != m_facesLookupTable.end());
+        if (iterator == m_facesLookupTable.end()) {
+            // The font may have failed even before addToFacesLookupTable() was called on it,
+            // which means we never added it (because there's no point in adding a failed font).
+            // So, if it was never added, removing it is free! Woohoo!
+            return;
+        }
         bool found = false;
         for (size_t i = 0; i < iterator->value.size(); ++i) {
             if (iterator->value[i].ptr() == &face) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to