[StyleResolver] Pass RenderStyle& instead of RenderStyle* to updateFont() related...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Jun 2019 19:37:59 +0000 (19:37 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Jun 2019 19:37:59 +0000 (19:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199167
<rdar://problem/52062669>

Reviewed by Antti Koivisto.

It is expected to have a valid RenderStyle object here (and existing code relies on it).

* css/StyleResolver.cpp:
(WebCore::checkForOrientationChange):
(WebCore::StyleResolver::updateFont):
(WebCore::StyleResolver::checkForTextSizeAdjust):
(WebCore::StyleResolver::checkForZoomChange):
(WebCore::StyleResolver::checkForGenericFamilyChange):
* css/StyleResolver.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@246755 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h

index 8f2a1e8..53011ec 100644 (file)
@@ -1,3 +1,21 @@
+2019-06-24  Zalan Bujtas  <zalan@apple.com>
+
+        [StyleResolver] Pass RenderStyle& instead of RenderStyle* to updateFont() related functions.
+        https://bugs.webkit.org/show_bug.cgi?id=199167
+        <rdar://problem/52062669>
+
+        Reviewed by Antti Koivisto.
+
+        It is expected to have a valid RenderStyle object here (and existing code relies on it).
+
+        * css/StyleResolver.cpp:
+        (WebCore::checkForOrientationChange):
+        (WebCore::StyleResolver::updateFont):
+        (WebCore::StyleResolver::checkForTextSizeAdjust):
+        (WebCore::StyleResolver::checkForZoomChange):
+        (WebCore::StyleResolver::checkForGenericFamilyChange):
+        * css/StyleResolver.h:
+
 2019-06-24  Antoine Quint  <graouts@apple.com>
 
         [Pointer Events WPT] Unskip imported/w3c/web-platform-tests/pointerevents/pointerevent_lostpointercapture_is_first.html
index 6441004..0248790 100644 (file)
@@ -1174,20 +1174,20 @@ void StyleResolver::adjustRenderStyleForSiteSpecificQuirks(RenderStyle& style, c
     }
 }
 
-static void checkForOrientationChange(RenderStyle* style)
+static void checkForOrientationChange(RenderStyle& style)
 {
     FontOrientation fontOrientation;
     NonCJKGlyphOrientation glyphOrientation;
-    std::tie(fontOrientation, glyphOrientation) = style->fontAndGlyphOrientation();
+    std::tie(fontOrientation, glyphOrientation) = style.fontAndGlyphOrientation();
 
-    const auto& fontDescription = style->fontDescription();
+    const auto& fontDescription = style.fontDescription();
     if (fontDescription.orientation() == fontOrientation && fontDescription.nonCJKGlyphOrientation() == glyphOrientation)
         return;
 
     auto newFontDescription = fontDescription;
     newFontDescription.setNonCJKGlyphOrientation(glyphOrientation);
     newFontDescription.setOrientation(fontOrientation);
-    style->setFontDescription(WTFMove(newFontDescription));
+    style.setFontDescription(WTFMove(newFontDescription));
 }
 
 void StyleResolver::updateFont()
@@ -1195,16 +1195,16 @@ void StyleResolver::updateFont()
     if (!m_state.fontDirty())
         return;
 
-    RenderStyle* style = m_state.style();
+    auto& style = *m_state.style();
 #if ENABLE(TEXT_AUTOSIZING)
     checkForTextSizeAdjust(style);
 #endif
     checkForGenericFamilyChange(style, m_state.parentStyle());
     checkForZoomChange(style, m_state.parentStyle());
     checkForOrientationChange(style);
-    style->fontCascade().update(&document().fontSelector());
+    style.fontCascade().update(&document().fontSelector());
     if (m_state.fontSizeHasViewportUnits())
-        style->setHasViewportUnits(true);
+        style.setHasViewportUnits(true);
     m_state.setFontDirty(false);
 }
 
@@ -1848,38 +1848,37 @@ RefPtr<StyleImage> StyleResolver::styleImage(CSSValue& value)
 }
 
 #if ENABLE(TEXT_AUTOSIZING)
-void StyleResolver::checkForTextSizeAdjust(RenderStyle* style)
+void StyleResolver::checkForTextSizeAdjust(RenderStyle& style)
 {
-    ASSERT(style);
-    if (style->textSizeAdjust().isAuto() || (settings().textAutosizingUsesIdempotentMode() && !style->textSizeAdjust().isNone()))
+    if (style.textSizeAdjust().isAuto() || (settings().textAutosizingUsesIdempotentMode() && !style.textSizeAdjust().isNone()))
         return;
 
-    auto newFontDescription = style->fontDescription();
-    if (!style->textSizeAdjust().isNone())
-        newFontDescription.setComputedSize(newFontDescription.specifiedSize() * style->textSizeAdjust().multiplier());
+    auto newFontDescription = style.fontDescription();
+    if (!style.textSizeAdjust().isNone())
+        newFontDescription.setComputedSize(newFontDescription.specifiedSize() * style.textSizeAdjust().multiplier());
     else
         newFontDescription.setComputedSize(newFontDescription.specifiedSize());
-    style->setFontDescription(WTFMove(newFontDescription));
+    style.setFontDescription(WTFMove(newFontDescription));
 }
 #endif
 
-void StyleResolver::checkForZoomChange(RenderStyle* style, const RenderStyle* parentStyle)
+void StyleResolver::checkForZoomChange(RenderStyle& style, const RenderStyle* parentStyle)
 {
     if (!parentStyle)
         return;
 
-    if (style->effectiveZoom() == parentStyle->effectiveZoom() && style->textZoom() == parentStyle->textZoom())
+    if (style.effectiveZoom() == parentStyle->effectiveZoom() && style.textZoom() == parentStyle->textZoom())
         return;
 
-    const auto& childFont = style->fontDescription();
+    const auto& childFont = style.fontDescription();
     auto newFontDescription = childFont;
     setFontSize(newFontDescription, childFont.specifiedSize());
-    style->setFontDescription(WTFMove(newFontDescription));
+    style.setFontDescription(WTFMove(newFontDescription));
 }
 
-void StyleResolver::checkForGenericFamilyChange(RenderStyle* style, const RenderStyle* parentStyle)
+void StyleResolver::checkForGenericFamilyChange(RenderStyle& style, const RenderStyle* parentStyle)
 {
-    const auto& childFont = style->fontDescription();
+    const auto& childFont = style.fontDescription();
 
     if (childFont.isAbsoluteSize() || !parentStyle)
         return;
@@ -1905,7 +1904,7 @@ void StyleResolver::checkForGenericFamilyChange(RenderStyle* style, const Render
 
     auto newFontDescription = childFont;
     setFontSize(newFontDescription, size);
-    style->setFontDescription(WTFMove(newFontDescription));
+    style.setFontDescription(WTFMove(newFontDescription));
 }
 
 void StyleResolver::initializeFontStyle()
index 01bb8fb..8c88da8 100644 (file)
@@ -312,10 +312,10 @@ public:
 
 private:
     // This function fixes up the default font size if it detects that the current generic font family has changed. -dwh
-    void checkForGenericFamilyChange(RenderStyle*, const RenderStyle* parentStyle);
-    void checkForZoomChange(RenderStyle*, const RenderStyle* parentStyle);
+    void checkForGenericFamilyChange(RenderStyle&, const RenderStyle* parentStyle);
+    void checkForZoomChange(RenderStyle&, const RenderStyle* parentStyle);
 #if ENABLE(TEXT_AUTOSIZING)
-    void checkForTextSizeAdjust(RenderStyle*);
+    void checkForTextSizeAdjust(RenderStyle&);
 #endif
 
     void adjustRenderStyle(RenderStyle&, const RenderStyle& parentStyle, const RenderStyle* parentBoxStyle, const Element*);