<!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>[208744] 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/208744">208744</a></dd>
<dt>Author</dt> <dd>zalan@apple.com</dd>
<dt>Date</dt> <dd>2016-11-15 12:12:26 -0800 (Tue, 15 Nov 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>CounterNode::insertAfter and ::removeChild should take references.
https://bugs.webkit.org/show_bug.cgi?id=164780

Reviewed by Simon Fraser.

No change in functionality.

* rendering/CounterNode.cpp:
(WebCore::CounterNode::insertAfter):
(WebCore::CounterNode::removeChild):
* rendering/CounterNode.h:
* rendering/RenderCounter.cpp:
(WebCore::makeCounterNode):
(WebCore::destroyCounterNodeWithoutMapRemoval):
(WebCore::updateCounters):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingCounterNodecpp">trunk/Source/WebCore/rendering/CounterNode.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingCounterNodeh">trunk/Source/WebCore/rendering/CounterNode.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderCountercpp">trunk/Source/WebCore/rendering/RenderCounter.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208743 => 208744)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-15 19:53:25 UTC (rev 208743)
+++ trunk/Source/WebCore/ChangeLog        2016-11-15 20:12:26 UTC (rev 208744)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2016-11-15  Zalan Bujtas  &lt;zalan@apple.com&gt;
+
+        CounterNode::insertAfter and ::removeChild should take references.
+        https://bugs.webkit.org/show_bug.cgi?id=164780
+
+        Reviewed by Simon Fraser.
+
+        No change in functionality.
+
+        * rendering/CounterNode.cpp:
+        (WebCore::CounterNode::insertAfter):
+        (WebCore::CounterNode::removeChild):
+        * rendering/CounterNode.h:
+        * rendering/RenderCounter.cpp:
+        (WebCore::makeCounterNode):
+        (WebCore::destroyCounterNodeWithoutMapRemoval):
+        (WebCore::updateCounters):
+
</ins><span class="cx"> 2016-11-15  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         slot doesn't work as a flex container
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingCounterNodecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/CounterNode.cpp (208743 => 208744)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/CounterNode.cpp        2016-11-15 19:53:25 UTC (rev 208743)
+++ trunk/Source/WebCore/rendering/CounterNode.cpp        2016-11-15 20:12:26 UTC (rev 208744)
</span><span class="lines">@@ -211,47 +211,46 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CounterNode::insertAfter(CounterNode* newChild, CounterNode* refChild, const AtomicString&amp; identifier)
</del><ins>+void CounterNode::insertAfter(CounterNode&amp; newChild, CounterNode* beforeChild, const AtomicString&amp; identifier)
</ins><span class="cx"> {
</span><del>-    ASSERT(newChild);
-    ASSERT(!newChild-&gt;m_parent);
-    ASSERT(!newChild-&gt;m_previousSibling);
-    ASSERT(!newChild-&gt;m_nextSibling);
-    // If the refChild is not our child we can not complete the request. This hardens against bugs in RenderCounter.
</del><ins>+    ASSERT(!newChild.m_parent);
+    ASSERT(!newChild.m_previousSibling);
+    ASSERT(!newChild.m_nextSibling);
+    // If the beforeChild is not our child we can not complete the request. This hardens against bugs in RenderCounter.
</ins><span class="cx">     // When renderers are reparented it may request that we insert counter nodes improperly.
</span><del>-    if (refChild &amp;&amp; refChild-&gt;m_parent != this)
</del><ins>+    if (beforeChild &amp;&amp; beforeChild-&gt;m_parent != this)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (newChild-&gt;m_hasResetType) {
-        while (m_lastChild != refChild)
</del><ins>+    if (newChild.m_hasResetType) {
+        while (m_lastChild != beforeChild)
</ins><span class="cx">             RenderCounter::destroyCounterNode(m_lastChild-&gt;owner(), identifier);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     CounterNode* next;
</span><span class="cx"> 
</span><del>-    if (refChild) {
-        next = refChild-&gt;m_nextSibling;
-        refChild-&gt;m_nextSibling = newChild;
</del><ins>+    if (beforeChild) {
+        next = beforeChild-&gt;m_nextSibling;
+        beforeChild-&gt;m_nextSibling = &amp;newChild;
</ins><span class="cx">     } else {
</span><span class="cx">         next = m_firstChild;
</span><del>-        m_firstChild = newChild;
</del><ins>+        m_firstChild = &amp;newChild;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    newChild-&gt;m_parent = this;
-    newChild-&gt;m_previousSibling = refChild;
</del><ins>+    newChild.m_parent = this;
+    newChild.m_previousSibling = beforeChild;
</ins><span class="cx"> 
</span><span class="cx">     if (next) {
</span><del>-        ASSERT(next-&gt;m_previousSibling == refChild);
-        next-&gt;m_previousSibling = newChild;
-        newChild-&gt;m_nextSibling = next;
</del><ins>+        ASSERT(next-&gt;m_previousSibling == beforeChild);
+        next-&gt;m_previousSibling = &amp;newChild;
+        newChild.m_nextSibling = next;
</ins><span class="cx">     } else {
</span><del>-        ASSERT(m_lastChild == refChild);
-        m_lastChild = newChild;
</del><ins>+        ASSERT(m_lastChild == beforeChild);
+        m_lastChild = &amp;newChild;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (!newChild-&gt;m_firstChild || newChild-&gt;m_hasResetType) {
-        newChild-&gt;m_countInParent = newChild-&gt;computeCountInParent();
-        newChild-&gt;resetThisAndDescendantsRenderers();
</del><ins>+    if (!newChild.m_firstChild || newChild.m_hasResetType) {
+        newChild.m_countInParent = newChild.computeCountInParent();
+        newChild.resetThisAndDescendantsRenderers();
</ins><span class="cx">         if (next)
</span><span class="cx">             next-&gt;recount();
</span><span class="cx">         return;
</span><span class="lines">@@ -259,16 +258,16 @@
</span><span class="cx"> 
</span><span class="cx">     // The code below handles the case when a formerly root increment counter is loosing its root position
</span><span class="cx">     // and therefore its children become next siblings.
</span><del>-    CounterNode* last = newChild-&gt;m_lastChild;
-    CounterNode* first = newChild-&gt;m_firstChild;
</del><ins>+    CounterNode* last = newChild.m_lastChild;
+    CounterNode* first = newChild.m_firstChild;
</ins><span class="cx"> 
</span><span class="cx">     if (first) {
</span><span class="cx">         ASSERT(last);
</span><del>-        newChild-&gt;m_nextSibling = first;
-        if (m_lastChild == newChild)
</del><ins>+        newChild.m_nextSibling = first;
+        if (m_lastChild == &amp;newChild)
</ins><span class="cx">             m_lastChild = last;
</span><span class="cx"> 
</span><del>-        first-&gt;m_previousSibling = newChild;
</del><ins>+        first-&gt;m_previousSibling = &amp;newChild;
</ins><span class="cx">     
</span><span class="cx">         // The case when the original next sibling of the inserted node becomes a child of
</span><span class="cx">         // one of the former children of the inserted node is not handled as it is believed
</span><span class="lines">@@ -281,7 +280,7 @@
</span><span class="cx">         //    attached to renderers that were already in the document's render tree.
</span><span class="cx">         last-&gt;m_nextSibling = next;
</span><span class="cx">         if (next) {
</span><del>-            ASSERT(next-&gt;m_previousSibling == newChild);
</del><ins>+            ASSERT(next-&gt;m_previousSibling == &amp;newChild);
</ins><span class="cx">             next-&gt;m_previousSibling = last;
</span><span class="cx">         } else
</span><span class="cx">             m_lastChild = last;
</span><span class="lines">@@ -291,30 +290,29 @@
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="cx">     }
</span><del>-    newChild-&gt;m_firstChild = nullptr;
-    newChild-&gt;m_lastChild = nullptr;
-    newChild-&gt;m_countInParent = newChild-&gt;computeCountInParent();
-    newChild-&gt;resetRenderers();
</del><ins>+    newChild.m_firstChild = nullptr;
+    newChild.m_lastChild = nullptr;
+    newChild.m_countInParent = newChild.computeCountInParent();
+    newChild.resetRenderers();
</ins><span class="cx">     first-&gt;recount();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void CounterNode::removeChild(CounterNode* oldChild)
</del><ins>+void CounterNode::removeChild(CounterNode&amp; oldChild)
</ins><span class="cx"> {
</span><del>-    ASSERT(oldChild);
-    ASSERT(!oldChild-&gt;m_firstChild);
-    ASSERT(!oldChild-&gt;m_lastChild);
</del><ins>+    ASSERT(!oldChild.m_firstChild);
+    ASSERT(!oldChild.m_lastChild);
</ins><span class="cx"> 
</span><del>-    CounterNode* next = oldChild-&gt;m_nextSibling;
-    CounterNode* previous = oldChild-&gt;m_previousSibling;
</del><ins>+    CounterNode* next = oldChild.m_nextSibling;
+    CounterNode* previous = oldChild.m_previousSibling;
</ins><span class="cx"> 
</span><del>-    oldChild-&gt;m_nextSibling = nullptr;
-    oldChild-&gt;m_previousSibling = nullptr;
-    oldChild-&gt;m_parent = nullptr;
</del><ins>+    oldChild.m_nextSibling = nullptr;
+    oldChild.m_previousSibling = nullptr;
+    oldChild.m_parent = nullptr;
</ins><span class="cx"> 
</span><span class="cx">     if (previous) 
</span><span class="cx">         previous-&gt;m_nextSibling = next;
</span><span class="cx">     else {
</span><del>-        ASSERT(m_firstChild == oldChild);
</del><ins>+        ASSERT(m_firstChild == &amp;oldChild);
</ins><span class="cx">         m_firstChild = next;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -321,7 +319,7 @@
</span><span class="cx">     if (next)
</span><span class="cx">         next-&gt;m_previousSibling = previous;
</span><span class="cx">     else {
</span><del>-        ASSERT(m_lastChild == oldChild);
</del><ins>+        ASSERT(m_lastChild == &amp;oldChild);
</ins><span class="cx">         m_lastChild = previous;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingCounterNodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/CounterNode.h (208743 => 208744)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/CounterNode.h        2016-11-15 19:53:25 UTC (rev 208743)
+++ trunk/Source/WebCore/rendering/CounterNode.h        2016-11-15 20:12:26 UTC (rev 208744)
</span><span class="lines">@@ -64,10 +64,9 @@
</span><span class="cx">     CounterNode* nextInPreOrder(const CounterNode* stayWithin = nullptr) const;
</span><span class="cx">     CounterNode* nextInPreOrderAfterChildren(const CounterNode* stayWithin = nullptr) const;
</span><span class="cx"> 
</span><del>-    void insertAfter(CounterNode* newChild, CounterNode* beforeChild, const AtomicString&amp; identifier);
-
</del><ins>+    void insertAfter(CounterNode&amp; newChild, CounterNode* beforeChild, const AtomicString&amp; identifier);
</ins><span class="cx">     // identifier must match the identifier of this counter.
</span><del>-    void removeChild(CounterNode*);
</del><ins>+    void removeChild(CounterNode&amp;);
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     CounterNode(RenderElement&amp;, bool isReset, int value);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderCountercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderCounter.cpp (208743 => 208744)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderCounter.cpp        2016-11-15 19:53:25 UTC (rev 208743)
+++ trunk/Source/WebCore/rendering/RenderCounter.cpp        2016-11-15 20:12:26 UTC (rev 208744)
</span><span class="lines">@@ -308,7 +308,7 @@
</span><span class="cx">     RefPtr&lt;CounterNode&gt; newPreviousSibling;
</span><span class="cx">     RefPtr&lt;CounterNode&gt; newNode = CounterNode::create(renderer, isReset, value);
</span><span class="cx">     if (findPlaceForCounter(renderer, identifier, isReset, newParent, newPreviousSibling))
</span><del>-        newParent-&gt;insertAfter(newNode.get(), newPreviousSibling.get(), identifier);
</del><ins>+        newParent-&gt;insertAfter(*newNode, newPreviousSibling.get(), identifier);
</ins><span class="cx">     CounterMap* nodeMap;
</span><span class="cx">     if (renderer.hasCounterNodeMap())
</span><span class="cx">         nodeMap = counterMaps().get(&amp;renderer);
</span><span class="lines">@@ -337,7 +337,7 @@
</span><span class="cx">             continue;
</span><span class="cx">         if (stayWithin == parentOrPseudoHostElement(*currentRenderer) &amp;&amp; currentCounter-&gt;hasResetType())
</span><span class="cx">             break;
</span><del>-        newNode-&gt;insertAfter(currentCounter, newNode-&gt;lastChild(), identifier);
</del><ins>+        newNode-&gt;insertAfter(*currentCounter, newNode-&gt;lastChild(), identifier);
</ins><span class="cx">     }
</span><span class="cx">     return newNode.get();
</span><span class="cx"> }
</span><span class="lines">@@ -430,12 +430,12 @@
</span><span class="cx">     CounterNode* previous;
</span><span class="cx">     for (RefPtr&lt;CounterNode&gt; child = node-&gt;lastDescendant(); child &amp;&amp; child != node; child = previous) {
</span><span class="cx">         previous = child-&gt;previousInPreOrder();
</span><del>-        child-&gt;parent()-&gt;removeChild(child.get());
</del><ins>+        child-&gt;parent()-&gt;removeChild(*child);
</ins><span class="cx">         ASSERT(counterMaps().get(&amp;child-&gt;owner())-&gt;get(identifier) == child);
</span><span class="cx">         counterMaps().get(&amp;child-&gt;owner())-&gt;remove(identifier);
</span><span class="cx">     }
</span><span class="cx">     if (CounterNode* parent = node-&gt;parent())
</span><del>-        parent-&gt;removeChild(node);
</del><ins>+        parent-&gt;removeChild(*node);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderCounter::destroyCounterNodes(RenderElement&amp; owner)
</span><span class="lines">@@ -521,9 +521,9 @@
</span><span class="cx">         if (newParent == parent &amp;&amp; newPreviousSibling == node-&gt;previousSibling())
</span><span class="cx">             continue;
</span><span class="cx">         if (parent)
</span><del>-            parent-&gt;removeChild(node.get());
</del><ins>+            parent-&gt;removeChild(*node);
</ins><span class="cx">         if (newParent)
</span><del>-            newParent-&gt;insertAfter(node.get(), newPreviousSibling.get(), it-&gt;key);
</del><ins>+            newParent-&gt;insertAfter(*node, newPreviousSibling.get(), it-&gt;key);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>