- Revision
- 272727
- Author
- [email protected]
- Date
- 2021-02-11 08:06:08 -0800 (Thu, 11 Feb 2021)
Log Message
Remove FontSelector dependence in CSSFontFace when creating a new FontFace wrapper
https://bugs.webkit.org/show_bug.cgi?id=221753
Reviewed by Myles C. Maxfield.
Add a parameter to the CSSFontFace-based FontFace constructor to allow
specifying the ScriptExecutionContext and therefore allow removal of
another dependence on m_fontSelector in CSSFontFace.
No new tests because there is no behavior change.
* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::wrapper):
* css/CSSFontFace.h:
* css/FontFace.cpp:
(WebCore::FontFace::create):
(WebCore::FontFace::FontFace):
* css/FontFace.h:
* css/FontFaceSet.cpp:
(WebCore::FontFaceSet::Iterator::next):
(WebCore::FontFaceSet::load):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (272726 => 272727)
--- trunk/Source/WebCore/ChangeLog 2021-02-11 15:25:20 UTC (rev 272726)
+++ trunk/Source/WebCore/ChangeLog 2021-02-11 16:06:08 UTC (rev 272727)
@@ -1,3 +1,27 @@
+2021-02-11 Chris Lord <[email protected]>
+
+ Remove FontSelector dependence in CSSFontFace when creating a new FontFace wrapper
+ https://bugs.webkit.org/show_bug.cgi?id=221753
+
+ Reviewed by Myles C. Maxfield.
+
+ Add a parameter to the CSSFontFace-based FontFace constructor to allow
+ specifying the ScriptExecutionContext and therefore allow removal of
+ another dependence on m_fontSelector in CSSFontFace.
+
+ No new tests because there is no behavior change.
+
+ * css/CSSFontFace.cpp:
+ (WebCore::CSSFontFace::wrapper):
+ * css/CSSFontFace.h:
+ * css/FontFace.cpp:
+ (WebCore::FontFace::create):
+ (WebCore::FontFace::FontFace):
+ * css/FontFace.h:
+ * css/FontFaceSet.cpp:
+ (WebCore::FontFaceSet::Iterator::next):
+ (WebCore::FontFaceSet::load):
+
2021-02-11 Zalan Bujtas <[email protected]>
[LFC][IFC] Introduce dedicated logical rect getter for each inline level box type
Modified: trunk/Source/WebCore/css/CSSFontFace.cpp (272726 => 272727)
--- trunk/Source/WebCore/css/CSSFontFace.cpp 2021-02-11 15:25:20 UTC (rev 272726)
+++ trunk/Source/WebCore/css/CSSFontFace.cpp 2021-02-11 16:06:08 UTC (rev 272727)
@@ -429,12 +429,14 @@
m_mayBePurged = false;
}
-Ref<FontFace> CSSFontFace::wrapper()
+Ref<FontFace> CSSFontFace::wrapper(ScriptExecutionContext* context)
{
- if (m_wrapper)
+ if (m_wrapper) {
+ ASSERT(m_wrapper->scriptExecutionContext() == context);
return *m_wrapper.get();
+ }
- auto wrapper = FontFace::create(*this);
+ auto wrapper = FontFace::create(context, *this);
m_wrapper = makeWeakPtr(wrapper.get());
initializeWrapper();
return wrapper;
@@ -454,11 +456,6 @@
ASSERT(!m_sourcesPopulated);
}
-Document* CSSFontFace::document() const
-{
- return m_fontSelector ? m_fontSelector->document() : nullptr;
-}
-
auto CSSFontFace::fontLoadTiming() const -> FontLoadTiming
{
switch (m_fontLoadTimingOverride) {
Modified: trunk/Source/WebCore/css/CSSFontFace.h (272726 => 272727)
--- trunk/Source/WebCore/css/CSSFontFace.h 2021-02-11 15:25:20 UTC (rev 272726)
+++ trunk/Source/WebCore/css/CSSFontFace.h 2021-02-11 16:06:08 UTC (rev 272727)
@@ -53,6 +53,7 @@
class FontDescription;
class Font;
class FontFace;
+class ScriptExecutionContext;
enum class ExternalResourceDownloadPolicy;
DECLARE_ALLOCATOR_WITH_HEAP_IDENTIFIER(CSSFontFace);
@@ -145,7 +146,7 @@
bool rangesMatchCodePoint(UChar32) const;
// We don't guarantee that the FontFace wrapper will be the same every time you ask for it.
- Ref<FontFace> wrapper();
+ Ref<FontFace> wrapper(ScriptExecutionContext*);
void setWrapper(FontFace&);
FontFace* existingWrapper();
@@ -165,8 +166,6 @@
bool hasSVGFontFaceSource() const;
void setErrorState();
- Document* document() const;
-
private:
CSSFontFace(CSSFontSelector*, StyleRuleFontFace*, FontFace*, bool isLocalFallback);
CSSFontFace(const Settings*, StyleRuleFontFace*, FontFace*, bool isLocalFallback);
Modified: trunk/Source/WebCore/css/FontFace.cpp (272726 => 272727)
--- trunk/Source/WebCore/css/FontFace.cpp 2021-02-11 15:25:20 UTC (rev 272726)
+++ trunk/Source/WebCore/css/FontFace.cpp 2021-02-11 16:06:08 UTC (rev 272727)
@@ -140,9 +140,9 @@
return result;
}
-Ref<FontFace> FontFace::create(CSSFontFace& face)
+Ref<FontFace> FontFace::create(ScriptExecutionContext* context, CSSFontFace& face)
{
- auto fontFace = adoptRef(*new FontFace(face));
+ auto fontFace = adoptRef(*new FontFace(context, face));
fontFace->suspendIfNeeded();
return fontFace;
}
@@ -155,8 +155,8 @@
m_backing->addClient(*this);
}
-FontFace::FontFace(CSSFontFace& face)
- : ActiveDOMObject(face.document())
+FontFace::FontFace(ScriptExecutionContext* context, CSSFontFace& face)
+ : ActiveDOMObject(context)
, m_backing(face)
, m_loadedPromise(makeUniqueRef<LoadedPromise>(*this, &FontFace::loadedPromiseResolve))
{
Modified: trunk/Source/WebCore/css/FontFace.h (272726 => 272727)
--- trunk/Source/WebCore/css/FontFace.h 2021-02-11 15:25:20 UTC (rev 272726)
+++ trunk/Source/WebCore/css/FontFace.h 2021-02-11 16:06:08 UTC (rev 272727)
@@ -55,7 +55,7 @@
using Source = Variant<String, RefPtr<JSC::ArrayBuffer>, RefPtr<JSC::ArrayBufferView>>;
static Ref<FontFace> create(Document&, const String& family, Source&&, const Descriptors&);
- static Ref<FontFace> create(CSSFontFace&);
+ static Ref<FontFace> create(ScriptExecutionContext*, CSSFontFace&);
virtual ~FontFace();
ExceptionOr<void> setFamily(Document&, const String&);
@@ -94,7 +94,7 @@
private:
explicit FontFace(CSSFontSelector&);
- explicit FontFace(CSSFontFace&);
+ explicit FontFace(ScriptExecutionContext*, CSSFontFace&);
// ActiveDOMObject.
const char* activeDOMObjectName() const final;
Modified: trunk/Source/WebCore/css/FontFaceSet.cpp (272726 => 272727)
--- trunk/Source/WebCore/css/FontFaceSet.cpp 2021-02-11 15:25:20 UTC (rev 272726)
+++ trunk/Source/WebCore/css/FontFaceSet.cpp 2021-02-11 16:06:08 UTC (rev 272727)
@@ -92,7 +92,7 @@
{
if (m_index == m_target->size())
return nullptr;
- return m_target->backing()[m_index++].wrapper();
+ return m_target->backing()[m_index++].wrapper(m_target->scriptExecutionContext());
}
FontFaceSet::PendingPromise::PendingPromise(LoadPromise&& promise)
@@ -161,7 +161,7 @@
bool waiting = false;
for (auto& face : matchingFaces) {
- pendingPromise->faces.append(face.get().wrapper());
+ pendingPromise->faces.append(face.get().wrapper(scriptExecutionContext()));
if (face.get().status() == CSSFontFace::Status::Success)
continue;
waiting = true;