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

Changeset 273726 in webkit


Ignore:
Timestamp:
Mar 2, 2021, 2:13:56 AM (6 years ago)
Author:
Chris Lord
Message:

Remove document accessor on CSSFontSelector
​https://bugs.webkit.org/show_bug.cgi?id=222550

Reviewed by Darin Adler.

Replace FontSelector::document() with FontSelector::scriptExecutionContext().

No new tests because there is no behavior change.

  • css/CSSFontFace.cpp:

(WebCore::CSSFontFace::appendSources):
(WebCore::CSSFontFace::create):
(WebCore::CSSFontFace::CSSFontFace):

  • css/CSSFontFace.h:
  • css/CSSFontFaceSet.cpp:

(WebCore::CSSFontFaceSet::ensureLocalFontFacesForFamilyRegistered):

  • css/CSSFontSelector.cpp:

(WebCore::CSSFontSelector::scriptExecutionContext const):
(WebCore::CSSFontSelector::fontStyleUpdateNeeded):

  • css/CSSFontSelector.h:
  • css/FontFace.cpp:

(WebCore::FontFace::FontFace):

Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r273723 r273726  
     12021-03-02  Chris Lord  <clord@igalia.com>
     2
     3        Remove document accessor on CSSFontSelector
     4        https://bugs.webkit.org/show_bug.cgi?id=222550
     5
     6        Reviewed by Darin Adler.
     7
     8        Replace FontSelector::document() with FontSelector::scriptExecutionContext().
     9
     10        No new tests because there is no behavior change.
     11
     12        * css/CSSFontFace.cpp:
     13        (WebCore::CSSFontFace::appendSources):
     14        (WebCore::CSSFontFace::create):
     15        (WebCore::CSSFontFace::CSSFontFace):
     16        * css/CSSFontFace.h:
     17        * css/CSSFontFaceSet.cpp:
     18        (WebCore::CSSFontFaceSet::ensureLocalFontFacesForFamilyRegistered):
     19        * css/CSSFontSelector.cpp:
     20        (WebCore::CSSFontSelector::scriptExecutionContext const):
     21        (WebCore::CSSFontSelector::fontStyleUpdateNeeded):
     22        * css/CSSFontSelector.h:
     23        * css/FontFace.cpp:
     24        (WebCore::FontFace::FontFace):
     25
    1262021-03-01  Zalan Bujtas  <zalan@apple.com>
    227
  • trunk/Source/WebCore/css/CSSFontFace.cpp

    r273650 r273726  
    6363}
    6464
    65 void CSSFontFace::appendSources(CSSFontFace& fontFace, CSSValueList& srcList, Document* document, bool isInitiatingElementInUserAgentShadowTree)
     65void CSSFontFace::appendSources(CSSFontFace& fontFace, CSSValueList& srcList, ScriptExecutionContext* context, bool isInitiatingElementInUserAgentShadowTree)
    6666{
    6767    for (auto& src : srcList) {
    … …  
    7575        fontFaceElement = item.svgFontFaceElement();
    7676        if (!item.isLocal()) {
    77             const Settings* settings = document ? &document->settings() : nullptr;
    78             bool allowDownloading = foundSVGFont || (settings && settings->downloadableBinaryFontsEnabled());
    79             if (allowDownloading && item.isSupportedFormat() && document) {
    80                 if (CachedFont* cachedFont = item.cachedFont(document, foundSVGFont, isInitiatingElementInUserAgentShadowTree))
    81                     source = makeUnique<CSSFontFaceSource>(fontFace, item.resource(), document->fontSelector(), *cachedFont);
     77            const auto* settings = context ? &context->settingsValues() : nullptr;
     78            bool allowDownloading = foundSVGFont || (settings && settings->downloadableBinaryFontsEnabled);
     79            if (allowDownloading && item.isSupportedFormat() && is<Document>(context)) {
     80                auto& document = downcast<Document>(*context);
     81                if (CachedFont* cachedFont = item.cachedFont(&document, foundSVGFont, isInitiatingElementInUserAgentShadowTree))
     82                    source = makeUnique<CSSFontFaceSource>(fontFace, item.resource(), document.fontSelector(), *cachedFont);
    8283            }
    8384        } else
    … …  
    9394Ref<CSSFontFace> CSSFontFace::create(CSSFontSelector* fontSelector, StyleRuleFontFace* cssConnection, FontFace* wrapper, bool isLocalFallback)
    9495{
    95     auto result = adoptRef(*new CSSFontFace((fontSelector && fontSelector->document()) ? &fontSelector->document()->settings() : nullptr, cssConnection, wrapper, isLocalFallback));
     96    auto* context = fontSelector ? fontSelector->scriptExecutionContext() : nullptr;
     97    const auto* settings = context ? &context->settingsValues() : nullptr;
     98    auto result = adoptRef(*new CSSFontFace(settings, cssConnection, wrapper, isLocalFallback));
    9699    if (fontSelector)
    97100        result->addClient(*fontSelector);
    … …  
    99102}
    100103
    101 CSSFontFace::CSSFontFace(const Settings* settings, StyleRuleFontFace* cssConnection, FontFace* wrapper, bool isLocalFallback)
     104CSSFontFace::CSSFontFace(const Settings::Values* settings, StyleRuleFontFace* cssConnection, FontFace* wrapper, bool isLocalFallback)
    102105    : m_cssConnection(cssConnection)
    103106    , m_wrapper(makeWeakPtr(wrapper))
    104107    , m_isLocalFallback(isLocalFallback)
    105108    , m_mayBePurged(!wrapper)
    106     , m_shouldIgnoreFontLoadCompletions(settings && settings->shouldIgnoreFontLoadCompletions())
    107     , m_fontLoadTimingOverride(settings ? settings->fontLoadTimingOverride() : FontLoadTimingOverride::None)
    108     , m_allowUserInstalledFonts(settings && !settings->shouldAllowUserInstalledFonts() ? AllowUserInstalledFonts::No : AllowUserInstalledFonts::Yes)
     109    , m_shouldIgnoreFontLoadCompletions(settings && settings->shouldIgnoreFontLoadCompletions)
     110    , m_fontLoadTimingOverride(settings ? settings->fontLoadTimingOverride : FontLoadTimingOverride::None)
     111    , m_allowUserInstalledFonts(settings && !settings->shouldAllowUserInstalledFonts ? AllowUserInstalledFonts::No : AllowUserInstalledFonts::Yes)
    109112    , m_timeoutTimer(*this, &CSSFontFace::timeoutFired)
    110113{
  • trunk/Source/WebCore/css/CSSFontFace.h

    r273650 r273726  
    2626#pragma once
    2727
    28 #include "FontLoadTimingOverride.h"
    2928#include "FontSelectionValueInlines.h"
    3029#include "FontTaggedSettings.h"
     30#include "Settings.h"
    3131#include "StyleRule.h"
    3232#include "TextFlags.h"
    33 #include "Timer.h"
    3433#include <memory>
    3534#include <wtf/Forward.h>
    3635#include <wtf/HashSet.h>
    37 #include <wtf/RefCounted.h>
    38 #include <wtf/Vector.h>
    3936#include <wtf/WeakPtr.h>
    4037
    … …  
    5047class CSSValue;
    5148class CSSValueList;
    52 class Document;
    5349class FontDescription;
    5450class Font;
    … …  
    121117    RefPtr<Font> font(const FontDescription&, bool syntheticBold, bool syntheticItalic, ExternalResourceDownloadPolicy);
    122118
    123     static void appendSources(CSSFontFace&, CSSValueList&, Document*, bool isInitiatingElementInUserAgentShadowTree);
     119    static void appendSources(CSSFontFace&, CSSValueList&, ScriptExecutionContext*, bool isInitiatingElementInUserAgentShadowTree);
    124120
    125121    class Client {
    … …  
    165161
    166162private:
    167     CSSFontFace(const Settings*, StyleRuleFontFace*, FontFace*, bool isLocalFallback);
     163    CSSFontFace(const Settings::Values*, StyleRuleFontFace*, FontFace*, bool isLocalFallback);
    168164
    169165    size_t pump(ExternalResourceDownloadPolicy);
  • trunk/Source/WebCore/css/CSSFontFaceSet.cpp

    r272047 r273726  
    109109
    110110    AllowUserInstalledFonts allowUserInstalledFonts = AllowUserInstalledFonts::Yes;
    111     if (m_owningFontSelector->document())
    112         allowUserInstalledFonts = m_owningFontSelector->document()->settings().shouldAllowUserInstalledFonts() ? AllowUserInstalledFonts::Yes : AllowUserInstalledFonts::No;
     111    if (m_owningFontSelector->scriptExecutionContext())
     112        allowUserInstalledFonts = m_owningFontSelector->scriptExecutionContext()->settingsValues().shouldAllowUserInstalledFonts ? AllowUserInstalledFonts::Yes : AllowUserInstalledFonts::No;
    113113    Vector<FontSelectionCapabilities> capabilities = FontCache::singleton().getFontSelectionCapabilitiesInFamily(familyName, allowUserInstalledFonts);
    114114    if (capabilities.isEmpty())
  • trunk/Source/WebCore/css/CSSFontSelector.cpp

    r273650 r273726  
    232232}
    233233
     234ScriptExecutionContext* CSSFontSelector::scriptExecutionContext() const
     235{
     236    // This class returns a ScriptExecutionContext despite holding a Document as preparation for a future
     237    // where it will actually hold a ScriptExecutionContext (which would be either a Document or a
     238    // WorkerGlobalScope, in the case of using fonts in OffscreenCanvas).
     239    return m_document.get();
     240}
     241
    234242void CSSFontSelector::dispatchInvalidationCallbacks()
    235243{
    … …  
    262270void CSSFontSelector::fontStyleUpdateNeeded(CSSFontFace&)
    263271{
    264     if (document())
    265         document()->updateStyleIfNeeded();
     272    if (m_document)
     273        m_document->updateStyleIfNeeded();
    266274}
    267275
  • trunk/Source/WebCore/css/CSSFontSelector.h

    r273374 r273726  
    7878    void unregisterForInvalidationCallbacks(FontSelectorClient&) final;
    7979
    80     Document* document() const { return m_document.get(); }
     80    ScriptExecutionContext* scriptExecutionContext() const;
    8181
    8282    void beginLoadingFontSoon(CachedFont&);
  • trunk/Source/WebCore/css/FontFace.cpp

    r273650 r273726  
    149149
    150150FontFace::FontFace(CSSFontSelector& fontSelector)
    151     : ActiveDOMObject(fontSelector.document())
     151    : ActiveDOMObject(fontSelector.scriptExecutionContext())
    152152    , m_backing(CSSFontFace::create(&fontSelector, nullptr, this))
    153153    , m_loadedPromise(makeUniqueRef<LoadedPromise>(*this, &FontFace::loadedPromiseResolve))
Note: See TracChangeset for help on using the changeset viewer.