<!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 <cdumez@apple.com>
+
+ 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 <roger_fong@apple.com>
</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& renderer)
</ins><span class="cx"> {
</span><del>- RenderObject* child = renderer->firstChildSlow();
</del><ins>+ RenderObject* child = renderer.firstChild();
</ins><span class="cx"> return child && child->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->isAnonymousBlock() && firstChildIsInlineContinuation(m_renderer)) {
- auto* firstParent = startOfContinuations(*m_renderer->firstChildSlow())->parent();
- while (firstChildIsInlineContinuation(firstParent))
</del><ins>+ else if (m_renderer->isAnonymousBlock() && firstChildIsInlineContinuation(downcast<RenderBlock>(*m_renderer))) {
+ RenderBlock& renderBlock = downcast<RenderBlock>(*m_renderer);
+ auto* firstParent = startOfContinuations(*renderBlock.firstChild())->parent();
+ ASSERT(firstParent);
+ while (firstChildIsInlineContinuation(*firstParent))
</ins><span class="cx"> firstParent = startOfContinuations(*firstParent->firstChild())->parent();
</span><span class="cx"> previousSibling = firstParent->previousSibling();
</span><span class="cx"> }
</span><span class="lines">@@ -351,9 +353,9 @@
</span><span class="cx"> return axObjectCache()->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& renderer)
</ins><span class="cx"> {
</span><del>- RenderObject* child = renderer->lastChildSlow();
</del><ins>+ RenderObject* child = renderer.lastChild();
</ins><span class="cx"> return child && 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->isAnonymousBlock() && lastChildHasContinuation(m_renderer)) {
</del><ins>+ else if (m_renderer->isAnonymousBlock() && lastChildHasContinuation(downcast<RenderBlock>(*m_renderer))) {
</ins><span class="cx"> RenderElement* lastParent = endOfContinuations(*downcast<RenderBlock>(*m_renderer).lastChild())->parent();
</span><del>- while (lastChildHasContinuation(lastParent))
</del><ins>+ ASSERT(lastParent);
+ while (lastChildHasContinuation(*lastParent))
</ins><span class="cx"> lastParent = endOfContinuations(*lastParent->lastChild())->parent();
</span><span class="cx"> nextSibling = lastParent->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& renderer, unsigned countSoFar, unsigned threshold)
</del><ins>+static unsigned countRenderedCharactersInRenderObjectWithThreshold(const RenderElement& renderer, unsigned threshold)
</ins><span class="cx"> {
</span><del>- // FIXME: Consider writing this using RenderObject::nextInPreOrder() instead of using recursion.
- if (is<RenderText>(renderer))
- countSoFar += downcast<RenderText>(renderer).text()->length();
-
- for (RenderObject* child = renderer.firstChildSlow(); child; child = child->nextSibling()) {
- if (countSoFar >= threshold)
- break;
- countSoFar = countRenderedCharactersInRenderObjectWithThreshold(*child, countSoFar, threshold);
</del><ins>+ unsigned count = 0;
+ for (const RenderObject* descendant = &renderer; descendant; descendant = descendant->nextInPreOrder()) {
+ if (is<RenderText>(*descendant)) {
+ count += downcast<RenderText>(*descendant).text()->length();
+ if (count >= 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->contentRenderer())
</span><span class="cx"> return false;
</span><del>- return countRenderedCharactersInRenderObjectWithThreshold(*m_frame->contentRenderer(), 0, threshold) >= threshold;
</del><ins>+ return countRenderedCharactersInRenderObjectWithThreshold(*m_frame->contentRenderer(), threshold) >= 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->parent()->isRuby()
</span><del>- || object->isRubyRun()
</del><ins>+ || is<RenderRubyRun>(*object)
</ins><span class="cx"> || (object->isInline() && (object->isBeforeContent() || object->isAfterContent()))
</span><del>- || (object->isAnonymous() && object->isRenderBlock() && object->style().display() == INLINE_BLOCK));
</del><ins>+ || (object->isAnonymous() && is<RenderBlock>(*object) && object->style().display() == INLINE_BLOCK));
</ins><span class="cx">
</span><span class="cx"> return object
</span><span class="cx"> && object->parent()->isRuby()
</span><del>- && object->isRenderBlock()
- && !object->isRubyRun();
</del><ins>+ && is<RenderBlock>(*object)
+ && !is<RenderRubyRun>(*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"> && !object->previousSibling()
</span><del>- && object->firstChildSlow()
- && object->firstChildSlow()->style().styleType() == BEFORE;
</del><ins>+ && downcast<RenderBlock>(*object).firstChild()
+ && downcast<RenderBlock>(*object).firstChild()->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"> && !object->nextSibling()
</span><del>- && object->firstChildSlow()
- && object->firstChildSlow()->style().styleType() == AFTER;
</del><ins>+ && downcast<RenderBlock>(*object).firstChild()
+ && downcast<RenderBlock>(*object).firstChild()->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&) 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 "config.h"
</span><span class="cx"> #include "SVGTextLayoutAttributesBuilder.h"
</span><span class="cx">
</span><ins>+#include "RenderSVGInline.h"
</ins><span class="cx"> #include "RenderSVGInlineText.h"
</span><span class="cx"> #include "RenderSVGText.h"
</span><span class="cx"> #include "SVGTextPositioningElement.h"
</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, &text, m_characterDataMap);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(RenderSVGText* textRoot)
</del><ins>+bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(RenderSVGText& 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(&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& lastCharacterWasSpace)
</del><ins>+void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderBoxModelObject& start, bool& lastCharacterWasSpace)
</ins><span class="cx"> {
</span><del>- ASSERT(!start->isSVGText() || m_textPositions.isEmpty());
</del><ins>+ ASSERT(!is<RenderSVGText>(start) || m_textPositions.isEmpty());
</ins><span class="cx">
</span><del>- for (RenderObject* child = start->firstChildSlow(); child; child = child->nextSibling()) {
- if (child->isSVGInlineText()) {
- processRenderSVGInlineText(*toRenderSVGInlineText(child), m_textLength, lastCharacterWasSpace);
</del><ins>+ for (RenderObject* child = start.firstChild(); child; child = child->nextSibling()) {
+ if (is<RenderSVGInlineText>(*child)) {
+ processRenderSVGInlineText(downcast<RenderSVGInlineText>(*child), m_textLength, lastCharacterWasSpace);
</ins><span class="cx"> continue;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (!child->isSVGInline())
</del><ins>+ if (!is<RenderSVGInline>(*child))
</ins><span class="cx"> continue;
</span><span class="cx">
</span><del>- SVGTextPositioningElement* element = SVGTextPositioningElement::elementFromRenderer(child);
</del><ins>+ RenderSVGInline& inlineChild = downcast<RenderSVGInline>(*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& 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&);
</ins><span class="cx"> void buildLayoutAttributesForTextRenderer(RenderSVGInlineText&);
</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& lastCharacterWasSpace);
</del><ins>+ void buildCharacterDataMap(RenderSVGText&);
+ void collectTextPositioningElements(RenderBoxModelObject&, bool& lastCharacterWasSpace);
</ins><span class="cx"> void fillCharacterDataMap(const TextPosition&);
</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 "SVGTextPositioningElement.h"
</span><span class="cx">
</span><span class="cx"> #include "Attribute.h"
</span><ins>+#include "RenderSVGInline.h"
</ins><span class="cx"> #include "RenderSVGResource.h"
</span><span class="cx"> #include "RenderSVGText.h"
</span><ins>+#include "SVGAltGlyphElement.h"
</ins><span class="cx"> #include "SVGElementInstance.h"
</span><span class="cx"> #include "SVGLengthList.h"
</span><span class="cx"> #include "SVGNames.h"
</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& renderer)
</ins><span class="cx"> {
</span><del>- if (!renderer)
- return 0;
</del><ins>+ if (!is<RenderSVGText>(renderer) && !is<RenderSVGInline>(renderer))
+ return nullptr;
</ins><span class="cx">
</span><del>- if (!renderer->isSVGText() && !renderer->isSVGInline())
- return 0;
</del><ins>+ ASSERT(renderer.element());
+ SVGElement& element = downcast<SVGElement>(*renderer.element());
</ins><span class="cx">
</span><del>- Node* node = renderer->node();
- ASSERT(node);
- ASSERT(node->isSVGElement());
-
- if (!node->hasTagName(SVGNames::textTag)
- && !node->hasTagName(SVGNames::tspanTag)
</del><ins>+ if (!is<SVGTextElement>(element)
+ && !is<SVGTSpanElement>(element)
</ins><span class="cx"> #if ENABLE(SVG_FONTS)
</span><del>- && !node->hasTagName(SVGNames::altGlyphTag)
</del><ins>+ && !is<SVGAltGlyphElement>(element)
</ins><span class="cx"> #endif
</span><del>- && !node->hasTagName(SVGNames::trefTag))
- return 0;
</del><ins>+ && !is<SVGTRefElement>(element))
+ return nullptr;
</ins><span class="cx">
</span><del>- return static_cast<SVGTextPositioningElement*>(node);
</del><ins>+ // FIXME: This should use downcast<>().
+ return &static_cast<SVGTextPositioningElement&>(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&);
</ins><span class="cx">
</span><span class="cx"> protected:
</span><span class="cx"> SVGTextPositioningElement(const QualifiedName&, Document&);
</span></span></pre>
</div>
</div>
</body>
</html>