<!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>[201174] 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/201174">201174</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-05-19 12:09:41 -0700 (Thu, 19 May 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Update RenderBlockFlow::adjustComputedFontSizes() to use RenderObjectTraversal
https://bugs.webkit.org/show_bug.cgi?id=157784

Reviewed by Zalan Bujtas.

Update RenderBlockFlow::adjustComputedFontSizes() to use RenderObjectTraversal
instead of having its own Renderer tree traversal API, specifically for iOS
text autosizing.

* rendering/RenderBlockFlow.cpp:
(WebCore::isVisibleRenderText):
(WebCore::resizeTextPermitted):
(WebCore::isNonBlocksOrNonFixedHeightListItems):
(WebCore::RenderBlockFlow::adjustComputedFontSizes):
* rendering/RenderIterator.h:
(WebCore::RenderObjectTraversal::nextSkippingChildren):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::traverseNext): Deleted.
(WebCore::RenderObject::enclosingBox): Deleted.
(WebCore::RenderObject::enclosingBoxModelObject): Deleted.
(WebCore::RenderObject::fixedPositionedWithNamedFlowContainingBlock): Deleted.
(WebCore::hasFixedPosInNamedFlowContainingBlock): Deleted.
(WebCore::RenderObject::firstLineBlock): Deleted.
(WebCore::objectIsRelayoutBoundary): Deleted.
* rendering/RenderObject.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockFlowcpp">trunk/Source/WebCore/rendering/RenderBlockFlow.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderIteratorh">trunk/Source/WebCore/rendering/RenderIterator.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjectcpp">trunk/Source/WebCore/rendering/RenderObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderObjecth">trunk/Source/WebCore/rendering/RenderObject.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (201173 => 201174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-05-19 18:50:32 UTC (rev 201173)
+++ trunk/Source/WebCore/ChangeLog        2016-05-19 19:09:41 UTC (rev 201174)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2016-05-19  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Update RenderBlockFlow::adjustComputedFontSizes() to use RenderObjectTraversal
+        https://bugs.webkit.org/show_bug.cgi?id=157784
+
+        Reviewed by Zalan Bujtas.
+
+        Update RenderBlockFlow::adjustComputedFontSizes() to use RenderObjectTraversal
+        instead of having its own Renderer tree traversal API, specifically for iOS
+        text autosizing.
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::isVisibleRenderText):
+        (WebCore::resizeTextPermitted):
+        (WebCore::isNonBlocksOrNonFixedHeightListItems):
+        (WebCore::RenderBlockFlow::adjustComputedFontSizes):
+        * rendering/RenderIterator.h:
+        (WebCore::RenderObjectTraversal::nextSkippingChildren):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::traverseNext): Deleted.
+        (WebCore::RenderObject::enclosingBox): Deleted.
+        (WebCore::RenderObject::enclosingBoxModelObject): Deleted.
+        (WebCore::RenderObject::fixedPositionedWithNamedFlowContainingBlock): Deleted.
+        (WebCore::hasFixedPosInNamedFlowContainingBlock): Deleted.
+        (WebCore::RenderObject::firstLineBlock): Deleted.
+        (WebCore::objectIsRelayoutBoundary): Deleted.
+        * rendering/RenderObject.h:
+
</ins><span class="cx"> 2016-05-19  Csaba Osztrogonác  &lt;ossy@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix the build with GCC 4.9 in CSSParser.cpp
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (201173 => 201174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2016-05-19 18:50:32 UTC (rev 201173)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2016-05-19 19:09:41 UTC (rev 201174)
</span><span class="lines">@@ -3706,25 +3706,24 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(IOS_TEXT_AUTOSIZING)
</span><del>-inline static bool isVisibleRenderText(RenderObject* renderer)
</del><ins>+static inline bool isVisibleRenderText(const RenderObject&amp; renderer)
</ins><span class="cx"> {
</span><del>-    if (!is&lt;RenderText&gt;(*renderer))
</del><ins>+    if (!is&lt;RenderText&gt;(renderer))
</ins><span class="cx">         return false;
</span><del>-    RenderText&amp; renderText = downcast&lt;RenderText&gt;(*renderer);
</del><ins>+
+    auto&amp; renderText = downcast&lt;RenderText&gt;(renderer);
</ins><span class="cx">     return !renderText.linesBoundingBox().isEmpty() &amp;&amp; !renderText.text()-&gt;containsOnlyWhitespace();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline static bool resizeTextPermitted(RenderObject* render)
</del><ins>+static inline bool resizeTextPermitted(const RenderObject&amp; renderer)
</ins><span class="cx"> {
</span><span class="cx">     // We disallow resizing for text input fields and textarea to address &lt;rdar://problem/5792987&gt; and &lt;rdar://problem/8021123&gt;
</span><del>-    auto renderer = render-&gt;parent();
-    while (renderer) {
</del><ins>+    for (auto* ancestor = renderer.parent(); ancestor; ancestor = ancestor-&gt;parent()) {
</ins><span class="cx">         // Get the first non-shadow HTMLElement and see if it's an input.
</span><del>-        if (is&lt;HTMLElement&gt;(renderer-&gt;element()) &amp;&amp; !renderer-&gt;element()-&gt;isInShadowTree()) {
-            const HTMLElement&amp; element = downcast&lt;HTMLElement&gt;(*renderer-&gt;element());
</del><ins>+        if (is&lt;HTMLElement&gt;(ancestor-&gt;element()) &amp;&amp; !ancestor-&gt;element()-&gt;isInShadowTree()) {
+            auto&amp; element = downcast&lt;HTMLElement&gt;(*ancestor-&gt;element());
</ins><span class="cx">             return !is&lt;HTMLInputElement&gt;(element) &amp;&amp; !is&lt;HTMLTextAreaElement&gt;(element);
</span><span class="cx">         }
</span><del>-        renderer = renderer-&gt;parent();
</del><span class="cx">     }
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="lines">@@ -3742,12 +3741,12 @@
</span><span class="cx">     return count;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static bool isNonBlocksOrNonFixedHeightListItems(const RenderObject&amp; render)
</del><ins>+static bool isNonBlocksOrNonFixedHeightListItems(const RenderObject&amp; renderer)
</ins><span class="cx"> {
</span><del>-    if (!render.isRenderBlock())
</del><ins>+    if (!renderer.isRenderBlock())
</ins><span class="cx">         return true;
</span><del>-    if (render.isListItem())
-        return render.style().height().type() != Fixed;
</del><ins>+    if (renderer.isListItem())
+        return renderer.style().height().type() != Fixed;
</ins><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -3790,29 +3789,37 @@
</span><span class="cx">     float actualWidth = m_widthForTextAutosizing != -1 ? static_cast&lt;float&gt;(m_widthForTextAutosizing) : static_cast&lt;float&gt;(width());
</span><span class="cx">     float scale = visibleWidth / actualWidth;
</span><span class="cx">     float minFontSize = roundf(size / scale);
</span><del>-    
-    for (RenderObject* descendent = traverseNext(this, isNonBlocksOrNonFixedHeightListItems); descendent; descendent = descendent-&gt;traverseNext(this, isNonBlocksOrNonFixedHeightListItems)) {
-        if (isVisibleRenderText(descendent) &amp;&amp; resizeTextPermitted(descendent)) {
-            auto&amp; text = downcast&lt;RenderText&gt;(*descendent);
-            auto&amp; oldStyle = text.style();
-            auto fontDescription = oldStyle.fontDescription();
-            float specifiedSize = fontDescription.specifiedSize();
-            float scaledSize = roundf(specifiedSize * scale);
-            if (scaledSize &gt; 0 &amp;&amp; scaledSize &lt; minFontSize) {
-                // Record the width of the block and the line count the first time we resize text and use it from then on for text resizing.
-                // This makes text resizing consistent even if the block's width or line count changes (which can be caused by text resizing itself 5159915).
-                if (m_lineCountForTextAutosizing == NOT_SET)
-                    m_lineCountForTextAutosizing = lineCount;
-                if (m_widthForTextAutosizing == -1)
-                    m_widthForTextAutosizing = actualWidth;
-                
-                float candidateNewSize = 0;
-                float lineTextMultiplier = lineCount == ONE_LINE ? oneLineTextMultiplier(specifiedSize) : textMultiplier(specifiedSize);
-                candidateNewSize = roundf(std::min(minFontSize, specifiedSize * lineTextMultiplier));
-                if (candidateNewSize &gt; specifiedSize &amp;&amp; candidateNewSize != fontDescription.computedSize() &amp;&amp; text.textNode() &amp;&amp; oldStyle.textSizeAdjust().isAuto())
-                    document().addAutoSizingNode(*text.textNode(), candidateNewSize);
-            }
</del><ins>+
+    for (auto* descendant = RenderObjectTraversal::firstChild(*this); descendant; ) {
+        if (!isNonBlocksOrNonFixedHeightListItems(*descendant)) {
+            descendant = RenderObjectTraversal::nextSkippingChildren(*descendant, this);
+            continue;
</ins><span class="cx">         }
</span><ins>+        if (!isVisibleRenderText(*descendant) || !resizeTextPermitted(*descendant)) {
+            descendant = RenderObjectTraversal::next(*descendant, this);
+            continue;
+        }
+
+        auto&amp; text = downcast&lt;RenderText&gt;(*descendant);
+        auto&amp; oldStyle = text.style();
+        auto&amp; fontDescription = oldStyle.fontDescription();
+        float specifiedSize = fontDescription.specifiedSize();
+        float scaledSize = roundf(specifiedSize * scale);
+        if (scaledSize &gt; 0 &amp;&amp; scaledSize &lt; minFontSize) {
+            // Record the width of the block and the line count the first time we resize text and use it from then on for text resizing.
+            // This makes text resizing consistent even if the block's width or line count changes (which can be caused by text resizing itself 5159915).
+            if (m_lineCountForTextAutosizing == NOT_SET)
+                m_lineCountForTextAutosizing = lineCount;
+            if (m_widthForTextAutosizing == -1)
+                m_widthForTextAutosizing = actualWidth;
+
+            float lineTextMultiplier = lineCount == ONE_LINE ? oneLineTextMultiplier(specifiedSize) : textMultiplier(specifiedSize);
+            float candidateNewSize = roundf(std::min(minFontSize, specifiedSize * lineTextMultiplier));
+            if (candidateNewSize &gt; specifiedSize &amp;&amp; candidateNewSize != fontDescription.computedSize() &amp;&amp; text.textNode() &amp;&amp; oldStyle.textSizeAdjust().isAuto())
+                document().addAutoSizingNode(*text.textNode(), candidateNewSize);
+        }
+
+        descendant = RenderObjectTraversal::nextSkippingChildren(text, this);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> #endif // ENABLE(IOS_TEXT_AUTOSIZING)
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderIteratorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderIterator.h (201173 => 201174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderIterator.h        2016-05-19 18:50:32 UTC (rev 201173)
+++ trunk/Source/WebCore/rendering/RenderIterator.h        2016-05-19 19:09:41 UTC (rev 201174)
</span><span class="lines">@@ -124,8 +124,19 @@
</span><span class="cx">     return nextAncestorSibling(current, stayWithin);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+inline RenderObject* nextSkippingChildren(RenderObject&amp; current, const RenderObject* stayWithin)
+{
+    if (&amp;current == stayWithin)
+        return nullptr;
+
+    if (auto* sibling = current.nextSibling())
+        return sibling;
+
+    return nextAncestorSibling(current, stayWithin);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+}
+
</ins><span class="cx"> namespace RenderTraversal {
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename T, typename U&gt;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.cpp (201173 => 201174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.cpp        2016-05-19 18:50:32 UTC (rev 201173)
+++ trunk/Source/WebCore/rendering/RenderObject.cpp        2016-05-19 19:09:41 UTC (rev 201174)
</span><span class="lines">@@ -298,29 +298,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(IOS_TEXT_AUTOSIZING)
</span><del>-// Inspired by Node::traverseNextNode.
-RenderObject* RenderObject::traverseNext(const RenderObject* stayWithin) const
-{
-    RenderObject* child = firstChildSlow();
-    if (child) {
-        ASSERT(!stayWithin || child-&gt;isDescendantOf(stayWithin));
-        return child;
-    }
-    if (this == stayWithin)
-        return nullptr;
-    if (nextSibling()) {
-        ASSERT(!stayWithin || nextSibling()-&gt;isDescendantOf(stayWithin));
-        return nextSibling();
-    }
-    const RenderObject* n = this;
-    while (n &amp;&amp; !n-&gt;nextSibling() &amp;&amp; (!stayWithin || n-&gt;parent() != stayWithin))
-        n = n-&gt;parent();
-    if (n) {
-        ASSERT(!stayWithin || !n-&gt;nextSibling() || n-&gt;nextSibling()-&gt;isDescendantOf(stayWithin));
-        return n-&gt;nextSibling();
-    }
-    return nullptr;
-}
</del><span class="cx"> 
</span><span class="cx"> // Non-recursive version of the DFS search.
</span><span class="cx"> RenderObject* RenderObject::traverseNext(const RenderObject* stayWithin, HeightTypeTraverseNextInclusionFunction inclusionFunction, int&amp; currentDepth, int&amp; newFixedDepth) const
</span><span class="lines">@@ -370,44 +347,6 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RenderObject* RenderObject::traverseNext(const RenderObject* stayWithin, TraverseNextInclusionFunction inclusionFunction) const
-{
-    for (RenderObject* child = firstChildSlow(); child; child = child-&gt;nextSibling()) {
-        if (inclusionFunction(*child)) {
-            ASSERT(!stayWithin || child-&gt;isDescendantOf(stayWithin));
-            return child;
-        }
-    }
-
-    if (this == stayWithin)
-        return nullptr;
-
-    for (RenderObject* sibling = nextSibling(); sibling; sibling = sibling-&gt;nextSibling()) {
-        if (inclusionFunction(*sibling)) {
-            ASSERT(!stayWithin || sibling-&gt;isDescendantOf(stayWithin));
-            return sibling;
-        }
-    }
-
-    const RenderObject* n = this;
-    while (n) {
-        while (n &amp;&amp; !n-&gt;nextSibling() &amp;&amp; (!stayWithin || n-&gt;parent() != stayWithin))
-            n = n-&gt;parent();
-        if (n) {
-            for (RenderObject* sibling = n-&gt;nextSibling(); sibling; sibling = sibling-&gt;nextSibling()) {
-                if (inclusionFunction(*sibling)) {
-                    ASSERT(!stayWithin || !n-&gt;nextSibling() || n-&gt;nextSibling()-&gt;isDescendantOf(stayWithin));
-                    return sibling;
-                }
-            }
-            if ((!stayWithin || n-&gt;parent() != stayWithin))
-                n = n-&gt;parent();
-            else
-                return nullptr;
-        }
-    }
-    return nullptr;
-}
</del><span class="cx"> #endif // ENABLE(IOS_TEXT_AUTOSIZING)
</span><span class="cx"> 
</span><span class="cx"> RenderLayer* RenderObject::enclosingLayer() const
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderObject.h (201173 => 201174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderObject.h        2016-05-19 18:50:32 UTC (rev 201173)
+++ trunk/Source/WebCore/rendering/RenderObject.h        2016-05-19 19:09:41 UTC (rev 201174)
</span><span class="lines">@@ -189,11 +189,7 @@
</span><span class="cx">         OverflowHeight
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    RenderObject* traverseNext(const RenderObject* stayWithin) const;
-    typedef bool (*TraverseNextInclusionFunction)(const RenderObject&amp;);
</del><span class="cx">     typedef BlockContentHeightType (*HeightTypeTraverseNextInclusionFunction)(const RenderObject&amp;);
</span><del>-
-    RenderObject* traverseNext(const RenderObject* stayWithin, TraverseNextInclusionFunction) const;
</del><span class="cx">     RenderObject* traverseNext(const RenderObject* stayWithin, HeightTypeTraverseNextInclusionFunction, int&amp; currentDepth,  int&amp; newFixedDepth) const;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>