Title: [282583] branches/safari-612-branch
Revision
282583
Author
repst...@apple.com
Date
2021-09-16 11:49:03 -0700 (Thu, 16 Sep 2021)

Log Message

Cherry-pick r281845. rdar://problem/83183887

    document.fonts.size needs to update style so it doesn't return stale values
    https://bugs.webkit.org/show_bug.cgi?id=229644

    Reviewed by Darin Adler.

    LayoutTests/imported/w3c:

    * web-platform-tests/css/css-font-loading/fontfaceset-update-after-stylesheet-change-expected.txt:

    Source/WebCore:

    Currently, we only update style inside the document::fonts() call.
    This isn't correct because content can save the results of document.fonts,
    do some work, then ask for its size.

    Test: web-platform-tests/css/css-font-loading/fontfaceset-update-after-stylesheet-change.html

    * css/CSSFontFace.cpp:
    (WebCore::CSSFontFace::updateStyleIfNeeded):
    * css/CSSFontFace.h:
    * css/CSSFontFaceSet.cpp:
    (WebCore::CSSFontFaceSet::updateStyleIfNeeded):
    * css/CSSFontFaceSet.h:
    * css/CSSFontSelector.cpp:
    (WebCore::CSSFontSelector::updateStyleIfNeeded):
    (WebCore::CSSFontSelector::fontStyleUpdateNeeded): Deleted.
    * css/CSSFontSelector.h:
    * css/FontFaceSet.cpp:
    (WebCore::FontFaceSet::size):
    (WebCore::FontFaceSet::size const): Deleted.
    * css/FontFaceSet.h:
    * dom/Document.cpp:
    (WebCore::Document::fonts):

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-612-branch/LayoutTests/imported/w3c/ChangeLog (282582 => 282583)


--- branches/safari-612-branch/LayoutTests/imported/w3c/ChangeLog	2021-09-16 18:48:59 UTC (rev 282582)
+++ branches/safari-612-branch/LayoutTests/imported/w3c/ChangeLog	2021-09-16 18:49:03 UTC (rev 282583)
@@ -1,5 +1,54 @@
 2021-09-16  Russell Epstein  <repst...@apple.com>
 
+        Cherry-pick r281845. rdar://problem/83183887
+
+    document.fonts.size needs to update style so it doesn't return stale values
+    https://bugs.webkit.org/show_bug.cgi?id=229644
+    
+    Reviewed by Darin Adler.
+    
+    LayoutTests/imported/w3c:
+    
+    * web-platform-tests/css/css-font-loading/fontfaceset-update-after-stylesheet-change-expected.txt:
+    
+    Source/WebCore:
+    
+    Currently, we only update style inside the document::fonts() call.
+    This isn't correct because content can save the results of document.fonts,
+    do some work, then ask for its size.
+    
+    Test: web-platform-tests/css/css-font-loading/fontfaceset-update-after-stylesheet-change.html
+    
+    * css/CSSFontFace.cpp:
+    (WebCore::CSSFontFace::updateStyleIfNeeded):
+    * css/CSSFontFace.h:
+    * css/CSSFontFaceSet.cpp:
+    (WebCore::CSSFontFaceSet::updateStyleIfNeeded):
+    * css/CSSFontFaceSet.h:
+    * css/CSSFontSelector.cpp:
+    (WebCore::CSSFontSelector::updateStyleIfNeeded):
+    (WebCore::CSSFontSelector::fontStyleUpdateNeeded): Deleted.
+    * css/CSSFontSelector.h:
+    * css/FontFaceSet.cpp:
+    (WebCore::FontFaceSet::size):
+    (WebCore::FontFaceSet::size const): Deleted.
+    * css/FontFaceSet.h:
+    * dom/Document.cpp:
+    (WebCore::Document::fonts):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281845 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-09-01  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+            document.fonts.size needs to update style so it doesn't return stale values
+            https://bugs.webkit.org/show_bug.cgi?id=229644
+
+            Reviewed by Darin Adler.
+
+            * web-platform-tests/css/css-font-loading/fontfaceset-update-after-stylesheet-change-expected.txt:
+
+2021-09-16  Russell Epstein  <repst...@apple.com>
+
         Cherry-pick r281842. rdar://problem/83183953
 
     CSSFontFaceSet.clear() should not clear CSS-connected members

Added: branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/css/css-font-loading/fontfaceset-update-after-stylesheet-change-expected.txt (0 => 282583)


--- branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/css/css-font-loading/fontfaceset-update-after-stylesheet-change-expected.txt	                        (rev 0)
+++ branches/safari-612-branch/LayoutTests/imported/w3c/web-platform-tests/css/css-font-loading/fontfaceset-update-after-stylesheet-change-expected.txt	2021-09-16 18:49:03 UTC (rev 282583)
@@ -0,0 +1,3 @@
+
+PASS fontfaceset-update-after-stylesheet-change
+

Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (282582 => 282583)


--- branches/safari-612-branch/Source/WebCore/ChangeLog	2021-09-16 18:48:59 UTC (rev 282582)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog	2021-09-16 18:49:03 UTC (rev 282583)
@@ -1,5 +1,75 @@
 2021-09-16  Russell Epstein  <repst...@apple.com>
 
+        Cherry-pick r281845. rdar://problem/83183887
+
+    document.fonts.size needs to update style so it doesn't return stale values
+    https://bugs.webkit.org/show_bug.cgi?id=229644
+    
+    Reviewed by Darin Adler.
+    
+    LayoutTests/imported/w3c:
+    
+    * web-platform-tests/css/css-font-loading/fontfaceset-update-after-stylesheet-change-expected.txt:
+    
+    Source/WebCore:
+    
+    Currently, we only update style inside the document::fonts() call.
+    This isn't correct because content can save the results of document.fonts,
+    do some work, then ask for its size.
+    
+    Test: web-platform-tests/css/css-font-loading/fontfaceset-update-after-stylesheet-change.html
+    
+    * css/CSSFontFace.cpp:
+    (WebCore::CSSFontFace::updateStyleIfNeeded):
+    * css/CSSFontFace.h:
+    * css/CSSFontFaceSet.cpp:
+    (WebCore::CSSFontFaceSet::updateStyleIfNeeded):
+    * css/CSSFontFaceSet.h:
+    * css/CSSFontSelector.cpp:
+    (WebCore::CSSFontSelector::updateStyleIfNeeded):
+    (WebCore::CSSFontSelector::fontStyleUpdateNeeded): Deleted.
+    * css/CSSFontSelector.h:
+    * css/FontFaceSet.cpp:
+    (WebCore::FontFaceSet::size):
+    (WebCore::FontFaceSet::size const): Deleted.
+    * css/FontFaceSet.h:
+    * dom/Document.cpp:
+    (WebCore::Document::fonts):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281845 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-09-01  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+            document.fonts.size needs to update style so it doesn't return stale values
+            https://bugs.webkit.org/show_bug.cgi?id=229644
+
+            Reviewed by Darin Adler.
+
+            Currently, we only update style inside the document::fonts() call.
+            This isn't correct because content can save the results of document.fonts,
+            do some work, then ask for its size.
+
+            Test: web-platform-tests/css/css-font-loading/fontfaceset-update-after-stylesheet-change.html
+
+            * css/CSSFontFace.cpp:
+            (WebCore::CSSFontFace::updateStyleIfNeeded):
+            * css/CSSFontFace.h:
+            * css/CSSFontFaceSet.cpp:
+            (WebCore::CSSFontFaceSet::updateStyleIfNeeded):
+            * css/CSSFontFaceSet.h:
+            * css/CSSFontSelector.cpp:
+            (WebCore::CSSFontSelector::updateStyleIfNeeded):
+            (WebCore::CSSFontSelector::fontStyleUpdateNeeded): Deleted.
+            * css/CSSFontSelector.h:
+            * css/FontFaceSet.cpp:
+            (WebCore::FontFaceSet::size):
+            (WebCore::FontFaceSet::size const): Deleted.
+            * css/FontFaceSet.h:
+            * dom/Document.cpp:
+            (WebCore::Document::fonts):
+
+2021-09-16  Russell Epstein  <repst...@apple.com>
+
         Cherry-pick r281842. rdar://problem/83183953
 
     CSSFontFaceSet.clear() should not clear CSS-connected members

Modified: branches/safari-612-branch/Source/WebCore/css/CSSFontFace.cpp (282582 => 282583)


--- branches/safari-612-branch/Source/WebCore/css/CSSFontFace.cpp	2021-09-16 18:48:59 UTC (rev 282582)
+++ branches/safari-612-branch/Source/WebCore/css/CSSFontFace.cpp	2021-09-16 18:49:03 UTC (rev 282583)
@@ -699,7 +699,7 @@
 void CSSFontFace::updateStyleIfNeeded()
 {
     iterateClients(m_clients, [&](Client& client) {
-        client.fontStyleUpdateNeeded(*this);
+        client.updateStyleIfNeeded(*this);
     });
 }
 

Modified: branches/safari-612-branch/Source/WebCore/css/CSSFontFace.h (282582 => 282583)


--- branches/safari-612-branch/Source/WebCore/css/CSSFontFace.h	2021-09-16 18:48:59 UTC (rev 282582)
+++ branches/safari-612-branch/Source/WebCore/css/CSSFontFace.h	2021-09-16 18:49:03 UTC (rev 282583)
@@ -125,7 +125,7 @@
         virtual void fontLoaded(CSSFontFace&) { }
         virtual void fontStateChanged(CSSFontFace&, Status /*oldState*/, Status /*newState*/) { }
         virtual void fontPropertyChanged(CSSFontFace&, CSSValueList* /*oldFamilies*/ = nullptr) { }
-        virtual void fontStyleUpdateNeeded(CSSFontFace&) { }
+        virtual void updateStyleIfNeeded(CSSFontFace&) { }
         virtual void ref() = 0;
         virtual void deref() = 0;
     };

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


--- branches/safari-612-branch/Source/WebCore/css/CSSFontFaceSet.cpp	2021-09-16 18:48:59 UTC (rev 282582)
+++ branches/safari-612-branch/Source/WebCore/css/CSSFontFaceSet.cpp	2021-09-16 18:49:03 UTC (rev 282583)
@@ -103,6 +103,13 @@
     return false;
 }
 
+// Calling updateStyleIfNeeded() might delete |this|.
+void CSSFontFaceSet::updateStyleIfNeeded()
+{
+    if (m_owningFontSelector)
+        m_owningFontSelector->updateStyleIfNeeded();
+}
+
 void CSSFontFaceSet::ensureLocalFontFacesForFamilyRegistered(const String& familyName)
 {
     ASSERT(m_owningFontSelector);

Modified: branches/safari-612-branch/Source/WebCore/css/CSSFontFaceSet.h (282582 => 282583)


--- branches/safari-612-branch/Source/WebCore/css/CSSFontFaceSet.h	2021-09-16 18:48:59 UTC (rev 282582)
+++ branches/safari-612-branch/Source/WebCore/css/CSSFontFaceSet.h	2021-09-16 18:49:03 UTC (rev 282583)
@@ -57,6 +57,9 @@
     };
     void addFontEventClient(const FontEventClient&);
 
+    // Calling updateStyleIfNeeded() might delete |this|.
+    void updateStyleIfNeeded();
+
     bool hasFace(const CSSFontFace&) const;
     size_t faceCount() const { return m_faces.size(); }
     void add(CSSFontFace&);
@@ -84,6 +87,8 @@
     // CSSFontFace::Client needs to be able to be held in a RefPtr.
     void ref() final { RefCounted::ref(); }
     void deref() final { RefCounted::deref(); }
+    // FIXME: Should this be implemented?
+    void updateStyleIfNeeded(CSSFontFace&) final { }
 
 private:
     CSSFontFaceSet(CSSFontSelector*);

Modified: branches/safari-612-branch/Source/WebCore/css/CSSFontSelector.cpp (282582 => 282583)


--- branches/safari-612-branch/Source/WebCore/css/CSSFontSelector.cpp	2021-09-16 18:48:59 UTC (rev 282582)
+++ branches/safari-612-branch/Source/WebCore/css/CSSFontSelector.cpp	2021-09-16 18:49:03 UTC (rev 282583)
@@ -269,12 +269,17 @@
         dispatchInvalidationCallbacks();
 }
 
-void CSSFontSelector::fontStyleUpdateNeeded(CSSFontFace&)
+void CSSFontSelector::updateStyleIfNeeded()
 {
     if (is<Document>(m_context.get()))
         downcast<Document>(*m_context).updateStyleIfNeeded();
 }
 
+void CSSFontSelector::updateStyleIfNeeded(CSSFontFace&)
+{
+    updateStyleIfNeeded();
+}
+
 void CSSFontSelector::fontCacheInvalidated()
 {
     dispatchInvalidationCallbacks();

Modified: branches/safari-612-branch/Source/WebCore/css/CSSFontSelector.h (282582 => 282583)


--- branches/safari-612-branch/Source/WebCore/css/CSSFontSelector.h	2021-09-16 18:48:59 UTC (rev 282582)
+++ branches/safari-612-branch/Source/WebCore/css/CSSFontSelector.h	2021-09-16 18:49:03 UTC (rev 282583)
@@ -89,6 +89,8 @@
 
     void loadPendingFonts();
 
+    void updateStyleIfNeeded();
+
     // CSSFontFace::Client needs to be able to be held in a RefPtr.
     void ref() final { FontSelector::ref(); }
     void deref() final { FontSelector::deref(); }
@@ -104,7 +106,7 @@
 
     // CSSFontFace::Client
     void fontLoaded(CSSFontFace&) final;
-    void fontStyleUpdateNeeded(CSSFontFace&) final;
+    void updateStyleIfNeeded(CSSFontFace&) final;
 
     void fontModified();
 

Modified: branches/safari-612-branch/Source/WebCore/css/FontFaceSet.cpp (282582 => 282583)


--- branches/safari-612-branch/Source/WebCore/css/FontFaceSet.cpp	2021-09-16 18:48:59 UTC (rev 282582)
+++ branches/safari-612-branch/Source/WebCore/css/FontFaceSet.cpp	2021-09-16 18:49:03 UTC (rev 282583)
@@ -112,9 +112,11 @@
     return m_backing->hasFace(face.backing());
 }
 
-size_t FontFaceSet::size() const
+size_t FontFaceSet::size()
 {
-    return m_backing->faceCount();
+    auto protect = m_backing;
+    protect->updateStyleIfNeeded();
+    return protect->faceCount();
 }
 
 FontFaceSet& FontFaceSet::add(FontFace& face)

Modified: branches/safari-612-branch/Source/WebCore/css/FontFaceSet.h (282582 => 282583)


--- branches/safari-612-branch/Source/WebCore/css/FontFaceSet.h	2021-09-16 18:48:59 UTC (rev 282582)
+++ branches/safari-612-branch/Source/WebCore/css/FontFaceSet.h	2021-09-16 18:49:03 UTC (rev 282583)
@@ -46,7 +46,7 @@
     virtual ~FontFaceSet();
 
     bool has(FontFace&) const;
-    size_t size() const;
+    size_t size();
     FontFaceSet& add(FontFace&);
     bool remove(FontFace&);
     void clear();

Modified: branches/safari-612-branch/Source/WebCore/dom/Document.cpp (282582 => 282583)


--- branches/safari-612-branch/Source/WebCore/dom/Document.cpp	2021-09-16 18:48:59 UTC (rev 282582)
+++ branches/safari-612-branch/Source/WebCore/dom/Document.cpp	2021-09-16 18:49:03 UTC (rev 282583)
@@ -7439,7 +7439,7 @@
 
 Ref<FontFaceSet> Document::fonts()
 {
-    updateStyleIfNeeded();
+    updateStyleIfNeeded(); // FIXME: This is unnecessary. Instead, the actual accessors in the FontFaceSet need to update style.
     return fontSelector().fontFaceSet();
 }
     
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to