WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-222550-20210302094614.patch (text/plain), 10.69 KB, created by
Chris Lord
on 2021-03-02 01:46:15 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Chris Lord
Created:
2021-03-02 01:46:15 PST
Size:
10.69 KB
patch
obsolete
>Subversion Revision: 273241 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 26f6c073e1e4a5ddbd9d73484e740c6f6c00d85e..4020a53c97ae17db2d5da872c97dc297f61aeaa4 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,28 @@ >+2021-03-01 Chris Lord <clord@igalia.com> >+ >+ 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): >+ > 2021-02-24 Chris Lord <clord@igalia.com> > > CSSFontFace should not need its m_fontSelector data member >diff --git a/Source/WebCore/css/CSSFontFace.cpp b/Source/WebCore/css/CSSFontFace.cpp >index 0b04fd53f1697fd1441f71a1185a7281668b26b3..8171accea7ef47cb153995e94aa8a0119d7ae360 100644 >--- a/Source/WebCore/css/CSSFontFace.cpp >+++ b/Source/WebCore/css/CSSFontFace.cpp >@@ -62,7 +62,7 @@ template<typename T> void iterateClients(HashSet<CSSFontFace::Client*>& clients, > callback(client); > } > >-void CSSFontFace::appendSources(CSSFontFace& fontFace, CSSValueList& srcList, Document* document, bool isInitiatingElementInUserAgentShadowTree) >+void CSSFontFace::appendSources(CSSFontFace& fontFace, CSSValueList& srcList, ScriptExecutionContext* context, bool isInitiatingElementInUserAgentShadowTree) > { > for (auto& src : srcList) { > // An item in the list either specifies a string (local font name) or a URL (remote font to download). >@@ -74,11 +74,12 @@ void CSSFontFace::appendSources(CSSFontFace& fontFace, CSSValueList& srcList, Do > foundSVGFont = item.isSVGFontFaceSrc() || item.svgFontFaceElement(); > fontFaceElement = item.svgFontFaceElement(); > if (!item.isLocal()) { >- const Settings* settings = document ? &document->settings() : nullptr; >- bool allowDownloading = foundSVGFont || (settings && settings->downloadableBinaryFontsEnabled()); >- if (allowDownloading && item.isSupportedFormat() && document) { >- if (CachedFont* cachedFont = item.cachedFont(document, foundSVGFont, isInitiatingElementInUserAgentShadowTree)) >- source = makeUnique<CSSFontFaceSource>(fontFace, item.resource(), document->fontSelector(), *cachedFont); >+ const auto* settings = context ? &context->settingsValues() : nullptr; >+ bool allowDownloading = foundSVGFont || (settings && settings->downloadableBinaryFontsEnabled); >+ if (allowDownloading && item.isSupportedFormat() && is<Document>(context)) { >+ auto& document = downcast<Document>(*context); >+ if (CachedFont* cachedFont = item.cachedFont(&document, foundSVGFont, isInitiatingElementInUserAgentShadowTree)) >+ source = makeUnique<CSSFontFaceSource>(fontFace, item.resource(), document.fontSelector(), *cachedFont); > } > } else > source = (fontFaceElement ? makeUnique<CSSFontFaceSource>(fontFace, item.resource(), *fontFaceElement) >@@ -92,20 +93,22 @@ void CSSFontFace::appendSources(CSSFontFace& fontFace, CSSValueList& srcList, Do > > Ref<CSSFontFace> CSSFontFace::create(CSSFontSelector* fontSelector, StyleRuleFontFace* cssConnection, FontFace* wrapper, bool isLocalFallback) > { >- auto result = adoptRef(*new CSSFontFace((fontSelector && fontSelector->document()) ? &fontSelector->document()->settings() : nullptr, cssConnection, wrapper, isLocalFallback)); >+ auto* context = fontSelector ? fontSelector->scriptExecutionContext() : nullptr; >+ const auto* settings = context ? &context->settingsValues() : nullptr; >+ auto result = adoptRef(*new CSSFontFace(settings, cssConnection, wrapper, isLocalFallback)); > if (fontSelector) > result->addClient(*fontSelector); > return result; > } > >-CSSFontFace::CSSFontFace(const Settings* settings, StyleRuleFontFace* cssConnection, FontFace* wrapper, bool isLocalFallback) >+CSSFontFace::CSSFontFace(const Settings::Values* settings, StyleRuleFontFace* cssConnection, FontFace* wrapper, bool isLocalFallback) > : m_cssConnection(cssConnection) > , m_wrapper(makeWeakPtr(wrapper)) > , m_isLocalFallback(isLocalFallback) > , m_mayBePurged(!wrapper) >- , m_shouldIgnoreFontLoadCompletions(settings && settings->shouldIgnoreFontLoadCompletions()) >- , m_fontLoadTimingOverride(settings ? settings->fontLoadTimingOverride() : FontLoadTimingOverride::None) >- , m_allowUserInstalledFonts(settings && !settings->shouldAllowUserInstalledFonts() ? AllowUserInstalledFonts::No : AllowUserInstalledFonts::Yes) >+ , m_shouldIgnoreFontLoadCompletions(settings && settings->shouldIgnoreFontLoadCompletions) >+ , m_fontLoadTimingOverride(settings ? settings->fontLoadTimingOverride : FontLoadTimingOverride::None) >+ , m_allowUserInstalledFonts(settings && !settings->shouldAllowUserInstalledFonts ? AllowUserInstalledFonts::No : AllowUserInstalledFonts::Yes) > , m_timeoutTimer(*this, &CSSFontFace::timeoutFired) > { > } >diff --git a/Source/WebCore/css/CSSFontFace.h b/Source/WebCore/css/CSSFontFace.h >index 732500b9db3f59b950c268fee0027b41da73670d..b5e4975d1d59209d862bd8462dd7cdfff6f59dbd 100644 >--- a/Source/WebCore/css/CSSFontFace.h >+++ b/Source/WebCore/css/CSSFontFace.h >@@ -25,17 +25,14 @@ > > #pragma once > >-#include "FontLoadTimingOverride.h" > #include "FontSelectionValueInlines.h" > #include "FontTaggedSettings.h" >+#include "Settings.h" > #include "StyleRule.h" > #include "TextFlags.h" >-#include "Timer.h" > #include <memory> > #include <wtf/Forward.h> > #include <wtf/HashSet.h> >-#include <wtf/RefCounted.h> >-#include <wtf/Vector.h> > #include <wtf/WeakPtr.h> > > namespace JSC { >@@ -49,7 +46,6 @@ class CSSFontSelector; > class CSSSegmentedFontFace; > class CSSValue; > class CSSValueList; >-class Document; > class FontDescription; > class Font; > class FontFace; >@@ -120,7 +116,7 @@ public: > > RefPtr<Font> font(const FontDescription&, bool syntheticBold, bool syntheticItalic, ExternalResourceDownloadPolicy); > >- static void appendSources(CSSFontFace&, CSSValueList&, Document*, bool isInitiatingElementInUserAgentShadowTree); >+ static void appendSources(CSSFontFace&, CSSValueList&, ScriptExecutionContext*, bool isInitiatingElementInUserAgentShadowTree); > > class Client { > public: >@@ -164,7 +160,7 @@ public: > void setErrorState(); > > private: >- CSSFontFace(const Settings*, StyleRuleFontFace*, FontFace*, bool isLocalFallback); >+ CSSFontFace(const Settings::Values*, StyleRuleFontFace*, FontFace*, bool isLocalFallback); > > size_t pump(ExternalResourceDownloadPolicy); > void setStatus(Status); >diff --git a/Source/WebCore/css/CSSFontFaceSet.cpp b/Source/WebCore/css/CSSFontFaceSet.cpp >index 729be033fcfb82b03890a2a829249b757e6924f3..61632b8504f3f7db48e3d0eef6c72c5607c60cf5 100644 >--- a/Source/WebCore/css/CSSFontFaceSet.cpp >+++ b/Source/WebCore/css/CSSFontFaceSet.cpp >@@ -108,8 +108,8 @@ void CSSFontFaceSet::ensureLocalFontFacesForFamilyRegistered(const String& famil > return; > > AllowUserInstalledFonts allowUserInstalledFonts = AllowUserInstalledFonts::Yes; >- if (m_owningFontSelector->document()) >- allowUserInstalledFonts = m_owningFontSelector->document()->settings().shouldAllowUserInstalledFonts() ? AllowUserInstalledFonts::Yes : AllowUserInstalledFonts::No; >+ if (m_owningFontSelector->scriptExecutionContext()) >+ allowUserInstalledFonts = m_owningFontSelector->scriptExecutionContext()->settingsValues().shouldAllowUserInstalledFonts ? AllowUserInstalledFonts::Yes : AllowUserInstalledFonts::No; > Vector<FontSelectionCapabilities> capabilities = FontCache::singleton().getFontSelectionCapabilitiesInFamily(familyName, allowUserInstalledFonts); > if (capabilities.isEmpty()) > return; >diff --git a/Source/WebCore/css/CSSFontSelector.cpp b/Source/WebCore/css/CSSFontSelector.cpp >index b07b994cbea0e0d9d94eac9d9b0d66561061934e..7ebfbd11aa840a92bf9eb69f92c76b7aba365fce 100644 >--- a/Source/WebCore/css/CSSFontSelector.cpp >+++ b/Source/WebCore/css/CSSFontSelector.cpp >@@ -231,6 +231,14 @@ void CSSFontSelector::unregisterForInvalidationCallbacks(FontSelectorClient& cli > m_clients.remove(&client); > } > >+ScriptExecutionContext* CSSFontSelector::scriptExecutionContext() const >+{ >+ // This class returns a ScriptExecutionContext despite holding a Document as preparation for a future >+ // where it will actually hold a ScriptExecutionContext (which would be either a Document or a >+ // WorkerGlobalScope, in the case of using fonts in OffscreenCanvas). >+ return m_document.get(); >+} >+ > void CSSFontSelector::dispatchInvalidationCallbacks() > { > ++m_version; >@@ -261,8 +269,8 @@ void CSSFontSelector::fontModified() > > void CSSFontSelector::fontStyleUpdateNeeded(CSSFontFace&) > { >- if (document()) >- document()->updateStyleIfNeeded(); >+ if (m_document) >+ m_document->updateStyleIfNeeded(); > } > > void CSSFontSelector::fontCacheInvalidated() >diff --git a/Source/WebCore/css/CSSFontSelector.h b/Source/WebCore/css/CSSFontSelector.h >index da43172de0f4046e726e2eca1c38054424a4daf1..e59718fb126d12f96b849f90eb3715c18b801f0b 100644 >--- a/Source/WebCore/css/CSSFontSelector.h >+++ b/Source/WebCore/css/CSSFontSelector.h >@@ -77,7 +77,7 @@ public: > void registerForInvalidationCallbacks(FontSelectorClient&) final; > void unregisterForInvalidationCallbacks(FontSelectorClient&) final; > >- Document* document() const { return m_document.get(); } >+ ScriptExecutionContext* scriptExecutionContext() const; > > void beginLoadingFontSoon(CachedFont&); > void suspendFontLoadingTimer(); >diff --git a/Source/WebCore/css/FontFace.cpp b/Source/WebCore/css/FontFace.cpp >index 3bd8c069038778746ce4bb6e932f93a2c468f95f..35ffc0382a15a20fa4ee871c8638ea6168e3be1b 100644 >--- a/Source/WebCore/css/FontFace.cpp >+++ b/Source/WebCore/css/FontFace.cpp >@@ -148,7 +148,7 @@ Ref<FontFace> FontFace::create(ScriptExecutionContext* context, CSSFontFace& fac > } > > FontFace::FontFace(CSSFontSelector& fontSelector) >- : ActiveDOMObject(fontSelector.document()) >+ : ActiveDOMObject(fontSelector.scriptExecutionContext()) > , m_backing(CSSFontFace::create(&fontSelector, nullptr, this)) > , m_loadedPromise(makeUniqueRef<LoadedPromise>(*this, &FontFace::loadedPromiseResolve)) > {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 222550
:
421825
| 421916