<!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>[174542] 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/174542">174542</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2014-10-09 16:55:40 -0700 (Thu, 09 Oct 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use RenderObject::firstChildSlow() / lastChildSlow() less
https://bugs.webkit.org/show_bug.cgi?id=137573

Reviewed by Andreas Kling.

Use RenderObject::firstChildSlow() / lastChildSlow() less by using
tighter typing at call sites whenever possible to be able to call the
faster RenderElement::firstChild() / lastChild() instead.

This patch also uses more references instead of pointers when possible.

No new tests, no behavior change.

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::firstChildIsInlineContinuation):
(WebCore::AccessibilityRenderObject::previousSibling):
(WebCore::lastChildHasContinuation):
(WebCore::AccessibilityRenderObject::nextSibling):
* page/FrameView.cpp:
(WebCore::countRenderedCharactersInRenderObjectWithThreshold):
(WebCore::FrameView::renderedCharactersExceed):
* rendering/RenderElement.h:
* rendering/RenderRuby.cpp:
(WebCore::isAnonymousRubyInlineBlock):
(WebCore::isRubyBeforeBlock):
(WebCore::isRubyAfterBlock):
* rendering/svg/RenderSVGInline.h:
* rendering/svg/RenderSVGText.cpp:
(WebCore::RenderSVGText::layout):
* rendering/svg/SVGTextLayoutAttributesBuilder.cpp:
(WebCore::SVGTextLayoutAttributesBuilder::buildLayoutAttributesForTextRenderer):
(WebCore::SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree):
(WebCore::SVGTextLayoutAttributesBuilder::collectTextPositioningElements):
(WebCore::SVGTextLayoutAttributesBuilder::buildCharacterDataMap):
* rendering/svg/SVGTextLayoutAttributesBuilder.h:
* svg/SVGTextPositioningElement.cpp:
(WebCore::SVGTextPositioningElement::elementFromRenderer):
* svg/SVGTextPositioningElement.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAccessibilityRenderObjectcpp">trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewcpp">trunk/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderElementh">trunk/Source/WebCore/rendering/RenderElement.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderRubycpp">trunk/Source/WebCore/rendering/RenderRuby.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgRenderSVGInlineh">trunk/Source/WebCore/rendering/svg/RenderSVGInline.h</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgRenderSVGTextcpp">trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgSVGTextLayoutAttributesBuildercpp">trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingsvgSVGTextLayoutAttributesBuilderh">trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.h</a></li>
<li><a href="#trunkSourceWebCoresvgSVGTextPositioningElementcpp">trunk/Source/WebCore/svg/SVGTextPositioningElement.cpp</a></li>
<li><a href="#trunkSourceWebCoresvgSVGTextPositioningElementh">trunk/Source/WebCore/svg/SVGTextPositioningElement.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (174541 => 174542)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/ChangeLog        2014-10-09 23:55:40 UTC (rev 174542)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2014-10-09  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Use RenderObject::firstChildSlow() / lastChildSlow() less
+        https://bugs.webkit.org/show_bug.cgi?id=137573
+
+        Reviewed by Andreas Kling.
+
+        Use RenderObject::firstChildSlow() / lastChildSlow() less by using
+        tighter typing at call sites whenever possible to be able to call the
+        faster RenderElement::firstChild() / lastChild() instead.
+
+        This patch also uses more references instead of pointers when possible.
+
+        No new tests, no behavior change.
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::firstChildIsInlineContinuation):
+        (WebCore::AccessibilityRenderObject::previousSibling):
+        (WebCore::lastChildHasContinuation):
+        (WebCore::AccessibilityRenderObject::nextSibling):
+        * page/FrameView.cpp:
+        (WebCore::countRenderedCharactersInRenderObjectWithThreshold):
+        (WebCore::FrameView::renderedCharactersExceed):
+        * rendering/RenderElement.h:
+        * rendering/RenderRuby.cpp:
+        (WebCore::isAnonymousRubyInlineBlock):
+        (WebCore::isRubyBeforeBlock):
+        (WebCore::isRubyAfterBlock):
+        * rendering/svg/RenderSVGInline.h:
+        * rendering/svg/RenderSVGText.cpp:
+        (WebCore::RenderSVGText::layout):
+        * rendering/svg/SVGTextLayoutAttributesBuilder.cpp:
+        (WebCore::SVGTextLayoutAttributesBuilder::buildLayoutAttributesForTextRenderer):
+        (WebCore::SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree):
+        (WebCore::SVGTextLayoutAttributesBuilder::collectTextPositioningElements):
+        (WebCore::SVGTextLayoutAttributesBuilder::buildCharacterDataMap):
+        * rendering/svg/SVGTextLayoutAttributesBuilder.h:
+        * svg/SVGTextPositioningElement.cpp:
+        (WebCore::SVGTextPositioningElement::elementFromRenderer):
+        * svg/SVGTextPositioningElement.h:
+
</ins><span class="cx"> 2014-10-09  Roger Fong  &lt;roger_fong@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Build fix for Win EWS bots.
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAccessibilityRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (174541 => 174542)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp        2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp        2014-10-09 23:55:40 UTC (rev 174542)
</span><span class="lines">@@ -308,9 +308,9 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline bool firstChildIsInlineContinuation(RenderObject* renderer)
</del><ins>+static inline bool firstChildIsInlineContinuation(RenderElement&amp; renderer)
</ins><span class="cx"> {
</span><del>-    RenderObject* child = renderer-&gt;firstChildSlow();
</del><ins>+    RenderObject* child = renderer.firstChild();
</ins><span class="cx">     return child &amp;&amp; child-&gt;isInlineElementContinuation();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -329,9 +329,11 @@
</span><span class="cx"> 
</span><span class="cx">     // Case 2: Anonymous block parent of the end of a continuation - skip all the way to before
</span><span class="cx">     // the parent of the start, since everything in between will be linked up via the continuation.
</span><del>-    else if (m_renderer-&gt;isAnonymousBlock() &amp;&amp; firstChildIsInlineContinuation(m_renderer)) {
-        auto* firstParent = startOfContinuations(*m_renderer-&gt;firstChildSlow())-&gt;parent();
-        while (firstChildIsInlineContinuation(firstParent))
</del><ins>+    else if (m_renderer-&gt;isAnonymousBlock() &amp;&amp; firstChildIsInlineContinuation(downcast&lt;RenderBlock&gt;(*m_renderer))) {
+        RenderBlock&amp; renderBlock = downcast&lt;RenderBlock&gt;(*m_renderer);
+        auto* firstParent = startOfContinuations(*renderBlock.firstChild())-&gt;parent();
+        ASSERT(firstParent);
+        while (firstChildIsInlineContinuation(*firstParent))
</ins><span class="cx">             firstParent = startOfContinuations(*firstParent-&gt;firstChild())-&gt;parent();
</span><span class="cx">         previousSibling = firstParent-&gt;previousSibling();
</span><span class="cx">     }
</span><span class="lines">@@ -351,9 +353,9 @@
</span><span class="cx">     return axObjectCache()-&gt;getOrCreate(previousSibling);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static inline bool lastChildHasContinuation(RenderObject* renderer)
</del><ins>+static inline bool lastChildHasContinuation(RenderElement&amp; renderer)
</ins><span class="cx"> {
</span><del>-    RenderObject* child = renderer-&gt;lastChildSlow();
</del><ins>+    RenderObject* child = renderer.lastChild();
</ins><span class="cx">     return child &amp;&amp; isInlineWithContinuation(child);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -372,9 +374,10 @@
</span><span class="cx"> 
</span><span class="cx">     // Case 2: Anonymous block parent of the start of a continuation - skip all the way to
</span><span class="cx">     // after the parent of the end, since everything in between will be linked up via the continuation.
</span><del>-    else if (m_renderer-&gt;isAnonymousBlock() &amp;&amp; lastChildHasContinuation(m_renderer)) {
</del><ins>+    else if (m_renderer-&gt;isAnonymousBlock() &amp;&amp; lastChildHasContinuation(downcast&lt;RenderBlock&gt;(*m_renderer))) {
</ins><span class="cx">         RenderElement* lastParent = endOfContinuations(*downcast&lt;RenderBlock&gt;(*m_renderer).lastChild())-&gt;parent();
</span><del>-        while (lastChildHasContinuation(lastParent))
</del><ins>+        ASSERT(lastParent);
+        while (lastChildHasContinuation(*lastParent))
</ins><span class="cx">             lastParent = endOfContinuations(*lastParent-&gt;lastChild())-&gt;parent();
</span><span class="cx">         nextSibling = lastParent-&gt;nextSibling();
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (174541 => 174542)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.cpp        2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/page/FrameView.cpp        2014-10-09 23:55:40 UTC (rev 174542)
</span><span class="lines">@@ -2234,25 +2234,24 @@
</span><span class="cx">     ScrollView::repaintContentRectangle(r);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static unsigned countRenderedCharactersInRenderObjectWithThreshold(const RenderObject&amp; renderer, unsigned countSoFar, unsigned threshold)
</del><ins>+static unsigned countRenderedCharactersInRenderObjectWithThreshold(const RenderElement&amp; renderer, unsigned threshold)
</ins><span class="cx"> {
</span><del>-    // FIXME: Consider writing this using RenderObject::nextInPreOrder() instead of using recursion.
-    if (is&lt;RenderText&gt;(renderer))
-        countSoFar += downcast&lt;RenderText&gt;(renderer).text()-&gt;length();
-
-    for (RenderObject* child = renderer.firstChildSlow(); child; child = child-&gt;nextSibling()) {
-        if (countSoFar &gt;= threshold)
-            break;
-        countSoFar = countRenderedCharactersInRenderObjectWithThreshold(*child, countSoFar, threshold);
</del><ins>+    unsigned count = 0;
+    for (const RenderObject* descendant = &amp;renderer; descendant; descendant = descendant-&gt;nextInPreOrder()) {
+        if (is&lt;RenderText&gt;(*descendant)) {
+            count += downcast&lt;RenderText&gt;(*descendant).text()-&gt;length();
+            if (count &gt;= threshold)
+                break;
+        }
</ins><span class="cx">     }
</span><del>-    return countSoFar;
</del><ins>+    return count;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool FrameView::renderedCharactersExceed(unsigned threshold)
</span><span class="cx"> {
</span><span class="cx">     if (!m_frame-&gt;contentRenderer())
</span><span class="cx">         return false;
</span><del>-    return countRenderedCharactersInRenderObjectWithThreshold(*m_frame-&gt;contentRenderer(), 0, threshold) &gt;= threshold;
</del><ins>+    return countRenderedCharactersInRenderObjectWithThreshold(*m_frame-&gt;contentRenderer(), threshold) &gt;= threshold;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FrameView::contentsResized()
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderElement.h (174541 => 174542)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderElement.h        2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/rendering/RenderElement.h        2014-10-09 23:55:40 UTC (rev 174542)
</span><span class="lines">@@ -55,6 +55,8 @@
</span><span class="cx">     RenderObject* firstChild() const { return m_firstChild; }
</span><span class="cx">     RenderObject* lastChild() const { return m_lastChild; }
</span><span class="cx"> 
</span><ins>+    virtual bool isEmpty() const override { return !firstChild(); }
+
</ins><span class="cx">     // FIXME: Make these standalone and move to relevant files.
</span><span class="cx">     bool isRenderLayerModelObject() const;
</span><span class="cx">     bool isBoxModelObject() const;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderRubycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderRuby.cpp (174541 => 174542)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderRuby.cpp        2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/rendering/RenderRuby.cpp        2014-10-09 23:55:40 UTC (rev 174542)
</span><span class="lines">@@ -46,30 +46,30 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(!object
</span><span class="cx">         || !object-&gt;parent()-&gt;isRuby()
</span><del>-        || object-&gt;isRubyRun()
</del><ins>+        || is&lt;RenderRubyRun&gt;(*object)
</ins><span class="cx">         || (object-&gt;isInline() &amp;&amp; (object-&gt;isBeforeContent() || object-&gt;isAfterContent()))
</span><del>-        || (object-&gt;isAnonymous() &amp;&amp; object-&gt;isRenderBlock() &amp;&amp; object-&gt;style().display() == INLINE_BLOCK));
</del><ins>+        || (object-&gt;isAnonymous() &amp;&amp; is&lt;RenderBlock&gt;(*object) &amp;&amp; object-&gt;style().display() == INLINE_BLOCK));
</ins><span class="cx"> 
</span><span class="cx">     return object
</span><span class="cx">         &amp;&amp; object-&gt;parent()-&gt;isRuby()
</span><del>-        &amp;&amp; object-&gt;isRenderBlock()
-        &amp;&amp; !object-&gt;isRubyRun();
</del><ins>+        &amp;&amp; is&lt;RenderBlock&gt;(*object)
+        &amp;&amp; !is&lt;RenderRubyRun&gt;(*object);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline bool isRubyBeforeBlock(const RenderObject* object)
</span><span class="cx"> {
</span><span class="cx">     return isAnonymousRubyInlineBlock(object)
</span><span class="cx">         &amp;&amp; !object-&gt;previousSibling()
</span><del>-        &amp;&amp; object-&gt;firstChildSlow()
-        &amp;&amp; object-&gt;firstChildSlow()-&gt;style().styleType() == BEFORE;
</del><ins>+        &amp;&amp; downcast&lt;RenderBlock&gt;(*object).firstChild()
+        &amp;&amp; downcast&lt;RenderBlock&gt;(*object).firstChild()-&gt;style().styleType() == BEFORE;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline bool isRubyAfterBlock(const RenderObject* object)
</span><span class="cx"> {
</span><span class="cx">     return isAnonymousRubyInlineBlock(object)
</span><span class="cx">         &amp;&amp; !object-&gt;nextSibling()
</span><del>-        &amp;&amp; object-&gt;firstChildSlow()
-        &amp;&amp; object-&gt;firstChildSlow()-&gt;style().styleType() == AFTER;
</del><ins>+        &amp;&amp; downcast&lt;RenderBlock&gt;(*object).firstChild()
+        &amp;&amp; downcast&lt;RenderBlock&gt;(*object).firstChild()-&gt;style().styleType() == AFTER;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static inline RenderBlock* rubyBeforeBlock(const RenderElement* ruby)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgRenderSVGInlineh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/RenderSVGInline.h (174541 => 174542)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/svg/RenderSVGInline.h        2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGInline.h        2014-10-09 23:55:40 UTC (rev 174542)
</span><span class="lines">@@ -65,6 +65,8 @@
</span><span class="cx">     virtual RenderObject* removeChild(RenderObject&amp;) override final;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-}
</del><ins>+} // namespace WebCore
</ins><span class="cx"> 
</span><ins>+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGInline, isSVGInline())
+
</ins><span class="cx"> #endif // !RenderSVGTSpan_H
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgRenderSVGTextcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp (174541 => 174542)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp        2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp        2014-10-09 23:55:40 UTC (rev 174542)
</span><span class="lines">@@ -361,7 +361,7 @@
</span><span class="cx">         ASSERT(m_layoutAttributes.isEmpty());
</span><span class="cx">         collectLayoutAttributes(this, m_layoutAttributes);
</span><span class="cx">         updateFontInAllDescendants(this);
</span><del>-        m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(this);
</del><ins>+        m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(*this);
</ins><span class="cx"> 
</span><span class="cx">         m_needsReordering = true;
</span><span class="cx">         m_needsTextMetricsUpdate = false;
</span><span class="lines">@@ -375,7 +375,7 @@
</span><span class="cx">             m_needsTextMetricsUpdate = false;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(this);
</del><ins>+        m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(*this);
</ins><span class="cx">         m_needsReordering = true;
</span><span class="cx">         m_needsPositioningValuesUpdate = false;
</span><span class="cx">         updateCachedBoundariesInParents = true;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgSVGTextLayoutAttributesBuildercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp (174541 => 174542)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp        2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp        2014-10-09 23:55:40 UTC (rev 174542)
</span><span class="lines">@@ -20,6 +20,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;SVGTextLayoutAttributesBuilder.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;RenderSVGInline.h&quot;
</ins><span class="cx"> #include &quot;RenderSVGInlineText.h&quot;
</span><span class="cx"> #include &quot;RenderSVGText.h&quot;
</span><span class="cx"> #include &quot;SVGTextPositioningElement.h&quot;
</span><span class="lines">@@ -42,21 +43,19 @@
</span><span class="cx"> 
</span><span class="cx">         m_textLength = 0;
</span><span class="cx">         bool lastCharacterWasSpace = true;
</span><del>-        collectTextPositioningElements(textRoot, lastCharacterWasSpace);
</del><ins>+        collectTextPositioningElements(*textRoot, lastCharacterWasSpace);
</ins><span class="cx"> 
</span><span class="cx">         if (!m_textLength)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><del>-        buildCharacterDataMap(textRoot);
</del><ins>+        buildCharacterDataMap(*textRoot);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_metricsBuilder.buildMetricsAndLayoutAttributes(textRoot, &amp;text, m_characterDataMap);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(RenderSVGText* textRoot)
</del><ins>+bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(RenderSVGText&amp; textRoot)
</ins><span class="cx"> {
</span><del>-    ASSERT(textRoot);
-
</del><span class="cx">     m_characterDataMap.clear();
</span><span class="cx"> 
</span><span class="cx">     if (m_textPositions.isEmpty()) {
</span><span class="lines">@@ -69,7 +68,7 @@
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     buildCharacterDataMap(textRoot);
</span><del>-    m_metricsBuilder.buildMetricsAndLayoutAttributes(textRoot, 0, m_characterDataMap);
</del><ins>+    m_metricsBuilder.buildMetricsAndLayoutAttributes(&amp;textRoot, nullptr, m_characterDataMap);
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -96,25 +95,27 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderObject* start, bool&amp; lastCharacterWasSpace)
</del><ins>+void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderBoxModelObject&amp; start, bool&amp; lastCharacterWasSpace)
</ins><span class="cx"> {
</span><del>-    ASSERT(!start-&gt;isSVGText() || m_textPositions.isEmpty());
</del><ins>+    ASSERT(!is&lt;RenderSVGText&gt;(start) || m_textPositions.isEmpty());
</ins><span class="cx"> 
</span><del>-    for (RenderObject* child = start-&gt;firstChildSlow(); child; child = child-&gt;nextSibling()) {
-        if (child-&gt;isSVGInlineText()) {
-            processRenderSVGInlineText(*toRenderSVGInlineText(child), m_textLength, lastCharacterWasSpace);
</del><ins>+    for (RenderObject* child = start.firstChild(); child; child = child-&gt;nextSibling()) {
+        if (is&lt;RenderSVGInlineText&gt;(*child)) {
+            processRenderSVGInlineText(downcast&lt;RenderSVGInlineText&gt;(*child), m_textLength, lastCharacterWasSpace);
</ins><span class="cx">             continue;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (!child-&gt;isSVGInline())
</del><ins>+        if (!is&lt;RenderSVGInline&gt;(*child))
</ins><span class="cx">             continue;
</span><span class="cx"> 
</span><del>-        SVGTextPositioningElement* element = SVGTextPositioningElement::elementFromRenderer(child);
</del><ins>+        RenderSVGInline&amp; inlineChild = downcast&lt;RenderSVGInline&gt;(*child);
+        SVGTextPositioningElement* element = SVGTextPositioningElement::elementFromRenderer(inlineChild);
+
</ins><span class="cx">         unsigned atPosition = m_textPositions.size();
</span><span class="cx">         if (element)
</span><span class="cx">             m_textPositions.append(TextPosition(element, m_textLength));
</span><span class="cx"> 
</span><del>-        collectTextPositioningElements(child, lastCharacterWasSpace);
</del><ins>+        collectTextPositioningElements(inlineChild, lastCharacterWasSpace);
</ins><span class="cx"> 
</span><span class="cx">         if (!element)
</span><span class="cx">             continue;
</span><span class="lines">@@ -126,7 +127,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void SVGTextLayoutAttributesBuilder::buildCharacterDataMap(RenderSVGText* textRoot)
</del><ins>+void SVGTextLayoutAttributesBuilder::buildCharacterDataMap(RenderSVGText&amp; textRoot)
</ins><span class="cx"> {
</span><span class="cx">     SVGTextPositioningElement* outermostTextElement = SVGTextPositioningElement::elementFromRenderer(textRoot);
</span><span class="cx">     ASSERT(outermostTextElement);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingsvgSVGTextLayoutAttributesBuilderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.h (174541 => 174542)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.h        2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.h        2014-10-09 23:55:40 UTC (rev 174542)
</span><span class="lines">@@ -24,6 +24,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class RenderBoxModelObject;
</ins><span class="cx"> class RenderObject;
</span><span class="cx"> class RenderSVGInlineText;
</span><span class="cx"> class RenderSVGText;
</span><span class="lines">@@ -41,7 +42,7 @@
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(SVGTextLayoutAttributesBuilder);
</span><span class="cx"> public:
</span><span class="cx">     SVGTextLayoutAttributesBuilder();
</span><del>-    bool buildLayoutAttributesForForSubtree(RenderSVGText*);
</del><ins>+    bool buildLayoutAttributesForForSubtree(RenderSVGText&amp;);
</ins><span class="cx">     void buildLayoutAttributesForTextRenderer(RenderSVGInlineText&amp;);
</span><span class="cx"> 
</span><span class="cx">     void rebuildMetricsForTextRenderer(RenderSVGInlineText*);
</span><span class="lines">@@ -64,8 +65,8 @@
</span><span class="cx">         unsigned length;
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    void buildCharacterDataMap(RenderSVGText*);
-    void collectTextPositioningElements(RenderObject*, bool&amp; lastCharacterWasSpace);
</del><ins>+    void buildCharacterDataMap(RenderSVGText&amp;);
+    void collectTextPositioningElements(RenderBoxModelObject&amp;, bool&amp; lastCharacterWasSpace);
</ins><span class="cx">     void fillCharacterDataMap(const TextPosition&amp;);
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGTextPositioningElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGTextPositioningElement.cpp (174541 => 174542)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGTextPositioningElement.cpp        2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/svg/SVGTextPositioningElement.cpp        2014-10-09 23:55:40 UTC (rev 174542)
</span><span class="lines">@@ -23,8 +23,10 @@
</span><span class="cx"> #include &quot;SVGTextPositioningElement.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;Attribute.h&quot;
</span><ins>+#include &quot;RenderSVGInline.h&quot;
</ins><span class="cx"> #include &quot;RenderSVGResource.h&quot;
</span><span class="cx"> #include &quot;RenderSVGText.h&quot;
</span><ins>+#include &quot;SVGAltGlyphElement.h&quot;
</ins><span class="cx"> #include &quot;SVGElementInstance.h&quot;
</span><span class="cx"> #include &quot;SVGLengthList.h&quot;
</span><span class="cx"> #include &quot;SVGNames.h&quot;
</span><span class="lines">@@ -163,27 +165,24 @@
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-SVGTextPositioningElement* SVGTextPositioningElement::elementFromRenderer(RenderObject* renderer)
</del><ins>+SVGTextPositioningElement* SVGTextPositioningElement::elementFromRenderer(RenderBoxModelObject&amp; renderer)
</ins><span class="cx"> {
</span><del>-    if (!renderer)
-        return 0;
</del><ins>+    if (!is&lt;RenderSVGText&gt;(renderer) &amp;&amp; !is&lt;RenderSVGInline&gt;(renderer))
+        return nullptr;
</ins><span class="cx"> 
</span><del>-    if (!renderer-&gt;isSVGText() &amp;&amp; !renderer-&gt;isSVGInline())
-        return 0;
</del><ins>+    ASSERT(renderer.element());
+    SVGElement&amp; element = downcast&lt;SVGElement&gt;(*renderer.element());
</ins><span class="cx"> 
</span><del>-    Node* node = renderer-&gt;node();
-    ASSERT(node);
-    ASSERT(node-&gt;isSVGElement());
-
-    if (!node-&gt;hasTagName(SVGNames::textTag)
-        &amp;&amp; !node-&gt;hasTagName(SVGNames::tspanTag)
</del><ins>+    if (!is&lt;SVGTextElement&gt;(element)
+        &amp;&amp; !is&lt;SVGTSpanElement&gt;(element)
</ins><span class="cx"> #if ENABLE(SVG_FONTS)
</span><del>-        &amp;&amp; !node-&gt;hasTagName(SVGNames::altGlyphTag)
</del><ins>+        &amp;&amp; !is&lt;SVGAltGlyphElement&gt;(element)
</ins><span class="cx"> #endif
</span><del>-        &amp;&amp; !node-&gt;hasTagName(SVGNames::trefTag))
-        return 0;
</del><ins>+        &amp;&amp; !is&lt;SVGTRefElement&gt;(element))
+        return nullptr;
</ins><span class="cx"> 
</span><del>-    return static_cast&lt;SVGTextPositioningElement*&gt;(node);
</del><ins>+    // FIXME: This should use downcast&lt;&gt;().
+    return &amp;static_cast&lt;SVGTextPositioningElement&amp;&gt;(element);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoresvgSVGTextPositioningElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/SVGTextPositioningElement.h (174541 => 174542)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/SVGTextPositioningElement.h        2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/svg/SVGTextPositioningElement.h        2014-10-09 23:55:40 UTC (rev 174542)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx"> 
</span><span class="cx"> class SVGTextPositioningElement : public SVGTextContentElement {
</span><span class="cx"> public:
</span><del>-    static SVGTextPositioningElement* elementFromRenderer(RenderObject*);
</del><ins>+    static SVGTextPositioningElement* elementFromRenderer(RenderBoxModelObject&amp;);
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     SVGTextPositioningElement(const QualifiedName&amp;, Document&amp;);
</span></span></pre>
</div>
</div>

</body>
</html>