Title: [282240] branches/safari-612-branch/Source/WebCore
Revision
282240
Author
[email protected]
Date
2021-09-09 14:57:32 -0700 (Thu, 09 Sep 2021)

Log Message

Cherry-pick r281648. rdar://problem/82944435

    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):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281648 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (282239 => 282240)


--- branches/safari-612-branch/Source/WebCore/ChangeLog	2021-09-09 21:36:38 UTC (rev 282239)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog	2021-09-09 21:57:32 UTC (rev 282240)
@@ -1,5 +1,51 @@
 2021-09-09  Russell Epstein  <[email protected]>
 
+        Cherry-pick r281648. rdar://problem/82944435
+
+    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):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281648 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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-09-09  Russell Epstein  <[email protected]>
+
         Cherry-pick r282142. rdar://problem/82931317
 
     Add a fast path for atomizing strings when parsing HTML

Modified: branches/safari-612-branch/Source/WebCore/css/CSSFontFaceSet.cpp (282239 => 282240)


--- branches/safari-612-branch/Source/WebCore/css/CSSFontFaceSet.cpp	2021-09-09 21:36:38 UTC (rev 282239)
+++ branches/safari-612-branch/Source/WebCore/css/CSSFontFaceSet.cpp	2021-09-09 21:57:32 UTC (rev 282240)
@@ -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