Title: [158903] trunk/Source/WebCore
Revision
158903
Author
[email protected]
Date
2013-11-07 21:24:20 -0800 (Thu, 07 Nov 2013)

Log Message

RenderSVGResource helpers should take RenderStyle by const reference.
<https://webkit.org/b/124029>

Take const RenderStyle& instead of RenderStyle* in a few more places
so we can get rid of some ampersands and assertions.

Reviewed by Anders Carlsson.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (158902 => 158903)


--- trunk/Source/WebCore/ChangeLog	2013-11-08 05:21:32 UTC (rev 158902)
+++ trunk/Source/WebCore/ChangeLog	2013-11-08 05:24:20 UTC (rev 158903)
@@ -1,3 +1,13 @@
+2013-11-07  Andreas Kling  <[email protected]>
+
+        RenderSVGResource helpers should take RenderStyle by const reference.
+        <https://webkit.org/b/124029>
+
+        Take const RenderStyle& instead of RenderStyle* in a few more places
+        so we can get rid of some ampersands and assertions.
+
+        Reviewed by Anders Carlsson.
+
 2013-11-07  Gyuyoung Kim  <[email protected]>
 
         [AX] Generate toAccessibilityTableRow|Column|Cell to detect bad type casts

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResource.cpp (158902 => 158903)


--- trunk/Source/WebCore/rendering/svg/RenderSVGResource.cpp	2013-11-08 05:21:32 UTC (rev 158902)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResource.cpp	2013-11-08 05:24:20 UTC (rev 158903)
@@ -50,16 +50,13 @@
     return true;
 }
 
-static inline RenderSVGResource* requestPaintingResource(RenderSVGResourceMode mode, RenderElement& object, const RenderStyle* style, Color& fallbackColor)
+static inline RenderSVGResource* requestPaintingResource(RenderSVGResourceMode mode, RenderElement& renderer, const RenderStyle& style, Color& fallbackColor)
 {
-    ASSERT(style);
+    const SVGRenderStyle& svgStyle = style.svgStyle();
 
-    // If we have no style at all, ignore it.
-    const SVGRenderStyle& svgStyle = style->svgStyle();
+    bool isRenderingMask = renderer.view().frameView().paintBehavior() & PaintBehaviorRenderingSVGMask;
 
-    bool isRenderingMask = object.view().frameView().paintBehavior() & PaintBehaviorRenderingSVGMask;
-
-    // If we have no fill/stroke, return 0.
+    // If we have no fill/stroke, return nullptr.
     if (mode == ApplyToFillMode) {
         // When rendering the mask for a RenderSVGResourceClipper, always use the initial fill paint server, and ignore stroke.
         if (isRenderingMask) {
@@ -69,16 +66,16 @@
         }
 
         if (!svgStyle.hasFill())
-            return 0;
+            return nullptr;
     } else {
         if (!svgStyle.hasStroke() || isRenderingMask)
-            return 0;
+            return nullptr;
     }
 
     bool applyToFill = mode == ApplyToFillMode;
     SVGPaint::SVGPaintType paintType = applyToFill ? svgStyle.fillPaintType() : svgStyle.strokePaintType();
     if (paintType == SVGPaint::SVG_PAINTTYPE_NONE)
-        return 0;
+        return nullptr;
 
     Color color;
     switch (paintType) {
@@ -93,7 +90,7 @@
         break;
     }
 
-    if (style->insideLink() == InsideVisitedLink) {
+    if (style.insideLink() == InsideVisitedLink) {
         // FIXME: This code doesn't support the uri component of the visited link paint, https://bugs.webkit.org/show_bug.cgi?id=70006
         SVGPaint::SVGPaintType visitedPaintType = applyToFill ? svgStyle.visitedLinkFillPaintType() : svgStyle.visitedLinkStrokePaintType();
 
@@ -108,18 +105,18 @@
     // If the primary resource is just a color, return immediately.
     RenderSVGResourceSolidColor* colorResource = RenderSVGResource::sharedSolidPaintingResource();
     if (paintType < SVGPaint::SVG_PAINTTYPE_URI_NONE) {
-        if (!inheritColorFromParentStyleIfNeeded(object, applyToFill, color))
-            return 0;
+        if (!inheritColorFromParentStyleIfNeeded(renderer, applyToFill, color))
+            return nullptr;
 
         colorResource->setColor(color);
         return colorResource;
     }
 
     // If no resources are associated with the given renderer, return the color resource.
-    SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(&object);
+    SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(&renderer);
     if (!resources) {
-        if (paintType == SVGPaint::SVG_PAINTTYPE_URI_NONE || !inheritColorFromParentStyleIfNeeded(object, applyToFill, color))
-            return 0;
+        if (paintType == SVGPaint::SVG_PAINTTYPE_URI_NONE || !inheritColorFromParentStyleIfNeeded(renderer, applyToFill, color))
+            return nullptr;
 
         colorResource->setColor(color);
         return colorResource;
@@ -128,8 +125,8 @@
     // If the requested resource is not available, return the color resource.
     RenderSVGResource* uriResource = mode == ApplyToFillMode ? resources->fill() : resources->stroke();
     if (!uriResource) {
-        if (!inheritColorFromParentStyleIfNeeded(object, applyToFill, color))
-            return 0;
+        if (!inheritColorFromParentStyleIfNeeded(renderer, applyToFill, color))
+            return nullptr;
 
         colorResource->setColor(color);
         return colorResource;
@@ -141,14 +138,14 @@
     return uriResource;
 }
 
-RenderSVGResource* RenderSVGResource::fillPaintingResource(RenderElement& object, const RenderStyle* style, Color& fallbackColor)
+RenderSVGResource* RenderSVGResource::fillPaintingResource(RenderElement& renderer, const RenderStyle& style, Color& fallbackColor)
 {
-    return requestPaintingResource(ApplyToFillMode, object, style, fallbackColor);
+    return requestPaintingResource(ApplyToFillMode, renderer, style, fallbackColor);
 }
 
-RenderSVGResource* RenderSVGResource::strokePaintingResource(RenderElement& object, const RenderStyle* style, Color& fallbackColor)
+RenderSVGResource* RenderSVGResource::strokePaintingResource(RenderElement& renderer, const RenderStyle& style, Color& fallbackColor)
 {
-    return requestPaintingResource(ApplyToStrokeMode, object, style, fallbackColor);
+    return requestPaintingResource(ApplyToStrokeMode, renderer, style, fallbackColor);
 }
 
 RenderSVGResourceSolidColor* RenderSVGResource::sharedSolidPaintingResource()

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResource.h (158902 => 158903)


--- trunk/Source/WebCore/rendering/svg/RenderSVGResource.h	2013-11-08 05:21:32 UTC (rev 158902)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResource.h	2013-11-08 05:24:20 UTC (rev 158903)
@@ -78,8 +78,8 @@
     }
 
     // Helper utilities used in the render tree to access resources used for painting shapes/text (gradients & patterns & solid colors only)
-    static RenderSVGResource* fillPaintingResource(RenderElement&, const RenderStyle*, Color& fallbackColor);
-    static RenderSVGResource* strokePaintingResource(RenderElement&, const RenderStyle*, Color& fallbackColor);
+    static RenderSVGResource* fillPaintingResource(RenderElement&, const RenderStyle&, Color& fallbackColor);
+    static RenderSVGResource* strokePaintingResource(RenderElement&, const RenderStyle&, Color& fallbackColor);
     static RenderSVGResourceSolidColor* sharedSolidPaintingResource();
 
     static void markForLayoutAndParentResourceInvalidation(RenderObject*, bool needsLayout = true);

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp (158902 => 158903)


--- trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp	2013-11-08 05:21:32 UTC (rev 158902)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGShape.cpp	2013-11-08 05:24:20 UTC (rev 158903)
@@ -140,7 +140,7 @@
         return false;
 
     Color fallbackColor;
-    if (requiresFill && !RenderSVGResource::fillPaintingResource(*this, &style(), fallbackColor))
+    if (requiresFill && !RenderSVGResource::fillPaintingResource(*this, style(), fallbackColor))
         return false;
 
     return shapeDependentFillContains(point, fillRule);
@@ -152,7 +152,7 @@
         return false;
 
     Color fallbackColor;
-    if (requiresStroke && !RenderSVGResource::strokePaintingResource(*this, &style(), fallbackColor))
+    if (requiresStroke && !RenderSVGResource::strokePaintingResource(*this, style(), fallbackColor))
         return false;
 
     return shapeDependentStrokeContains(point);
@@ -231,31 +231,31 @@
     return resources->markerStart() || resources->markerMid() || resources->markerEnd();
 }
 
-void RenderSVGShape::fillShape(RenderStyle* style, GraphicsContext* context)
+void RenderSVGShape::fillShape(const RenderStyle& style, GraphicsContext* context)
 {
     Color fallbackColor;
     if (RenderSVGResource* fillPaintingResource = RenderSVGResource::fillPaintingResource(*this, style, fallbackColor)) {
-        if (fillPaintingResource->applyResource(*this, *style, context, ApplyToFillMode))
+        if (fillPaintingResource->applyResource(*this, style, context, ApplyToFillMode))
             fillPaintingResource->postApplyResource(*this, context, ApplyToFillMode, 0, this);
         else if (fallbackColor.isValid()) {
             RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::sharedSolidPaintingResource();
             fallbackResource->setColor(fallbackColor);
-            if (fallbackResource->applyResource(*this, *style, context, ApplyToFillMode))
+            if (fallbackResource->applyResource(*this, style, context, ApplyToFillMode))
                 fallbackResource->postApplyResource(*this, context, ApplyToFillMode, 0, this);
         }
     }
 }
 
-void RenderSVGShape::strokeShape(RenderStyle* style, GraphicsContext* context)
+void RenderSVGShape::strokeShape(const RenderStyle& style, GraphicsContext* context)
 {
     Color fallbackColor;
     if (RenderSVGResource* strokePaintingResource = RenderSVGResource::strokePaintingResource(*this, style, fallbackColor)) {
-        if (strokePaintingResource->applyResource(*this, *style, context, ApplyToStrokeMode))
+        if (strokePaintingResource->applyResource(*this, style, context, ApplyToStrokeMode))
             strokePaintingResource->postApplyResource(*this, context, ApplyToStrokeMode, 0, this);
         else if (fallbackColor.isValid()) {
             RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::sharedSolidPaintingResource();
             fallbackResource->setColor(fallbackColor);
-            if (fallbackResource->applyResource(*this, *style, context, ApplyToStrokeMode))
+            if (fallbackResource->applyResource(*this, style, context, ApplyToStrokeMode))
                 fallbackResource->postApplyResource(*this, context, ApplyToStrokeMode, 0, this);
         }
     }
@@ -263,11 +263,9 @@
 
 void RenderSVGShape::fillAndStrokeShape(GraphicsContext* context)
 {
-    RenderStyle& style = this->style();
+    fillShape(style(), context);
 
-    fillShape(&style, context);
-
-    if (!style.svgStyle().hasVisibleStroke())
+    if (!style().svgStyle().hasVisibleStroke())
         return;
 
     GraphicsContextStateSaver stateSaver(*context, false);
@@ -278,7 +276,7 @@
             return;
     }
 
-    strokeShape(&style, context);
+    strokeShape(style(), context);
 }
 
 void RenderSVGShape::paint(PaintInfo& paintInfo, const LayoutPoint&)

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGShape.h (158902 => 158903)


--- trunk/Source/WebCore/rendering/svg/RenderSVGShape.h	2013-11-08 05:21:32 UTC (rev 158902)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGShape.h	2013-11-08 05:24:20 UTC (rev 158903)
@@ -115,8 +115,8 @@
     FloatRect markerRect(float strokeWidth) const;
     void processMarkerPositions();
 
-    void fillShape(RenderStyle*, GraphicsContext*);
-    void strokeShape(RenderStyle*, GraphicsContext*);
+    void fillShape(const RenderStyle&, GraphicsContext*);
+    void strokeShape(const RenderStyle&, GraphicsContext*);
     void fillAndStrokeShape(GraphicsContext*);
     void drawMarkers(PaintInfo&);
 

Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp (158902 => 158903)


--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp	2013-11-08 05:21:32 UTC (rev 158902)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp	2013-11-08 05:24:20 UTC (rev 158903)
@@ -331,9 +331,9 @@
 
     Color fallbackColor;
     if (m_paintingResourceMode & ApplyToFillMode)
-        m_paintingResource = RenderSVGResource::fillPaintingResource(renderer, style, fallbackColor);
+        m_paintingResource = RenderSVGResource::fillPaintingResource(renderer, *style, fallbackColor);
     else if (m_paintingResourceMode & ApplyToStrokeMode)
-        m_paintingResource = RenderSVGResource::strokePaintingResource(renderer, style, fallbackColor);
+        m_paintingResource = RenderSVGResource::strokePaintingResource(renderer, *style, fallbackColor);
     else {
         // We're either called for stroking or filling.
         ASSERT_NOT_REACHED();

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp (158902 => 158903)


--- trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp	2013-11-08 05:21:32 UTC (rev 158902)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp	2013-11-08 05:24:20 UTC (rev 158903)
@@ -276,7 +276,7 @@
         const RenderSVGShape& shape = static_cast<const RenderSVGShape&>(object);
 
         Color fallbackColor;
-        if (RenderSVGResource* strokePaintingResource = RenderSVGResource::strokePaintingResource(const_cast<RenderSVGShape&>(shape), &shape.style(), fallbackColor)) {
+        if (RenderSVGResource* strokePaintingResource = RenderSVGResource::strokePaintingResource(const_cast<RenderSVGShape&>(shape), shape.style(), fallbackColor)) {
             TextStreamSeparator s(" ");
             ts << " [stroke={" << s;
             writeSVGPaintingResource(ts, strokePaintingResource);
@@ -303,7 +303,7 @@
             ts << "}]";
         }
 
-        if (RenderSVGResource* fillPaintingResource = RenderSVGResource::fillPaintingResource(const_cast<RenderSVGShape&>(shape), &shape.style(), fallbackColor)) {
+        if (RenderSVGResource* fillPaintingResource = RenderSVGResource::fillPaintingResource(const_cast<RenderSVGShape&>(shape), shape.style(), fallbackColor)) {
             TextStreamSeparator s(" ");
             ts << " [fill={" << s;
             writeSVGPaintingResource(ts, fillPaintingResource);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to