Title: [278466] trunk/Source/WebCore
Revision
278466
Author
mmaxfi...@apple.com
Date
2021-06-04 09:34:16 -0700 (Fri, 04 Jun 2021)

Log Message

Use references in font loading code instead of pointers which can never be null
https://bugs.webkit.org/show_bug.cgi?id=226622

Reviewed by Chris Dumez.

CSSFontFace::create()'s CSSFontSelector can never be null. This is clear from
observation of all 3 call sites.

No new tests because there is no behavior change.

* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::create):
* css/CSSFontFace.h:
* css/CSSFontFaceSet.cpp:
(WebCore::CSSFontFaceSet::ensureLocalFontFacesForFamilyRegistered):
* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::addFontFaceRule):
* css/FontFace.cpp:
(WebCore::FontFace::FontFace):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (278465 => 278466)


--- trunk/Source/WebCore/ChangeLog	2021-06-04 16:32:57 UTC (rev 278465)
+++ trunk/Source/WebCore/ChangeLog	2021-06-04 16:34:16 UTC (rev 278466)
@@ -1,3 +1,25 @@
+2021-06-04  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Use references in font loading code instead of pointers which can never be null
+        https://bugs.webkit.org/show_bug.cgi?id=226622
+
+        Reviewed by Chris Dumez.
+
+        CSSFontFace::create()'s CSSFontSelector can never be null. This is clear from
+        observation of all 3 call sites.
+
+        No new tests because there is no behavior change.
+
+        * css/CSSFontFace.cpp:
+        (WebCore::CSSFontFace::create):
+        * css/CSSFontFace.h:
+        * css/CSSFontFaceSet.cpp:
+        (WebCore::CSSFontFaceSet::ensureLocalFontFacesForFamilyRegistered):
+        * css/CSSFontSelector.cpp:
+        (WebCore::CSSFontSelector::addFontFaceRule):
+        * css/FontFace.cpp:
+        (WebCore::FontFace::FontFace):
+
 2021-06-04  David Kilzer  <ddkil...@apple.com>
 
         REGRESSION (r278121): Fix build failure due to weak external symbol

Modified: trunk/Source/WebCore/css/CSSFontFace.cpp (278465 => 278466)


--- trunk/Source/WebCore/css/CSSFontFace.cpp	2021-06-04 16:32:57 UTC (rev 278465)
+++ trunk/Source/WebCore/css/CSSFontFace.cpp	2021-06-04 16:34:16 UTC (rev 278466)
@@ -90,13 +90,12 @@
     fontFace.sourcesPopulated();
 }
 
-Ref<CSSFontFace> CSSFontFace::create(CSSFontSelector* fontSelector, StyleRuleFontFace* cssConnection, FontFace* wrapper, bool isLocalFallback)
+Ref<CSSFontFace> CSSFontFace::create(CSSFontSelector& fontSelector, StyleRuleFontFace* cssConnection, FontFace* wrapper, bool isLocalFallback)
 {
-    auto* context = fontSelector ? fontSelector->scriptExecutionContext() : nullptr;
+    auto* context = fontSelector.scriptExecutionContext();
     const auto* settings = context ? &context->settingsValues() : nullptr;
     auto result = adoptRef(*new CSSFontFace(settings, cssConnection, wrapper, isLocalFallback));
-    if (fontSelector)
-        result->addClient(*fontSelector);
+    result->addClient(fontSelector);
     return result;
 }
 

Modified: trunk/Source/WebCore/css/CSSFontFace.h (278465 => 278466)


--- trunk/Source/WebCore/css/CSSFontFace.h	2021-06-04 16:32:57 UTC (rev 278465)
+++ trunk/Source/WebCore/css/CSSFontFace.h	2021-06-04 16:34:16 UTC (rev 278466)
@@ -57,7 +57,7 @@
 class CSSFontFace final : public RefCounted<CSSFontFace> {
     WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(CSSFontFace);
 public:
-    static Ref<CSSFontFace> create(CSSFontSelector*, StyleRuleFontFace* cssConnection = nullptr, FontFace* wrapper = nullptr, bool isLocalFallback = false);
+    static Ref<CSSFontFace> create(CSSFontSelector&, StyleRuleFontFace* cssConnection = nullptr, FontFace* wrapper = nullptr, bool isLocalFallback = false);
     virtual ~CSSFontFace();
 
     // FIXME: These functions don't need to have boolean return values.

Modified: trunk/Source/WebCore/css/CSSFontFaceSet.cpp (278465 => 278466)


--- trunk/Source/WebCore/css/CSSFontFaceSet.cpp	2021-06-04 16:32:57 UTC (rev 278465)
+++ trunk/Source/WebCore/css/CSSFontFaceSet.cpp	2021-06-04 16:34:16 UTC (rev 278466)
@@ -118,7 +118,7 @@
 
     Vector<Ref<CSSFontFace>> faces;
     for (auto item : capabilities) {
-        Ref<CSSFontFace> face = CSSFontFace::create(m_owningFontSelector.get(), nullptr, nullptr, true);
+        auto face = CSSFontFace::create(*m_owningFontSelector, nullptr, nullptr, true);
         
         Ref<CSSValueList> familyList = CSSValueList::createCommaSeparated();
         familyList->append(m_owningFontSelector->scriptExecutionContext()->cssValuePool().createFontFamilyValue(familyName));

Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (278465 => 278466)


--- trunk/Source/WebCore/css/CSSFontSelector.cpp	2021-06-04 16:32:57 UTC (rev 278465)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp	2021-06-04 16:34:16 UTC (rev 278466)
@@ -190,7 +190,7 @@
         return;
 
     SetForScope<bool> creatingFont(m_creatingFont, true);
-    Ref<CSSFontFace> fontFace = CSSFontFace::create(this, &fontFaceRule);
+    auto fontFace = CSSFontFace::create(*this, &fontFaceRule);
 
     if (!fontFace->setFamilies(*fontFamily))
         return;

Modified: trunk/Source/WebCore/css/FontFace.cpp (278465 => 278466)


--- trunk/Source/WebCore/css/FontFace.cpp	2021-06-04 16:32:57 UTC (rev 278465)
+++ trunk/Source/WebCore/css/FontFace.cpp	2021-06-04 16:34:16 UTC (rev 278466)
@@ -151,7 +151,7 @@
 
 FontFace::FontFace(CSSFontSelector& fontSelector)
     : ActiveDOMObject(fontSelector.scriptExecutionContext())
-    , m_backing(CSSFontFace::create(&fontSelector, nullptr, this))
+    , m_backing(CSSFontFace::create(fontSelector, nullptr, this))
     , m_loadedPromise(makeUniqueRef<LoadedPromise>(*this, &FontFace::loadedPromiseResolve))
 {
     m_backing->addClient(*this);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to