⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 292072 in webkit


Ignore:
Timestamp:
Mar 29, 2022, 2:49:38 PM (4 years ago)
Author:
mmaxfield@apple.com
Message:

[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.
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r292069 r292072  
     12022-03-29  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [Cocoa] Automatically relayout the page when new fonts are installed
     4        https://bugs.webkit.org/show_bug.cgi?id=238483
     5        <rdar://problem/80544133>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * fast/text/install-font-style-recalc-expected.txt: Added.
     10        * fast/text/install-font-style-recalc.html: Added.
     11
    1122022-03-29  Arcady Goldmints-Orlov  <agoldmints@igalia.com>
    213
  • trunk/LayoutTests/TestExpectations

    r292045 r292072  
    52095209# Only certain ports have WebGPU implementations.
    52105210http/tests/webgpu [ Failure ImageOnlyFailure Pass Timeout ]
     5211
     5212# Only some ports automatically relayout if a font is installed while the page is open
     5213fast/text/install-font-style-recalc.html [ Failure ]
  • trunk/LayoutTests/platform/ios/TestExpectations

    r292061 r292072  
    35683568# iOS has a WebGPU implementation.
    35693569http/tests/webgpu [ Pass ]
     3570
     3571fast/text/install-font-style-recalc.html [ Pass ]
  • trunk/LayoutTests/platform/mac/TestExpectations

    r292052 r292072  
    24162416# macOS has a WebGPU implementation.
    24172417http/tests/webgpu [ Pass ]
     2418
     2419fast/text/install-font-style-recalc.html [ Pass ]
  • trunk/Source/WebCore/ChangeLog

    r292067 r292072  
     12022-03-29  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [Cocoa] Automatically relayout the page when new fonts are installed
     4        https://bugs.webkit.org/show_bug.cgi?id=238483
     5        <rdar://problem/80544133>
     6
     7        Reviewed by Chris Dumez.
     8
     9        This patch simply calls setNeedsRecalcStyleInAllFrames on every Page when we receive a
     10        kCTFontManagerRegisteredFontsChangedNotification.
     11
     12        FontCache::invalidateAllFontCaches() can't do this directly because it's in platform/ and
     13        therefore isn't allowed to know what Pages are. Instead, this patch takes a process-global
     14        callback and calls that instead. This callback is set at initialization time.
     15
     16        Test: fast/text/install-font-style-recalc.html
     17
     18        * page/Page.cpp:
     19        (WebCore::m_attachmentElementClient):
     20        * platform/graphics/FontCache.cpp:
     21        (WebCore::Function<void):
     22        (WebCore::FontCache::registerFontCacheInvalidationCallback):
     23        (WebCore::FontCache::invalidateAllFontCaches):
     24        * platform/graphics/FontCache.h:
     25
    1262022-03-29  Alex Christensen  <achristensen@webkit.org>
    227
  • trunk/Source/WebCore/page/Page.cpp

    r291992 r292072  
    389389    if (m_lowPowerModeNotifier->isLowPowerModeEnabled())
    390390        m_throttlingReasons.add(ThrottlingReason::LowPowerMode);
     391
     392    static bool fontCacheInvalidationCallbackRegistered = false;
     393    if (!fontCacheInvalidationCallbackRegistered) {
     394        FontCache::registerFontCacheInvalidationCallback([] {
     395            forEachPage([](auto& page) {
     396                page.setNeedsRecalcStyleInAllFrames();
     397            });
     398        });
     399        fontCacheInvalidationCallbackRegistered = true;
     400    }
    391401}
    392402
  • trunk/Source/WebCore/platform/graphics/FontCache.cpp

    r290901 r292072  
    490490}
    491491
     492static Function<void()>& fontCacheInvalidationCallback()
     493{
     494    static NeverDestroyed<Function<void()>> callback;
     495    return callback.get();
     496}
     497
     498void FontCache::registerFontCacheInvalidationCallback(Function<void()>&& callback)
     499{
     500    fontCacheInvalidationCallback() = WTFMove(callback);
     501}
     502
    492503void FontCache::invalidateAllFontCaches()
    493504{
     
    496507    // FIXME: Invalidate FontCaches in workers too.
    497508    FontCache::forCurrentThread().invalidate();
     509
     510    if (fontCacheInvalidationCallback())
     511        fontCacheInvalidationCallback()();
    498512}
    499513
  • trunk/Source/WebCore/platform/graphics/FontCache.h

    r290901 r292072  
    329329    unsigned short generation() const { return m_generation; }
    330330    WEBCORE_EXPORT void invalidate();
     331    static void registerFontCacheInvalidationCallback(Function<void()>&&);
    331332    WEBCORE_EXPORT static void invalidateAllFontCaches();
    332333
Note: See TracChangeset for help on using the changeset viewer.