Changeset 293267 in webkit


Ignore:
Timestamp:
Apr 22, 2022 4:59:50 PM (2 years ago)
Author:
Russell Epstein
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

Location:
branches/safari-613.2.7.1-branch
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-613.2.7.1-branch/LayoutTests/ChangeLog

    r293236 r293267  
     12022-04-22  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r292072. rdar://problem/80544133
     4
     5    [Cocoa] Automatically relayout the page when new fonts are installed
     6    https://bugs.webkit.org/show_bug.cgi?id=238483
     7    <rdar://problem/80544133>
     8   
     9    Reviewed by Chris Dumez.
     10   
     11    Source/WebCore:
     12   
     13    This patch simply calls setNeedsRecalcStyleInAllFrames on every Page when we receive a
     14    kCTFontManagerRegisteredFontsChangedNotification.
     15   
     16    FontCache::invalidateAllFontCaches() can't do this directly because it's in platform/ and
     17    therefore isn't allowed to know what Pages are. Instead, this patch takes a process-global
     18    callback and calls that instead. This callback is set at initialization time.
     19   
     20    Test: fast/text/install-font-style-recalc.html
     21   
     22    * page/Page.cpp:
     23    (WebCore::m_attachmentElementClient):
     24    * platform/graphics/FontCache.cpp:
     25    (WebCore::Function<void):
     26    (WebCore::FontCache::registerFontCacheInvalidationCallback):
     27    (WebCore::FontCache::invalidateAllFontCaches):
     28    * platform/graphics/FontCache.h:
     29   
     30    LayoutTests:
     31   
     32    * fast/text/install-font-style-recalc-expected.txt: Added.
     33    * fast/text/install-font-style-recalc.html: Added.
     34   
     35    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292072 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     36
     37    2022-03-29  Myles C. Maxfield  <mmaxfield@apple.com>
     38
     39            [Cocoa] Automatically relayout the page when new fonts are installed
     40            https://bugs.webkit.org/show_bug.cgi?id=238483
     41            <rdar://problem/80544133>
     42
     43            Reviewed by Chris Dumez.
     44
     45            * fast/text/install-font-style-recalc-expected.txt: Added.
     46            * fast/text/install-font-style-recalc.html: Added.
     47
    1482022-04-22  Russell Epstein  <repstein@apple.com>
    249
  • branches/safari-613.2.7.1-branch/LayoutTests/TestExpectations

    r293133 r293267  
    52075207security/contentSecurityPolicy/plugins-types-blocks-youtube-plugin-replacement.html [ Skip ]
    52085208userscripts/user-script-plugin-document.html [ Skip ]
     5209
     5210# Only some ports automatically relayout if a font is installed while the page is open
     5211fast/text/install-font-style-recalc.html [ Failure ]
  • branches/safari-613.2.7.1-branch/LayoutTests/platform/ios/TestExpectations

    r293079 r293267  
    34573457
    34583458webkit.org/b/159755 fast/text/emoji-num-glyphs.html [ Pass ]
     3459
     3460fast/text/install-font-style-recalc.html [ Pass ]
  • branches/safari-613.2.7.1-branch/LayoutTests/platform/mac/TestExpectations

    r289349 r293267  
    24302430# This test is specific to Core Text.
    24312431fast/text/font-lookup-dot-prefix-case-sensitive.html [ Pass ]
     2432
     2433fast/text/install-font-style-recalc.html [ Pass ]
  • branches/safari-613.2.7.1-branch/Source/WebCore/ChangeLog

    r293261 r293267  
     12022-04-22  Russell Epstein  <repstein@apple.com>
     2
     3        Cherry-pick r292072. rdar://problem/80544133
     4
     5    [Cocoa] Automatically relayout the page when new fonts are installed
     6    https://bugs.webkit.org/show_bug.cgi?id=238483
     7    <rdar://problem/80544133>
     8   
     9    Reviewed by Chris Dumez.
     10   
     11    Source/WebCore:
     12   
     13    This patch simply calls setNeedsRecalcStyleInAllFrames on every Page when we receive a
     14    kCTFontManagerRegisteredFontsChangedNotification.
     15   
     16    FontCache::invalidateAllFontCaches() can't do this directly because it's in platform/ and
     17    therefore isn't allowed to know what Pages are. Instead, this patch takes a process-global
     18    callback and calls that instead. This callback is set at initialization time.
     19   
     20    Test: fast/text/install-font-style-recalc.html
     21   
     22    * page/Page.cpp:
     23    (WebCore::m_attachmentElementClient):
     24    * platform/graphics/FontCache.cpp:
     25    (WebCore::Function<void):
     26    (WebCore::FontCache::registerFontCacheInvalidationCallback):
     27    (WebCore::FontCache::invalidateAllFontCaches):
     28    * platform/graphics/FontCache.h:
     29   
     30    LayoutTests:
     31   
     32    * fast/text/install-font-style-recalc-expected.txt: Added.
     33    * fast/text/install-font-style-recalc.html: Added.
     34   
     35    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292072 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     36
     37    2022-03-29  Myles C. Maxfield  <mmaxfield@apple.com>
     38
     39            [Cocoa] Automatically relayout the page when new fonts are installed
     40            https://bugs.webkit.org/show_bug.cgi?id=238483
     41            <rdar://problem/80544133>
     42
     43            Reviewed by Chris Dumez.
     44
     45            This patch simply calls setNeedsRecalcStyleInAllFrames on every Page when we receive a
     46            kCTFontManagerRegisteredFontsChangedNotification.
     47
     48            FontCache::invalidateAllFontCaches() can't do this directly because it's in platform/ and
     49            therefore isn't allowed to know what Pages are. Instead, this patch takes a process-global
     50            callback and calls that instead. This callback is set at initialization time.
     51
     52            Test: fast/text/install-font-style-recalc.html
     53
     54            * page/Page.cpp:
     55            (WebCore::m_attachmentElementClient):
     56            * platform/graphics/FontCache.cpp:
     57            (WebCore::Function<void):
     58            (WebCore::FontCache::registerFontCacheInvalidationCallback):
     59            (WebCore::FontCache::invalidateAllFontCaches):
     60            * platform/graphics/FontCache.h:
     61
    1622022-04-22  Russell Epstein  <repstein@apple.com>
    263
  • branches/safari-613.2.7.1-branch/Source/WebCore/page/Page.cpp

    r293133 r293267  
    384384    if (m_lowPowerModeNotifier->isLowPowerModeEnabled())
    385385        m_throttlingReasons.add(ThrottlingReason::LowPowerMode);
     386
     387    static bool fontCacheInvalidationCallbackRegistered = false;
     388    if (!fontCacheInvalidationCallbackRegistered) {
     389        FontCache::registerFontCacheInvalidationCallback([] {
     390            forEachPage([](auto& page) {
     391                page.setNeedsRecalcStyleInAllFrames();
     392            });
     393        });
     394        fontCacheInvalidationCallbackRegistered = true;
     395    }
    386396}
    387397
  • branches/safari-613.2.7.1-branch/Source/WebCore/platform/graphics/FontCache.cpp

    r293133 r293267  
    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
  • branches/safari-613.2.7.1-branch/Source/WebCore/platform/graphics/FontCache.h

    r293133 r293267  
    323323    unsigned short generation() const { return m_generation; }
    324324    WEBCORE_EXPORT void invalidate();
     325    static void registerFontCacheInvalidationCallback(Function<void()>&&);
    325326    WEBCORE_EXPORT static void invalidateAllFontCaches();
    326327
Note: See TracChangeset for help on using the changeset viewer.