SVG: applyStrokeStyleToContext should take a RenderElement&.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Oct 2013 17:17:22 +0000 (17:17 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Oct 2013 17:17:22 +0000 (17:17 +0000)
<https://webkit.org/b/123447>

..and a RenderStyle& too, for that matter.

Reviewed by Anders Carlsson.

* rendering/svg/SVGRenderSupport.h:
* rendering/svg/SVGRenderSupport.cpp:
(WebCore::SVGRenderSupport::applyStrokeStyleToContext):

    Have this take a RenderElement& and RenderStyle& instead of
    raw pointers. Tweaked a silly-looking loop.

* rendering/svg/RenderSVGShape.h:
* rendering/svg/RenderSVGShape.cpp:

    Moved BoundingRectStrokeStyleApplier helper class into the
    cpp file since it wasn't being used anywhere else.

* rendering/svg/RenderSVGResourceGradient.cpp:
(WebCore::RenderSVGResourceGradient::applyResource):
* rendering/svg/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::applyResource):
* rendering/svg/RenderSVGResourceSolidColor.cpp:
(WebCore::RenderSVGResourceSolidColor::applyResource):

    Remove ampersands.

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

Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp
Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp
Source/WebCore/rendering/svg/RenderSVGResourceSolidColor.cpp
Source/WebCore/rendering/svg/RenderSVGShape.cpp
Source/WebCore/rendering/svg/RenderSVGShape.h
Source/WebCore/rendering/svg/SVGRenderSupport.cpp
Source/WebCore/rendering/svg/SVGRenderSupport.h

index 7135c3b..43cd426 100644 (file)
@@ -1,3 +1,34 @@
+2013-10-29  Andreas Kling  <akling@apple.com>
+
+        SVG: applyStrokeStyleToContext should take a RenderElement&.
+        <https://webkit.org/b/123447>
+
+        ..and a RenderStyle& too, for that matter.
+
+        Reviewed by Anders Carlsson.
+
+        * rendering/svg/SVGRenderSupport.h:
+        * rendering/svg/SVGRenderSupport.cpp:
+        (WebCore::SVGRenderSupport::applyStrokeStyleToContext):
+
+            Have this take a RenderElement& and RenderStyle& instead of
+            raw pointers. Tweaked a silly-looking loop.
+
+        * rendering/svg/RenderSVGShape.h:
+        * rendering/svg/RenderSVGShape.cpp:
+
+            Moved BoundingRectStrokeStyleApplier helper class into the
+            cpp file since it wasn't being used anywhere else.
+
+        * rendering/svg/RenderSVGResourceGradient.cpp:
+        (WebCore::RenderSVGResourceGradient::applyResource):
+        * rendering/svg/RenderSVGResourcePattern.cpp:
+        (WebCore::RenderSVGResourcePattern::applyResource):
+        * rendering/svg/RenderSVGResourceSolidColor.cpp:
+        (WebCore::RenderSVGResourceSolidColor::applyResource):
+
+            Remove ampersands.
+
 2013-10-29  Antti Koivisto  <antti@apple.com>
 
         Multiple runs per line on simple line path
index 704666f..fef74e5 100644 (file)
@@ -198,7 +198,7 @@ bool RenderSVGResourceGradient::applyResource(RenderElement& renderer, const Ren
             gradientData->gradient->setGradientSpaceTransform(transformOnNonScalingStroke(&renderer, gradientData->userspaceTransform));
         context->setAlpha(svgStyle->strokeOpacity());
         context->setStrokeGradient(gradientData->gradient);
-        SVGRenderSupport::applyStrokeStyleToContext(context, &style, &renderer);
+        SVGRenderSupport::applyStrokeStyleToContext(context, style, renderer);
     }
 
     return true;
index 60ccb48..5fb046a 100644 (file)
@@ -167,7 +167,7 @@ bool RenderSVGResourcePattern::applyResource(RenderElement& renderer, const Rend
             patternData->pattern->setPatternSpaceTransform(transformOnNonScalingStroke(&renderer, patternData->transform));
         context->setAlpha(svgStyle->strokeOpacity());
         context->setStrokePattern(patternData->pattern);
-        SVGRenderSupport::applyStrokeStyleToContext(context, &style, &renderer);
+        SVGRenderSupport::applyStrokeStyleToContext(context, style, renderer);
     }
 
     if (resourceMode & ApplyToTextMode) {
index 700a6af..f1d9deb 100644 (file)
@@ -69,7 +69,7 @@ bool RenderSVGResourceSolidColor::applyResource(RenderElement& renderer, const R
         context->setAlpha(svgStyle ? svgStyle->strokeOpacity() : 1);
         context->setStrokeColor(m_color, colorSpace);
 
-        SVGRenderSupport::applyStrokeStyleToContext(context, &style, &renderer);
+        SVGRenderSupport::applyStrokeStyleToContext(context, style, renderer);
 
         if (resourceMode & ApplyToTextMode)
             context->setTextDrawingMode(TextModeStroke);
index 26817ed..d46e0af 100644 (file)
 
 namespace WebCore {
 
+class BoundingRectStrokeStyleApplier FINAL : public StrokeStyleApplier {
+public:
+    BoundingRectStrokeStyleApplier(const RenderSVGShape& renderer)
+        : m_renderer(renderer)
+    {
+    }
+
+    virtual void strokeStyle(GraphicsContext* context) OVERRIDE
+    {
+        SVGRenderSupport::applyStrokeStyleToContext(context, m_renderer.style(), m_renderer);
+    }
+
+private:
+    const RenderSVGShape& m_renderer;
+};
+
 RenderSVGShape::RenderSVGShape(SVGGraphicsElement& element, PassRef<RenderStyle> style)
     : RenderSVGModelObject(element, std::move(style))
     , m_needsBoundariesUpdate(false) // Default is false, the cached rects are empty from the beginning.
@@ -101,7 +117,7 @@ void RenderSVGShape::strokeShape(GraphicsContext* context) const
 bool RenderSVGShape::shapeDependentStrokeContains(const FloatPoint& point)
 {
     ASSERT(m_path);
-    BoundingRectStrokeStyleApplier applier(this, &style());
+    BoundingRectStrokeStyleApplier applier(*this);
 
     if (hasNonScalingStroke()) {
         AffineTransform nonScalingTransform = nonScalingStrokeTransform();
@@ -382,7 +398,7 @@ FloatRect RenderSVGShape::calculateStrokeBoundingBox() const
 
     const SVGRenderStyle* svgStyle = style().svgStyle();
     if (svgStyle->hasStroke()) {
-        BoundingRectStrokeStyleApplier strokeStyle(this, &style());
+        BoundingRectStrokeStyleApplier strokeStyle(*this);
         if (hasNonScalingStroke()) {
             AffineTransform nonScalingTransform = nonScalingStrokeTransform();
             if (nonScalingTransform.isInvertible()) {
index b7057bc..e77c2e5 100644 (file)
@@ -32,7 +32,6 @@
 #include "RenderSVGModelObject.h"
 #include "SVGGraphicsElement.h"
 #include "SVGMarkerData.h"
-#include "StrokeStyleApplier.h"
 #include <wtf/OwnPtr.h>
 #include <wtf/Vector.h>
 
@@ -45,26 +44,6 @@ class RenderSVGPath;
 class RenderSVGResource;
 class SVGGraphicsElement;
 
-class BoundingRectStrokeStyleApplier : public StrokeStyleApplier {
-public:
-    BoundingRectStrokeStyleApplier(const RenderObject* object, RenderStyle* style)
-        : m_object(object)
-        , m_style(style)
-    {
-        ASSERT(style);
-        ASSERT(object);
-    }
-
-    virtual void strokeStyle(GraphicsContext* context) OVERRIDE
-    {
-        SVGRenderSupport::applyStrokeStyleToContext(context, m_style, m_object);
-    }
-
-private:
-    const RenderObject* m_object;
-    RenderStyle* m_style;
-};
-
 class RenderSVGShape : public RenderSVGModelObject {
 public:
     RenderSVGShape(SVGGraphicsElement&, PassRef<RenderStyle>);
index 0a3cdc0..0b2120e 100644 (file)
@@ -417,18 +417,16 @@ bool SVGRenderSupport::pointInClippingArea(RenderObject* object, const FloatPoin
     return true;
 }
 
-void SVGRenderSupport::applyStrokeStyleToContext(GraphicsContext* context, const RenderStyle* style, const RenderObject* object)
+void SVGRenderSupport::applyStrokeStyleToContext(GraphicsContext* context, const RenderStyle& style, const RenderElement& renderer)
 {
     ASSERT(context);
-    ASSERT(style);
-    ASSERT(object);
-    ASSERT(object->node());
-    ASSERT(object->node()->isSVGElement());
+    ASSERT(renderer.element());
+    ASSERT(renderer.element()->isSVGElement());
 
-    const SVGRenderStyle* svgStyle = style->svgStyle();
+    const SVGRenderStyle* svgStyle = style.svgStyle();
     ASSERT(svgStyle);
 
-    SVGLengthContext lengthContext(toSVGElement(object->node()));
+    SVGLengthContext lengthContext(toSVGElement(renderer.element()));
     context->setStrokeThickness(svgStyle->strokeWidth().value(lengthContext));
     context->setLineCap(svgStyle->capStyle());
     context->setLineJoin(svgStyle->joinStyle());
@@ -440,9 +438,9 @@ void SVGRenderSupport::applyStrokeStyleToContext(GraphicsContext* context, const
         context->setStrokeStyle(SolidStroke);
     else {
         DashArray dashArray;
-        const Vector<SVGLength>::const_iterator end = dashes.end();
-        for (Vector<SVGLength>::const_iterator it = dashes.begin(); it != end; ++it)
-            dashArray.append((*it).value(lengthContext));
+        dashArray.reserveInitialCapacity(dashes.size());
+        for (unsigned i = 0, size = dashes.size(); i < size; ++i)
+            dashArray.uncheckedAppend(dashes[i].value(lengthContext));
 
         context->setLineDash(dashArray, svgStyle->strokeDashOffset().value(lengthContext));
     }
index 7a4c115..8d26441 100644 (file)
@@ -74,7 +74,7 @@ public:
     static bool checkForSVGRepaintDuringLayout(RenderObject*);
 
     // Shared between SVG renderers and resources.
-    static void applyStrokeStyleToContext(GraphicsContext*, const RenderStyle*, const RenderObject*);
+    static void applyStrokeStyleToContext(GraphicsContext*, const RenderStyle&, const RenderElement&);
 
     // Determines if any ancestor's transform has changed.
     static bool transformToRootChanged(RenderObject*);