Title: [163319] trunk/Source/WebCore
Revision
163319
Author
akl...@apple.com
Date
2014-02-03 12:26:09 -0800 (Mon, 03 Feb 2014)

Log Message

CTTE: RenderSVGGradientStop always has a SVGStopElement.
<https://webkit.org/b/128107>

RenderSVGGradientStop is never anonymous and always has a
corresponding SVGStopElement. Codify this by adding an element()
overload that returns an SVGStopElement&.

Also added missing overrides and made most functions private.

Reviewed by Darin Adler.

* rendering/svg/RenderSVGGradientStop.cpp:
(WebCore::RenderSVGGradientStop::styleDidChange):
(WebCore::RenderSVGGradientStop::gradientElement):
* rendering/svg/RenderSVGGradientStop.h:
* rendering/svg/SVGRenderTreeAsText.cpp:
(WebCore::writeSVGGradientStop):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (163318 => 163319)


--- trunk/Source/WebCore/ChangeLog	2014-02-03 19:34:30 UTC (rev 163318)
+++ trunk/Source/WebCore/ChangeLog	2014-02-03 20:26:09 UTC (rev 163319)
@@ -1,3 +1,23 @@
+2014-02-03  Andreas Kling  <akl...@apple.com>
+
+        CTTE: RenderSVGGradientStop always has a SVGStopElement.
+        <https://webkit.org/b/128107>
+
+        RenderSVGGradientStop is never anonymous and always has a
+        corresponding SVGStopElement. Codify this by adding an element()
+        overload that returns an SVGStopElement&.
+
+        Also added missing overrides and made most functions private.
+
+        Reviewed by Darin Adler.
+
+        * rendering/svg/RenderSVGGradientStop.cpp:
+        (WebCore::RenderSVGGradientStop::styleDidChange):
+        (WebCore::RenderSVGGradientStop::gradientElement):
+        * rendering/svg/RenderSVGGradientStop.h:
+        * rendering/svg/SVGRenderTreeAsText.cpp:
+        (WebCore::writeSVGGradientStop):
+
 2014-02-03  David Kilzer  <ddkil...@apple.com>
 
         Remove CachedImageManual class

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGGradientStop.cpp (163318 => 163319)


--- trunk/Source/WebCore/rendering/svg/RenderSVGGradientStop.cpp	2014-02-03 19:34:30 UTC (rev 163318)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGGradientStop.cpp	2014-02-03 20:26:09 UTC (rev 163319)
@@ -50,7 +50,7 @@
 
     // <stop> elements should only be allowed to make renderers under gradient elements
     // but I can imagine a few cases we might not be catching, so let's not crash if our parent isn't a gradient.
-    SVGGradientElement* gradient = gradientElement();
+    const auto* gradient = gradientElement();
     if (!gradient)
         return;
 
@@ -67,12 +67,11 @@
     clearNeedsLayout();
 }
 
-SVGGradientElement* RenderSVGGradientStop::gradientElement() const
+SVGGradientElement* RenderSVGGradientStop::gradientElement()
 {
-    ContainerNode* parentNode = element()->parentNode();
-    if (parentNode->hasTagName(linearGradientTag) || parentNode->hasTagName(radialGradientTag))
-        return toSVGGradientElement(parentNode);
-    return 0;
+    if (element().parentElement() && isSVGGradientElement(*element().parentElement()))
+        return &toSVGGradientElement(*element().parentElement());
+    return nullptr;
 }
 
 }

Modified: trunk/Source/WebCore/rendering/svg/RenderSVGGradientStop.h (163318 => 163319)


--- trunk/Source/WebCore/rendering/svg/RenderSVGGradientStop.h	2014-02-03 19:34:30 UTC (rev 163318)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGGradientStop.h	2014-02-03 20:26:09 UTC (rev 163319)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2007 Eric Seidel <e...@webkit.org>
  * Copyright (C) 2009 Google, Inc.
+ * Copyright (C) 2014 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -23,11 +24,11 @@
 
 #if ENABLE(SVG)
 #include "RenderElement.h"
+#include "SVGStopElement.h"
 
 namespace WebCore {
     
 class SVGGradientElement;
-class SVGStopElement;
 
 // This class exists mostly so we can hear about gradient stop style changes
 class RenderSVGGradientStop final : public RenderElement {
@@ -35,28 +36,29 @@
     RenderSVGGradientStop(SVGStopElement&, PassRef<RenderStyle>);
     virtual ~RenderSVGGradientStop();
 
-    virtual bool isSVGGradientStop() const { return true; }
-    virtual const char* renderName() const { return "RenderSVGGradientStop"; }
+    SVGStopElement& element() const { return toSVGStopElement(RenderObject::nodeForNonAnonymous()); }
 
-    virtual void layout();
+private:
+    virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
 
-    // This overrides are needed to prevent ASSERTs on <svg><stop /></svg>
+    virtual void layout() override;
+
+    // These overrides are needed to prevent ASSERTs on <svg><stop /></svg>
     // RenderObject's default implementations ASSERT_NOT_REACHED()
     // https://bugs.webkit.org/show_bug.cgi?id=20400
     virtual LayoutRect clippedOverflowRectForRepaint(const RenderLayerModelObject*) const override { return LayoutRect(); }
-    virtual FloatRect objectBoundingBox() const { return FloatRect(); }
-    virtual FloatRect strokeBoundingBox() const { return FloatRect(); }
-    virtual FloatRect repaintRectInLocalCoordinates() const { return FloatRect(); }
+    virtual FloatRect objectBoundingBox() const override { return FloatRect(); }
+    virtual FloatRect strokeBoundingBox() const override { return FloatRect(); }
+    virtual FloatRect repaintRectInLocalCoordinates() const override { return FloatRect(); }
     virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint&, HitTestAction) override { return false; }
 
-protected:
-    virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
+    virtual bool isSVGGradientStop() const override { return true; }
+    virtual const char* renderName() const override { return "RenderSVGGradientStop"; }
 
-private:
     virtual bool canHaveChildren() const override { return false; }
-    virtual void paint(PaintInfo&, const LayoutPoint&) override final { }
+    virtual void paint(PaintInfo&, const LayoutPoint&) override { }
 
-    SVGGradientElement* gradientElement() const;
+    SVGGradientElement* gradientElement();
 };
 
 RENDER_OBJECT_TYPE_CASTS(RenderSVGGradientStop, isSVGGradientStop())

Modified: trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp (163318 => 163319)


--- trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp	2014-02-03 19:34:30 UTC (rev 163318)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp	2014-02-03 20:26:09 UTC (rev 163319)
@@ -608,10 +608,7 @@
 {
     writeStandardPrefix(ts, stop, indent);
 
-    SVGStopElement* stopElement = toSVGStopElement(toSVGElement(stop.element()));
-    ASSERT(stopElement);
-
-    ts << " [offset=" << stopElement->offset() << "] [color=" << stopElement->stopColorIncludingOpacity() << "]\n";
+    ts << " [offset=" << stop.element().offset() << "] [color=" << stop.element().stopColorIncludingOpacity() << "]\n";
 }
 
 void writeResources(TextStream& ts, const RenderObject& renderer, int indent)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to