Changeset 273726 in webkit
- Timestamp:
- Mar 2, 2021, 2:13:56 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
-
ChangeLog (modified) (1 diff)
-
css/CSSFontFace.cpp (modified) (4 diffs)
-
css/CSSFontFace.h (modified) (4 diffs)
-
css/CSSFontFaceSet.cpp (modified) (1 diff)
-
css/CSSFontSelector.cpp (modified) (2 diffs)
-
css/CSSFontSelector.h (modified) (1 diff)
-
css/FontFace.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r273723 r273726 1 2021-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 1 26 2021-03-01 Zalan Bujtas <zalan@apple.com> 2 27 -
trunk/Source/WebCore/css/CSSFontFace.cpp
r273650 r273726 63 63 } 64 64 65 void CSSFontFace::appendSources(CSSFontFace& fontFace, CSSValueList& srcList, Document* document, bool isInitiatingElementInUserAgentShadowTree)65 void CSSFontFace::appendSources(CSSFontFace& fontFace, CSSValueList& srcList, ScriptExecutionContext* context, bool isInitiatingElementInUserAgentShadowTree) 66 66 { 67 67 for (auto& src : srcList) { … … 75 75 fontFaceElement = item.svgFontFaceElement(); 76 76 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); 82 83 } 83 84 } else … … 93 94 Ref<CSSFontFace> CSSFontFace::create(CSSFontSelector* fontSelector, StyleRuleFontFace* cssConnection, FontFace* wrapper, bool isLocalFallback) 94 95 { 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)); 96 99 if (fontSelector) 97 100 result->addClient(*fontSelector); … … 99 102 } 100 103 101 CSSFontFace::CSSFontFace(const Settings * settings, StyleRuleFontFace* cssConnection, FontFace* wrapper, bool isLocalFallback)104 CSSFontFace::CSSFontFace(const Settings::Values* settings, StyleRuleFontFace* cssConnection, FontFace* wrapper, bool isLocalFallback) 102 105 : m_cssConnection(cssConnection) 103 106 , m_wrapper(makeWeakPtr(wrapper)) 104 107 , m_isLocalFallback(isLocalFallback) 105 108 , 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) 109 112 , m_timeoutTimer(*this, &CSSFontFace::timeoutFired) 110 113 { -
trunk/Source/WebCore/css/CSSFontFace.h
r273650 r273726 26 26 #pragma once 27 27 28 #include "FontLoadTimingOverride.h"29 28 #include "FontSelectionValueInlines.h" 30 29 #include "FontTaggedSettings.h" 30 #include "Settings.h" 31 31 #include "StyleRule.h" 32 32 #include "TextFlags.h" 33 #include "Timer.h"34 33 #include <memory> 35 34 #include <wtf/Forward.h> 36 35 #include <wtf/HashSet.h> 37 #include <wtf/RefCounted.h>38 #include <wtf/Vector.h>39 36 #include <wtf/WeakPtr.h> 40 37 … … 50 47 class CSSValue; 51 48 class CSSValueList; 52 class Document;53 49 class FontDescription; 54 50 class Font; … … 121 117 RefPtr<Font> font(const FontDescription&, bool syntheticBold, bool syntheticItalic, ExternalResourceDownloadPolicy); 122 118 123 static void appendSources(CSSFontFace&, CSSValueList&, Document*, bool isInitiatingElementInUserAgentShadowTree);119 static void appendSources(CSSFontFace&, CSSValueList&, ScriptExecutionContext*, bool isInitiatingElementInUserAgentShadowTree); 124 120 125 121 class Client { … … 165 161 166 162 private: 167 CSSFontFace(const Settings *, StyleRuleFontFace*, FontFace*, bool isLocalFallback);163 CSSFontFace(const Settings::Values*, StyleRuleFontFace*, FontFace*, bool isLocalFallback); 168 164 169 165 size_t pump(ExternalResourceDownloadPolicy); -
trunk/Source/WebCore/css/CSSFontFaceSet.cpp
r272047 r273726 109 109 110 110 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; 113 113 Vector<FontSelectionCapabilities> capabilities = FontCache::singleton().getFontSelectionCapabilitiesInFamily(familyName, allowUserInstalledFonts); 114 114 if (capabilities.isEmpty()) -
trunk/Source/WebCore/css/CSSFontSelector.cpp
r273650 r273726 232 232 } 233 233 234 ScriptExecutionContext* 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 234 242 void CSSFontSelector::dispatchInvalidationCallbacks() 235 243 { … … 262 270 void CSSFontSelector::fontStyleUpdateNeeded(CSSFontFace&) 263 271 { 264 if ( document())265 document()->updateStyleIfNeeded();272 if (m_document) 273 m_document->updateStyleIfNeeded(); 266 274 } 267 275 -
trunk/Source/WebCore/css/CSSFontSelector.h
r273374 r273726 78 78 void unregisterForInvalidationCallbacks(FontSelectorClient&) final; 79 79 80 Document* document() const { return m_document.get(); }80 ScriptExecutionContext* scriptExecutionContext() const; 81 81 82 82 void beginLoadingFontSoon(CachedFont&); -
trunk/Source/WebCore/css/FontFace.cpp
r273650 r273726 149 149 150 150 FontFace::FontFace(CSSFontSelector& fontSelector) 151 : ActiveDOMObject(fontSelector. document())151 : ActiveDOMObject(fontSelector.scriptExecutionContext()) 152 152 , m_backing(CSSFontFace::create(&fontSelector, nullptr, this)) 153 153 , m_loadedPromise(makeUniqueRef<LoadedPromise>(*this, &FontFace::loadedPromiseResolve))
Note:
See TracChangeset
for help on using the changeset viewer.