Title: [272045] trunk/Source/WebCore
Revision
272045
Author
[email protected]
Date
2021-01-28 19:49:06 -0800 (Thu, 28 Jan 2021)

Log Message

Remove some uses of FontSelector from within CSSFontFace
https://bugs.webkit.org/show_bug.cgi?id=221064

Reviewed by Darin Adler.

This is one of the steps toward https://bugs.webkit.org/show_bug.cgi?id=208351 "CSSFontFace should
not need its m_fontSelector data member."

No new tests because there is no behavior change.

* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::CSSFontFace):
(WebCore::CSSFontFace::fontLoadTiming const):
(WebCore::CSSFontFace::allowUserInstalledFonts const): Deleted.
(WebCore::fontLoadTimingOverride): Deleted.
(WebCore::CSSFontFace::shouldIgnoreFontLoadCompletions const): Deleted.
* css/CSSFontFace.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (272044 => 272045)


--- trunk/Source/WebCore/ChangeLog	2021-01-29 03:42:39 UTC (rev 272044)
+++ trunk/Source/WebCore/ChangeLog	2021-01-29 03:49:06 UTC (rev 272045)
@@ -1,3 +1,23 @@
+2021-01-28  Myles C. Maxfield  <[email protected]>
+
+        Remove some uses of FontSelector from within CSSFontFace
+        https://bugs.webkit.org/show_bug.cgi?id=221064
+
+        Reviewed by Darin Adler.
+
+        This is one of the steps toward https://bugs.webkit.org/show_bug.cgi?id=208351 "CSSFontFace should
+        not need its m_fontSelector data member."
+
+        No new tests because there is no behavior change.
+
+        * css/CSSFontFace.cpp:
+        (WebCore::CSSFontFace::CSSFontFace):
+        (WebCore::CSSFontFace::fontLoadTiming const):
+        (WebCore::CSSFontFace::allowUserInstalledFonts const): Deleted.
+        (WebCore::fontLoadTimingOverride): Deleted.
+        (WebCore::CSSFontFace::shouldIgnoreFontLoadCompletions const): Deleted.
+        * css/CSSFontFace.h:
+
 2021-01-28  Jean-Yves Avenard  <[email protected]>
 
         [ Big Sur ] media/media-source/media-source-webm-init-inside-segment.html is failing

Modified: trunk/Source/WebCore/css/CSSFontFace.cpp (272044 => 272045)


--- trunk/Source/WebCore/css/CSSFontFace.cpp	2021-01-29 03:42:39 UTC (rev 272044)
+++ trunk/Source/WebCore/css/CSSFontFace.cpp	2021-01-29 03:49:06 UTC (rev 272045)
@@ -90,11 +90,19 @@
 }
 
 CSSFontFace::CSSFontFace(CSSFontSelector* fontSelector, StyleRuleFontFace* cssConnection, FontFace* wrapper, bool isLocalFallback)
-    : m_fontSelector(makeWeakPtr(fontSelector))
-    , m_cssConnection(cssConnection)
+    : CSSFontFace(fontSelector && fontSelector->document() ? &fontSelector->document()->settings() : nullptr, cssConnection, wrapper, isLocalFallback)
+{
+    m_fontSelector = makeWeakPtr(fontSelector); // FIXME: Ideally this data member would go away (https://bugs.webkit.org/show_bug.cgi?id=208351).
+}
+
+CSSFontFace::CSSFontFace(const Settings* 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_timeoutTimer(*this, &CSSFontFace::timeoutFired)
 {
 }
@@ -452,24 +460,9 @@
     return m_fontSelector ? m_fontSelector->document() : nullptr;
 }
 
-AllowUserInstalledFonts CSSFontFace::allowUserInstalledFonts() const
-{
-    if (m_fontSelector && m_fontSelector->document())
-        return m_fontSelector->document()->settings().shouldAllowUserInstalledFonts() ? AllowUserInstalledFonts::Yes : AllowUserInstalledFonts::No;
-    return AllowUserInstalledFonts::Yes;
-}
-
-static FontLoadTimingOverride fontLoadTimingOverride(CSSFontSelector* fontSelector)
-{
-    auto overrideValue = FontLoadTimingOverride::None;
-    if (fontSelector && fontSelector->document())
-        overrideValue = fontSelector->document()->settings().fontLoadTimingOverride();
-    return overrideValue;
-}
-
 auto CSSFontFace::fontLoadTiming() const -> FontLoadTiming
 {
-    switch (fontLoadTimingOverride(m_fontSelector.get())) {
+    switch (m_fontLoadTimingOverride) {
     case FontLoadTimingOverride::None:
         switch (m_loadingBehavior) {
         case FontLoadingBehavior::Auto:
@@ -559,13 +552,6 @@
     fontLoadEventOccurred();
 }
 
-bool CSSFontFace::shouldIgnoreFontLoadCompletions() const
-{
-    if (m_fontSelector && m_fontSelector->document())
-        return m_fontSelector->document()->settings().shouldIgnoreFontLoadCompletions();
-    return false;
-}
-
 void CSSFontFace::opportunisticallyStartFontDataURLLoading(CSSFontSelector& fontSelector)
 {
     // We don't want to go crazy here and blow the cache. Usually these data URLs are the first item in the src: list, so let's just check that one.

Modified: trunk/Source/WebCore/css/CSSFontFace.h (272044 => 272045)


--- trunk/Source/WebCore/css/CSSFontFace.h	2021-01-29 03:42:39 UTC (rev 272044)
+++ trunk/Source/WebCore/css/CSSFontFace.h	2021-01-29 03:49:06 UTC (rev 272045)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "FontLoadTimingOverride.h"
 #include "FontSelectionValueInlines.h"
 #include "FontTaggedSettings.h"
 #include "StyleRule.h"
@@ -152,11 +153,11 @@
         Seconds swapPeriod;
     };
     FontLoadTiming fontLoadTiming() const;
-    bool shouldIgnoreFontLoadCompletions() const;
+    bool shouldIgnoreFontLoadCompletions() const { return m_shouldIgnoreFontLoadCompletions; }
 
     bool purgeable() const;
 
-    AllowUserInstalledFonts allowUserInstalledFonts() const;
+    AllowUserInstalledFonts allowUserInstalledFonts() const { return m_allowUserInstalledFonts; }
 
     void updateStyleIfNeeded();
 
@@ -167,6 +168,7 @@
 
 private:
     CSSFontFace(CSSFontSelector*, StyleRuleFontFace*, FontFace*, bool isLocalFallback);
+    CSSFontFace(const Settings*, StyleRuleFontFace*, FontFace*, bool isLocalFallback);
 
     size_t pump(ExternalResourceDownloadPolicy);
     void setStatus(Status);
@@ -194,6 +196,9 @@
     bool m_isLocalFallback { false };
     bool m_sourcesPopulated { false };
     bool m_mayBePurged { true };
+    bool m_shouldIgnoreFontLoadCompletions { false };
+    FontLoadTimingOverride m_fontLoadTimingOverride { FontLoadTimingOverride::None };
+    AllowUserInstalledFonts m_allowUserInstalledFonts { AllowUserInstalledFonts::Yes };
 
     Timer m_timeoutTimer;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to