Title: [293267] branches/safari-613.2.7.1-branch
Revision
293267
Author
repst...@apple.com
Date
2022-04-22 16:59:50 -0700 (Fri, 22 Apr 2022)

Log Message

Cherry-pick r292072. rdar://problem/80544133

    [Cocoa] Automatically relayout the page when new fonts are installed
    https://bugs.webkit.org/show_bug.cgi?id=238483
    <rdar://problem/80544133>

    Reviewed by Chris Dumez.

    Source/WebCore:

    This patch simply calls setNeedsRecalcStyleInAllFrames on every Page when we receive a
    kCTFontManagerRegisteredFontsChangedNotification.

    FontCache::invalidateAllFontCaches() can't do this directly because it's in platform/ and
    therefore isn't allowed to know what Pages are. Instead, this patch takes a process-global
    callback and calls that instead. This callback is set at initialization time.

    Test: fast/text/install-font-style-recalc.html

    * page/Page.cpp:
    (WebCore::m_attachmentElementClient):
    * platform/graphics/FontCache.cpp:
    (WebCore::Function<void):
    (WebCore::FontCache::registerFontCacheInvalidationCallback):
    (WebCore::FontCache::invalidateAllFontCaches):
    * platform/graphics/FontCache.h:

    LayoutTests:

    * fast/text/install-font-style-recalc-expected.txt: Added.
    * fast/text/install-font-style-recalc.html: Added.

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-613.2.7.1-branch/LayoutTests/ChangeLog (293266 => 293267)


--- branches/safari-613.2.7.1-branch/LayoutTests/ChangeLog	2022-04-22 23:39:17 UTC (rev 293266)
+++ branches/safari-613.2.7.1-branch/LayoutTests/ChangeLog	2022-04-22 23:59:50 UTC (rev 293267)
@@ -1,5 +1,52 @@
 2022-04-22  Russell Epstein  <repst...@apple.com>
 
+        Cherry-pick r292072. rdar://problem/80544133
+
+    [Cocoa] Automatically relayout the page when new fonts are installed
+    https://bugs.webkit.org/show_bug.cgi?id=238483
+    <rdar://problem/80544133>
+    
+    Reviewed by Chris Dumez.
+    
+    Source/WebCore:
+    
+    This patch simply calls setNeedsRecalcStyleInAllFrames on every Page when we receive a
+    kCTFontManagerRegisteredFontsChangedNotification.
+    
+    FontCache::invalidateAllFontCaches() can't do this directly because it's in platform/ and
+    therefore isn't allowed to know what Pages are. Instead, this patch takes a process-global
+    callback and calls that instead. This callback is set at initialization time.
+    
+    Test: fast/text/install-font-style-recalc.html
+    
+    * page/Page.cpp:
+    (WebCore::m_attachmentElementClient):
+    * platform/graphics/FontCache.cpp:
+    (WebCore::Function<void):
+    (WebCore::FontCache::registerFontCacheInvalidationCallback):
+    (WebCore::FontCache::invalidateAllFontCaches):
+    * platform/graphics/FontCache.h:
+    
+    LayoutTests:
+    
+    * fast/text/install-font-style-recalc-expected.txt: Added.
+    * fast/text/install-font-style-recalc.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292072 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-03-29  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+            [Cocoa] Automatically relayout the page when new fonts are installed
+            https://bugs.webkit.org/show_bug.cgi?id=238483
+            <rdar://problem/80544133>
+
+            Reviewed by Chris Dumez.
+
+            * fast/text/install-font-style-recalc-expected.txt: Added.
+            * fast/text/install-font-style-recalc.html: Added.
+
+2022-04-22  Russell Epstein  <repst...@apple.com>
+
         Cherry-pick r291724. rdar://problem/91975589
 
     Expose the AX tree of PDFs loaded via iframes on the Mac

Modified: branches/safari-613.2.7.1-branch/LayoutTests/TestExpectations (293266 => 293267)


--- branches/safari-613.2.7.1-branch/LayoutTests/TestExpectations	2022-04-22 23:39:17 UTC (rev 293266)
+++ branches/safari-613.2.7.1-branch/LayoutTests/TestExpectations	2022-04-22 23:59:50 UTC (rev 293267)
@@ -5206,3 +5206,6 @@
 security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement-without-mime-type.html [ Skip ]
 security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement.html [ Skip ]
 userscripts/user-script-plugin-document.html [ Skip ]
+
+# Only some ports automatically relayout if a font is installed while the page is open
+fast/text/install-font-style-recalc.html [ Failure ]

Added: branches/safari-613.2.7.1-branch/LayoutTests/fast/text/install-font-style-recalc-expected.txt (0 => 293267)


--- branches/safari-613.2.7.1-branch/LayoutTests/fast/text/install-font-style-recalc-expected.txt	                        (rev 0)
+++ branches/safari-613.2.7.1-branch/LayoutTests/fast/text/install-font-style-recalc-expected.txt	2022-04-22 23:59:50 UTC (rev 293267)
@@ -0,0 +1,11 @@
+This test makes sure that installing a font causes a style recalc. The test only runs in DumpRenderTree/WebKitTestRunner. It passes if the text above is rendered as black boxes (aka in Ahem).
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS target.offsetWidth became 200
+PASS The font was used.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+rrrr

Added: branches/safari-613.2.7.1-branch/LayoutTests/fast/text/install-font-style-recalc.html (0 => 293267)


--- branches/safari-613.2.7.1-branch/LayoutTests/fast/text/install-font-style-recalc.html	                        (rev 0)
+++ branches/safari-613.2.7.1-branch/LayoutTests/fast/text/install-font-style-recalc.html	2022-04-22 23:59:50 UTC (rev 293267)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<span id="target" style="font: 50px 'Helvetica2';">rrrr</span>
+<script>
+description("This test makes sure that installing a font causes a style recalc. The test only runs in DumpRenderTree/WebKitTestRunner. It passes if the text above is rendered as black boxes (aka in Ahem).");
+window.jsTestIsAsync = true;
+let target = document.getElementById("target");
+target.offsetWidth; // Force a font lookup
+if (window.testRunner)
+    testRunner.installFakeHelvetica("Helvetica2-400");
+shouldBecomeEqual("target.offsetWidth", "200", function() {
+    testPassed("The font was used.");
+    finishJSTest();
+});
+</script>
+</body>
+</html>

Modified: branches/safari-613.2.7.1-branch/LayoutTests/platform/ios/TestExpectations (293266 => 293267)


--- branches/safari-613.2.7.1-branch/LayoutTests/platform/ios/TestExpectations	2022-04-22 23:39:17 UTC (rev 293266)
+++ branches/safari-613.2.7.1-branch/LayoutTests/platform/ios/TestExpectations	2022-04-22 23:59:50 UTC (rev 293267)
@@ -3456,3 +3456,5 @@
 fast/text/design-system-ui-16.html [ Pass ]
 
 webkit.org/b/159755 fast/text/emoji-num-glyphs.html [ Pass ]
+
+fast/text/install-font-style-recalc.html [ Pass ]

Modified: branches/safari-613.2.7.1-branch/LayoutTests/platform/mac/TestExpectations (293266 => 293267)


--- branches/safari-613.2.7.1-branch/LayoutTests/platform/mac/TestExpectations	2022-04-22 23:39:17 UTC (rev 293266)
+++ branches/safari-613.2.7.1-branch/LayoutTests/platform/mac/TestExpectations	2022-04-22 23:59:50 UTC (rev 293267)
@@ -2429,3 +2429,5 @@
 
 # This test is specific to Core Text.
 fast/text/font-lookup-dot-prefix-case-sensitive.html [ Pass ]
+
+fast/text/install-font-style-recalc.html [ Pass ]

Modified: branches/safari-613.2.7.1-branch/Source/WebCore/ChangeLog (293266 => 293267)


--- branches/safari-613.2.7.1-branch/Source/WebCore/ChangeLog	2022-04-22 23:39:17 UTC (rev 293266)
+++ branches/safari-613.2.7.1-branch/Source/WebCore/ChangeLog	2022-04-22 23:59:50 UTC (rev 293267)
@@ -1,5 +1,66 @@
 2022-04-22  Russell Epstein  <repst...@apple.com>
 
+        Cherry-pick r292072. rdar://problem/80544133
+
+    [Cocoa] Automatically relayout the page when new fonts are installed
+    https://bugs.webkit.org/show_bug.cgi?id=238483
+    <rdar://problem/80544133>
+    
+    Reviewed by Chris Dumez.
+    
+    Source/WebCore:
+    
+    This patch simply calls setNeedsRecalcStyleInAllFrames on every Page when we receive a
+    kCTFontManagerRegisteredFontsChangedNotification.
+    
+    FontCache::invalidateAllFontCaches() can't do this directly because it's in platform/ and
+    therefore isn't allowed to know what Pages are. Instead, this patch takes a process-global
+    callback and calls that instead. This callback is set at initialization time.
+    
+    Test: fast/text/install-font-style-recalc.html
+    
+    * page/Page.cpp:
+    (WebCore::m_attachmentElementClient):
+    * platform/graphics/FontCache.cpp:
+    (WebCore::Function<void):
+    (WebCore::FontCache::registerFontCacheInvalidationCallback):
+    (WebCore::FontCache::invalidateAllFontCaches):
+    * platform/graphics/FontCache.h:
+    
+    LayoutTests:
+    
+    * fast/text/install-font-style-recalc-expected.txt: Added.
+    * fast/text/install-font-style-recalc.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292072 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-03-29  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+            [Cocoa] Automatically relayout the page when new fonts are installed
+            https://bugs.webkit.org/show_bug.cgi?id=238483
+            <rdar://problem/80544133>
+
+            Reviewed by Chris Dumez.
+
+            This patch simply calls setNeedsRecalcStyleInAllFrames on every Page when we receive a
+            kCTFontManagerRegisteredFontsChangedNotification.
+
+            FontCache::invalidateAllFontCaches() can't do this directly because it's in platform/ and
+            therefore isn't allowed to know what Pages are. Instead, this patch takes a process-global
+            callback and calls that instead. This callback is set at initialization time.
+
+            Test: fast/text/install-font-style-recalc.html
+
+            * page/Page.cpp:
+            (WebCore::m_attachmentElementClient):
+            * platform/graphics/FontCache.cpp:
+            (WebCore::Function<void):
+            (WebCore::FontCache::registerFontCacheInvalidationCallback):
+            (WebCore::FontCache::invalidateAllFontCaches):
+            * platform/graphics/FontCache.h:
+
+2022-04-22  Russell Epstein  <repst...@apple.com>
+
         Cherry-pick r291589. rdar://problem/90511155
 
     LayoutTests/imported/w3c:

Modified: branches/safari-613.2.7.1-branch/Source/WebCore/page/Page.cpp (293266 => 293267)


--- branches/safari-613.2.7.1-branch/Source/WebCore/page/Page.cpp	2022-04-22 23:39:17 UTC (rev 293266)
+++ branches/safari-613.2.7.1-branch/Source/WebCore/page/Page.cpp	2022-04-22 23:59:50 UTC (rev 293267)
@@ -383,6 +383,16 @@
 
     if (m_lowPowerModeNotifier->isLowPowerModeEnabled())
         m_throttlingReasons.add(ThrottlingReason::LowPowerMode);
+
+    static bool fontCacheInvalidationCallbackRegistered = false;
+    if (!fontCacheInvalidationCallbackRegistered) {
+        FontCache::registerFontCacheInvalidationCallback([] {
+            forEachPage([](auto& page) {
+                page.setNeedsRecalcStyleInAllFrames();
+            });
+        });
+        fontCacheInvalidationCallbackRegistered = true;
+    }
 }
 
 Page::~Page()

Modified: branches/safari-613.2.7.1-branch/Source/WebCore/platform/graphics/FontCache.cpp (293266 => 293267)


--- branches/safari-613.2.7.1-branch/Source/WebCore/platform/graphics/FontCache.cpp	2022-04-22 23:39:17 UTC (rev 293266)
+++ branches/safari-613.2.7.1-branch/Source/WebCore/platform/graphics/FontCache.cpp	2022-04-22 23:59:50 UTC (rev 293267)
@@ -489,6 +489,17 @@
     purgeInactiveFontData();
 }
 
+static Function<void()>& fontCacheInvalidationCallback()
+{
+    static NeverDestroyed<Function<void()>> callback;
+    return callback.get();
+}
+
+void FontCache::registerFontCacheInvalidationCallback(Function<void()>&& callback)
+{
+    fontCacheInvalidationCallback() = WTFMove(callback);
+}
+
 void FontCache::invalidateAllFontCaches()
 {
     ASSERT(isMainThread());
@@ -495,6 +506,9 @@
 
     // FIXME: Invalidate FontCaches in workers too.
     FontCache::forCurrentThread().invalidate();
+
+    if (fontCacheInvalidationCallback())
+        fontCacheInvalidationCallback()();
 }
 
 #if !PLATFORM(COCOA)

Modified: branches/safari-613.2.7.1-branch/Source/WebCore/platform/graphics/FontCache.h (293266 => 293267)


--- branches/safari-613.2.7.1-branch/Source/WebCore/platform/graphics/FontCache.h	2022-04-22 23:39:17 UTC (rev 293266)
+++ branches/safari-613.2.7.1-branch/Source/WebCore/platform/graphics/FontCache.h	2022-04-22 23:59:50 UTC (rev 293267)
@@ -322,6 +322,7 @@
 
     unsigned short generation() const { return m_generation; }
     WEBCORE_EXPORT void invalidate();
+    static void registerFontCacheInvalidationCallback(Function<void()>&&);
     WEBCORE_EXPORT static void invalidateAllFontCaches();
 
     WEBCORE_EXPORT size_t fontCount();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to