<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[163316] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/163316">163316</a></dd>
<dt>Author</dt> <dd>akling@apple.com</dd>
<dt>Date</dt> <dd>2014-02-03 10:52:12 -0800 (Mon, 03 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>CTTE: Grab bag of SVGRenderTreeAsText cleanups.
&lt;https://webkit.org/b/128099&gt;

Made some of the DRT SVG functions take more specific types than
RenderObject. Removed some redundant casts.

Reviewed by Anders Carlsson.

* rendering/RenderTreeAsText.cpp:
(WebCore::write):
* rendering/svg/SVGRenderTreeAsText.h:
* rendering/svg/SVGRenderTreeAsText.cpp:
(WebCore::writeSVGResourceContainer):
(WebCore::writeSVGContainer):

    Make writeSVGResourceContainer() and writeSVGContainer() take the
    final type instead of RenderObject.

(WebCore::writeStyle):
(WebCore::writePositionAndStyle):

    Make these take RenderElement instead of RenderObject.

(WebCore::writeChildren):

    Use child renderer iterator.

(WebCore::writeResources):

    Remove unnecessary cast.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderTreeAsTextcpp">trunk/Source/WebCore/rendering/RenderTreeAsText.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgSVGRenderTreeAsTextcpp">trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgSVGRenderTreeAsTexth">trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (163315 => 163316)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-02-03 18:38:54 UTC (rev 163315)
+++ trunk/Source/WebCore/ChangeLog        2014-02-03 18:52:12 UTC (rev 163316)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2014-02-03  Andreas Kling  &lt;akling@apple.com&gt;
+
+        CTTE: Grab bag of SVGRenderTreeAsText cleanups.
+        &lt;https://webkit.org/b/128099&gt;
+
+        Made some of the DRT SVG functions take more specific types than
+        RenderObject. Removed some redundant casts.
+
+        Reviewed by Anders Carlsson.
+
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::write):
+        * rendering/svg/SVGRenderTreeAsText.h:
+        * rendering/svg/SVGRenderTreeAsText.cpp:
+        (WebCore::writeSVGResourceContainer):
+        (WebCore::writeSVGContainer):
+
+            Make writeSVGResourceContainer() and writeSVGContainer() take the
+            final type instead of RenderObject.
+
+        (WebCore::writeStyle):
+        (WebCore::writePositionAndStyle):
+
+            Make these take RenderElement instead of RenderObject.
+
+        (WebCore::writeChildren):
+
+            Use child renderer iterator.
+
+        (WebCore::writeResources):
+
+            Remove unnecessary cast.
+
</ins><span class="cx"> 2014-01-25  Darin Adler  &lt;darin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Stop using Unicode.h
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderTreeAsTextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderTreeAsText.cpp (163315 => 163316)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderTreeAsText.cpp        2014-02-03 18:38:54 UTC (rev 163315)
+++ trunk/Source/WebCore/rendering/RenderTreeAsText.cpp        2014-02-03 18:52:12 UTC (rev 163316)
</span><span class="lines">@@ -66,6 +66,7 @@
</span><span class="cx"> #include &quot;RenderSVGImage.h&quot;
</span><span class="cx"> #include &quot;RenderSVGInlineText.h&quot;
</span><span class="cx"> #include &quot;RenderSVGPath.h&quot;
</span><ins>+#include &quot;RenderSVGResourceContainer.h&quot;
</ins><span class="cx"> #include &quot;RenderSVGRoot.h&quot;
</span><span class="cx"> #include &quot;RenderSVGText.h&quot;
</span><span class="cx"> #include &quot;SVGRenderTreeAsText.h&quot;
</span><span class="lines">@@ -518,11 +519,11 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (o.isSVGResourceContainer()) {
</span><del>-        writeSVGResourceContainer(ts, o, indent);
</del><ins>+        writeSVGResourceContainer(ts, toRenderSVGResourceContainer(o), indent);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (o.isSVGContainer()) {
</span><del>-        writeSVGContainer(ts, o, indent);
</del><ins>+        writeSVGContainer(ts, toRenderSVGContainer(o), indent);
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     if (o.isSVGRoot()) {
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgSVGRenderTreeAsTextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp (163315 => 163316)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp        2014-02-03 18:38:54 UTC (rev 163315)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.cpp        2014-02-03 18:52:12 UTC (rev 163316)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><span class="cx"> #include &quot;NodeRenderStyle.h&quot;
</span><span class="cx"> #include &quot;RenderImage.h&quot;
</span><ins>+#include &quot;RenderIterator.h&quot;
</ins><span class="cx"> #include &quot;RenderSVGGradientStop.h&quot;
</span><span class="cx"> #include &quot;RenderSVGImage.h&quot;
</span><span class="cx"> #include &quot;RenderSVGPath.h&quot;
</span><span class="lines">@@ -250,17 +251,17 @@
</span><span class="cx">     ts &lt;&lt; &quot; [id=\&quot;&quot; &lt;&lt; element.getIdAttribute() &lt;&lt; &quot;\&quot;]&quot;;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void writeStyle(TextStream&amp; ts, const RenderObject&amp; object)
</del><ins>+static void writeStyle(TextStream&amp; ts, const RenderElement&amp; renderer)
</ins><span class="cx"> {
</span><del>-    const RenderStyle&amp; style = object.style();
</del><ins>+    const RenderStyle&amp; style = renderer.style();
</ins><span class="cx">     const SVGRenderStyle&amp; svgStyle = style.svgStyle();
</span><span class="cx"> 
</span><del>-    if (!object.localTransform().isIdentity())
-        writeNameValuePair(ts, &quot;transform&quot;, object.localTransform());
</del><ins>+    if (!renderer.localTransform().isIdentity())
+        writeNameValuePair(ts, &quot;transform&quot;, renderer.localTransform());
</ins><span class="cx">     writeIfNotDefault(ts, &quot;image rendering&quot;, style.imageRendering(), RenderStyle::initialImageRendering());
</span><span class="cx">     writeIfNotDefault(ts, &quot;opacity&quot;, style.opacity(), RenderStyle::initialOpacity());
</span><del>-    if (object.isSVGShape()) {
-        const RenderSVGShape&amp; shape = static_cast&lt;const RenderSVGShape&amp;&gt;(object);
</del><ins>+    if (renderer.isSVGShape()) {
+        const auto&amp; shape = toRenderSVGShape(renderer);
</ins><span class="cx"> 
</span><span class="cx">         Color fallbackColor;
</span><span class="cx">         if (RenderSVGResource* strokePaintingResource = RenderSVGResource::strokePaintingResource(const_cast&lt;RenderSVGShape&amp;&gt;(shape), shape.style(), fallbackColor)) {
</span><span class="lines">@@ -307,10 +308,10 @@
</span><span class="cx">     writeIfNotEmpty(ts, &quot;end marker&quot;, svgStyle.markerEndResource());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static TextStream&amp; writePositionAndStyle(TextStream&amp; ts, const RenderObject&amp; object)
</del><ins>+static TextStream&amp; writePositionAndStyle(TextStream&amp; ts, const RenderElement&amp; renderer)
</ins><span class="cx"> {
</span><del>-    ts &lt;&lt; &quot; &quot; &lt;&lt; enclosingIntRect(const_cast&lt;RenderObject&amp;&gt;(object).absoluteClippedOverflowRect());
-    writeStyle(ts, object);
</del><ins>+    ts &lt;&lt; &quot; &quot; &lt;&lt; enclosingIntRect(renderer.absoluteClippedOverflowRect());
+    writeStyle(ts, renderer);
</ins><span class="cx">     return ts;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -451,10 +452,10 @@
</span><span class="cx">         ts &lt;&lt; &quot; {&quot; &lt;&lt; object.node()-&gt;nodeName() &lt;&lt; &quot;}&quot;;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void writeChildren(TextStream&amp; ts, const RenderObject&amp; object, int indent)
</del><ins>+static void writeChildren(TextStream&amp; ts, const RenderElement&amp; parent, int indent)
</ins><span class="cx"> {
</span><del>-    for (RenderObject* child = object.firstChildSlow(); child; child = child-&gt;nextSibling())
-        write(ts, *child, indent + 1);
</del><ins>+    for (const auto&amp; child : childrenOfType&lt;RenderObject&gt;(parent))
+        write(ts, child, indent + 1);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline void writeCommonGradientProperties(TextStream&amp; ts, SVGSpreadMethodType spreadMethod, const AffineTransform&amp; gradientTransform, SVGUnitTypes::SVGUnitType gradientUnits)
</span><span class="lines">@@ -468,16 +469,13 @@
</span><span class="cx">         ts &lt;&lt; &quot; [gradientTransform=&quot; &lt;&lt; gradientTransform &lt;&lt; &quot;]&quot;;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void writeSVGResourceContainer(TextStream&amp; ts, const RenderObject&amp; object, int indent)
</del><ins>+void writeSVGResourceContainer(TextStream&amp; ts, const RenderSVGResourceContainer&amp; resource, int indent)
</ins><span class="cx"> {
</span><del>-    writeStandardPrefix(ts, object, indent);
</del><ins>+    writeStandardPrefix(ts, resource, indent);
</ins><span class="cx"> 
</span><del>-    Element* element = toElement(object.node());
-    const AtomicString&amp; id = element-&gt;getIdAttribute();
</del><ins>+    const AtomicString&amp; id = resource.element().getIdAttribute();
</ins><span class="cx">     writeNameAndQuotedValue(ts, &quot;id&quot;, id);    
</span><span class="cx"> 
</span><del>-    const auto&amp; resource = toRenderSVGResourceContainer(object);
-
</del><span class="cx">     if (resource.resourceType() == MaskerResourceType) {
</span><span class="cx">         const auto&amp; masker = static_cast&lt;const RenderSVGResourceMasker&amp;&gt;(resource);
</span><span class="cx">         writeNameValuePair(ts, &quot;maskUnits&quot;, masker.maskUnits());
</span><span class="lines">@@ -552,10 +550,10 @@
</span><span class="cx">         ts &lt;&lt; &quot; [center=&quot; &lt;&lt; centerPoint &lt;&lt; &quot;] [focal=&quot; &lt;&lt; focalPoint &lt;&lt; &quot;] [radius=&quot; &lt;&lt; radius &lt;&lt; &quot;] [focalRadius=&quot; &lt;&lt; focalRadius &lt;&lt; &quot;]\n&quot;;
</span><span class="cx">     } else
</span><span class="cx">         ts &lt;&lt; &quot;\n&quot;;
</span><del>-    writeChildren(ts, object, indent);
</del><ins>+    writeChildren(ts, resource, indent);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void writeSVGContainer(TextStream&amp; ts, const RenderObject&amp; container, int indent)
</del><ins>+void writeSVGContainer(TextStream&amp; ts, const RenderSVGContainer&amp; container, int indent)
</ins><span class="cx"> {
</span><span class="cx">     // Currently RenderSVGResourceFilterPrimitive has no meaningful output.
</span><span class="cx">     if (container.isSVGResourceFilterPrimitive())
</span><span class="lines">@@ -616,16 +614,15 @@
</span><span class="cx">     ts &lt;&lt; &quot; [offset=&quot; &lt;&lt; stopElement-&gt;offset() &lt;&lt; &quot;] [color=&quot; &lt;&lt; stopElement-&gt;stopColorIncludingOpacity() &lt;&lt; &quot;]\n&quot;;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void writeResources(TextStream&amp; ts, const RenderObject&amp; object, int indent)
</del><ins>+void writeResources(TextStream&amp; ts, const RenderObject&amp; renderer, int indent)
</ins><span class="cx"> {
</span><del>-    const RenderStyle&amp; style = object.style();
</del><ins>+    const RenderStyle&amp; style = renderer.style();
</ins><span class="cx">     const SVGRenderStyle&amp; svgStyle = style.svgStyle();
</span><span class="cx"> 
</span><span class="cx">     // FIXME: We want to use SVGResourcesCache to determine which resources are present, instead of quering the resource &lt;-&gt; id cache.
</span><span class="cx">     // For now leave the DRT output as is, but later on we should change this so cycles are properly ignored in the DRT output.
</span><del>-    RenderObject&amp; renderer = const_cast&lt;RenderObject&amp;&gt;(object);
</del><span class="cx">     if (!svgStyle.maskerResource().isEmpty()) {
</span><del>-        if (RenderSVGResourceMasker* masker = getRenderSVGResourceById&lt;RenderSVGResourceMasker&gt;(object.document(), svgStyle.maskerResource())) {
</del><ins>+        if (RenderSVGResourceMasker* masker = getRenderSVGResourceById&lt;RenderSVGResourceMasker&gt;(renderer.document(), svgStyle.maskerResource())) {
</ins><span class="cx">             writeIndent(ts, indent);
</span><span class="cx">             ts &lt;&lt; &quot; &quot;;
</span><span class="cx">             writeNameAndQuotedValue(ts, &quot;masker&quot;, svgStyle.maskerResource());
</span><span class="lines">@@ -635,7 +632,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     if (!svgStyle.clipperResource().isEmpty()) {
</span><del>-        if (RenderSVGResourceClipper* clipper = getRenderSVGResourceById&lt;RenderSVGResourceClipper&gt;(object.document(), svgStyle.clipperResource())) {
</del><ins>+        if (RenderSVGResourceClipper* clipper = getRenderSVGResourceById&lt;RenderSVGResourceClipper&gt;(renderer.document(), svgStyle.clipperResource())) {
</ins><span class="cx">             writeIndent(ts, indent);
</span><span class="cx">             ts &lt;&lt; &quot; &quot;;
</span><span class="cx">             writeNameAndQuotedValue(ts, &quot;clipPath&quot;, svgStyle.clipperResource());
</span><span class="lines">@@ -646,7 +643,7 @@
</span><span class="cx">     }
</span><span class="cx"> #if ENABLE(FILTERS)
</span><span class="cx">     if (!svgStyle.filterResource().isEmpty()) {
</span><del>-        if (RenderSVGResourceFilter* filter = getRenderSVGResourceById&lt;RenderSVGResourceFilter&gt;(object.document(), svgStyle.filterResource())) {
</del><ins>+        if (RenderSVGResourceFilter* filter = getRenderSVGResourceById&lt;RenderSVGResourceFilter&gt;(renderer.document(), svgStyle.filterResource())) {
</ins><span class="cx">             writeIndent(ts, indent);
</span><span class="cx">             ts &lt;&lt; &quot; &quot;;
</span><span class="cx">             writeNameAndQuotedValue(ts, &quot;filter&quot;, svgStyle.filterResource());
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgSVGRenderTreeAsTexth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.h (163315 => 163316)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.h        2014-02-03 18:38:54 UTC (rev 163315)
+++ trunk/Source/WebCore/rendering/svg/SVGRenderTreeAsText.h        2014-02-03 18:52:12 UTC (rev 163316)
</span><span class="lines">@@ -38,9 +38,11 @@
</span><span class="cx"> class Node;
</span><span class="cx"> class RenderImage;
</span><span class="cx"> class RenderObject;
</span><ins>+class RenderSVGContainer;
</ins><span class="cx"> class RenderSVGGradientStop;
</span><span class="cx"> class RenderSVGImage;
</span><span class="cx"> class RenderSVGInlineText;
</span><ins>+class RenderSVGResourceContainer;
</ins><span class="cx"> class RenderSVGShape;
</span><span class="cx"> class RenderSVGRoot;
</span><span class="cx"> class RenderSVGText;
</span><span class="lines">@@ -51,8 +53,8 @@
</span><span class="cx"> void write(TextStream&amp;, const RenderSVGShape&amp;, int indent);
</span><span class="cx"> void write(TextStream&amp;, const RenderSVGRoot&amp;, int indent);
</span><span class="cx"> void writeSVGGradientStop(TextStream&amp;, const RenderSVGGradientStop&amp;, int indent);
</span><del>-void writeSVGResourceContainer(TextStream&amp;, const RenderObject&amp;, int indent);
-void writeSVGContainer(TextStream&amp;, const RenderObject&amp;, int indent);
</del><ins>+void writeSVGResourceContainer(TextStream&amp;, const RenderSVGResourceContainer&amp;, int indent);
+void writeSVGContainer(TextStream&amp;, const RenderSVGContainer&amp;, int indent);
</ins><span class="cx"> void writeSVGImage(TextStream&amp;, const RenderSVGImage&amp;, int indent);
</span><span class="cx"> void writeSVGInlineText(TextStream&amp;, const RenderSVGInlineText&amp;, int indent);
</span><span class="cx"> void writeSVGText(TextStream&amp;, const RenderSVGText&amp;, int indent);
</span></span></pre>
</div>
</div>

</body>
</html>