<!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>[175210] 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/175210">175210</a></dd>
<dt>Author</dt> <dd>akling@apple.com</dd>
<dt>Date</dt> <dd>2014-10-26 13:20:31 -0700 (Sun, 26 Oct 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Move continuation teardown from subclasses to RenderBoxModelObject.
&lt;https://webkit.org/b/138081&gt;

Reviewed by Antti Koivisto.

Let RenderBoxModelObject::willBeDestroyed() tear down any continuation
instead of having every subclass do this themselves.

Also added a RenderElement bit tracking whether the renderer has a
continuation. This avoids a hash lookup every time we destroy a
RenderBoxModelObject that didn't have a continuation.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::willBeDestroyed):
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::willBeDestroyed):
* rendering/RenderBoxModelObject.cpp:
(WebCore::continuationMap):
(WebCore::RenderBoxModelObject::willBeDestroyed):
(WebCore::RenderBoxModelObject::continuation):
(WebCore::RenderBoxModelObject::setContinuation):
* rendering/RenderElement.cpp:
(WebCore::RenderElement::RenderElement):
* rendering/RenderElement.h:
(WebCore::RenderElement::setHasContinuation):
(WebCore::RenderElement::hasContinuation):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::willBeDestroyed):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockcpp">trunk/Source/WebCore/rendering/RenderBlock.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBlockFlowcpp">trunk/Source/WebCore/rendering/RenderBlockFlow.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderBoxModelObjectcpp">trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderElementcpp">trunk/Source/WebCore/rendering/RenderElement.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderElementh">trunk/Source/WebCore/rendering/RenderElement.h</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderInlinecpp">trunk/Source/WebCore/rendering/RenderInline.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (175209 => 175210)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-10-26 05:47:13 UTC (rev 175209)
+++ trunk/Source/WebCore/ChangeLog        2014-10-26 20:20:31 UTC (rev 175210)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2014-10-26  Andreas Kling  &lt;akling@apple.com&gt;
+
+        Move continuation teardown from subclasses to RenderBoxModelObject.
+        &lt;https://webkit.org/b/138081&gt;
+
+        Reviewed by Antti Koivisto.
+
+        Let RenderBoxModelObject::willBeDestroyed() tear down any continuation
+        instead of having every subclass do this themselves.
+
+        Also added a RenderElement bit tracking whether the renderer has a
+        continuation. This avoids a hash lookup every time we destroy a
+        RenderBoxModelObject that didn't have a continuation.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::willBeDestroyed):
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::willBeDestroyed):
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::continuationMap):
+        (WebCore::RenderBoxModelObject::willBeDestroyed):
+        (WebCore::RenderBoxModelObject::continuation):
+        (WebCore::RenderBoxModelObject::setContinuation):
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::RenderElement):
+        * rendering/RenderElement.h:
+        (WebCore::RenderElement::setHasContinuation):
+        (WebCore::RenderElement::hasContinuation):
+        * rendering/RenderInline.cpp:
+        (WebCore::RenderInline::willBeDestroyed):
+
</ins><span class="cx"> 2014-10-25  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove a useless variable from SelectorCodeGenerator::generateElementMatchesSelectorList()
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (175209 => 175210)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlock.cpp        2014-10-26 05:47:13 UTC (rev 175209)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp        2014-10-26 20:20:31 UTC (rev 175210)
</span><span class="lines">@@ -247,15 +247,6 @@
</span><span class="cx">     // properly dirty line boxes that they are removed from. Effects that do :before/:after only on hover could crash otherwise.
</span><span class="cx">     destroyLeftoverChildren();
</span><span class="cx"> 
</span><del>-    // Destroy our continuation before anything other than anonymous children.
-    // The reason we don't destroy it before anonymous children is that they may
-    // have continuations of their own that are anonymous children of our continuation.
-    RenderBoxModelObject* continuation = this-&gt;continuation();
-    if (continuation) {
-        continuation-&gt;destroy();
-        setContinuation(0);
-    }
-    
</del><span class="cx">     if (!documentBeingDestroyed()) {
</span><span class="cx">         if (parent())
</span><span class="cx">             parent()-&gt;dirtyLinesFromChangedChild(*this);
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBlockFlowcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (175209 => 175210)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2014-10-26 05:47:13 UTC (rev 175209)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp        2014-10-26 20:20:31 UTC (rev 175210)
</span><span class="lines">@@ -153,15 +153,6 @@
</span><span class="cx">     // properly dirty line boxes that they are removed from. Effects that do :before/:after only on hover could crash otherwise.
</span><span class="cx">     destroyLeftoverChildren();
</span><span class="cx"> 
</span><del>-    // Destroy our continuation before anything other than anonymous children.
-    // The reason we don't destroy it before anonymous children is that they may
-    // have continuations of their own that are anonymous children of our continuation.
-    RenderBoxModelObject* continuation = this-&gt;continuation();
-    if (continuation) {
-        continuation-&gt;destroy();
-        setContinuation(0);
-    }
-
</del><span class="cx">     if (!documentBeingDestroyed()) {
</span><span class="cx">         if (firstRootBox()) {
</span><span class="cx">             // We can't wait for RenderBox::destroy to clear the selection,
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderBoxModelObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp (175209 => 175210)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2014-10-26 05:47:13 UTC (rev 175209)
+++ trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp        2014-10-26 20:20:31 UTC (rev 175210)
</span><span class="lines">@@ -55,6 +55,7 @@
</span><span class="cx"> #include &quot;ScrollingConstraints.h&quot;
</span><span class="cx"> #include &quot;Settings.h&quot;
</span><span class="cx"> #include &quot;TransformState.h&quot;
</span><ins>+#include &lt;wtf/NeverDestroyed.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -68,7 +69,11 @@
</span><span class="cx"> // &lt;b&gt;&lt;i&gt;&lt;p&gt;Hello&lt;/p&gt;&lt;/i&gt;&lt;/b&gt;. In this example the &lt;i&gt; will have a block as
</span><span class="cx"> // its continuation but the &lt;b&gt; will just have an inline as its continuation.
</span><span class="cx"> typedef HashMap&lt;const RenderBoxModelObject*, RenderBoxModelObject*&gt; ContinuationMap;
</span><del>-static ContinuationMap* continuationMap = 0;
</del><ins>+static ContinuationMap&amp; continuationMap()
+{
+    static NeverDestroyed&lt;ContinuationMap&gt; map;
+    return map;
+}
</ins><span class="cx"> 
</span><span class="cx"> // This HashMap is similar to the continuation map, but connects first-letter
</span><span class="cx"> // renderers to their remaining text fragments.
</span><span class="lines">@@ -177,8 +182,10 @@
</span><span class="cx"> 
</span><span class="cx"> void RenderBoxModelObject::willBeDestroyed()
</span><span class="cx"> {
</span><del>-    // A continuation of this RenderObject should be destroyed at subclasses.
-    ASSERT(!continuation());
</del><ins>+    if (hasContinuation()) {
+        continuation()-&gt;destroy();
+        setContinuation(nullptr);
+    }
</ins><span class="cx"> 
</span><span class="cx">     // If this is a first-letter object with a remaining text fragment then the
</span><span class="cx">     // entry needs to be cleared from the map.
</span><span class="lines">@@ -2529,21 +2536,18 @@
</span><span class="cx"> 
</span><span class="cx"> RenderBoxModelObject* RenderBoxModelObject::continuation() const
</span><span class="cx"> {
</span><del>-    if (!continuationMap)
-        return 0;
-    return continuationMap-&gt;get(this);
</del><ins>+    if (!hasContinuation())
+        return nullptr;
+    return continuationMap().get(this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void RenderBoxModelObject::setContinuation(RenderBoxModelObject* continuation)
</span><span class="cx"> {
</span><del>-    if (continuation) {
-        if (!continuationMap)
-            continuationMap = new ContinuationMap;
-        continuationMap-&gt;set(this, continuation);
-    } else {
-        if (continuationMap)
-            continuationMap-&gt;remove(this);
-    }
</del><ins>+    if (continuation)
+        continuationMap().set(this, continuation);
+    else if (hasContinuation())
+        continuationMap().remove(this);
+    setHasContinuation(!!continuation);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RenderTextFragment* RenderBoxModelObject::firstLetterRemainingText() const
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderElement.cpp (175209 => 175210)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderElement.cpp        2014-10-26 05:47:13 UTC (rev 175209)
+++ trunk/Source/WebCore/rendering/RenderElement.cpp        2014-10-26 20:20:31 UTC (rev 175210)
</span><span class="lines">@@ -87,6 +87,7 @@
</span><span class="cx">     , m_hasPausedImageAnimations(false)
</span><span class="cx">     , m_hasCounterNodeMap(false)
</span><span class="cx">     , m_isCSSAnimating(false)
</span><ins>+    , m_hasContinuation(false)
</ins><span class="cx">     , m_firstChild(nullptr)
</span><span class="cx">     , m_lastChild(nullptr)
</span><span class="cx">     , m_style(WTF::move(style))
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderElement.h (175209 => 175210)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderElement.h        2014-10-26 05:47:13 UTC (rev 175209)
+++ trunk/Source/WebCore/rendering/RenderElement.h        2014-10-26 20:20:31 UTC (rev 175210)
</span><span class="lines">@@ -198,6 +198,9 @@
</span><span class="cx">     void setRenderInlineAlwaysCreatesLineBoxes(bool b) { m_renderInlineAlwaysCreatesLineBoxes = b; }
</span><span class="cx">     bool renderInlineAlwaysCreatesLineBoxes() const { return m_renderInlineAlwaysCreatesLineBoxes; }
</span><span class="cx"> 
</span><ins>+    void setHasContinuation(bool b) { m_hasContinuation = b; }
+    bool hasContinuation() const { return m_hasContinuation; }
+
</ins><span class="cx">     static bool hasControlStatesForRenderer(const RenderObject*);
</span><span class="cx">     static ControlStates* controlStatesForRenderer(const RenderObject*);
</span><span class="cx">     static void removeControlStatesForRenderer(const RenderObject*);
</span><span class="lines">@@ -237,6 +240,7 @@
</span><span class="cx">     unsigned m_hasPausedImageAnimations : 1;
</span><span class="cx">     unsigned m_hasCounterNodeMap : 1;
</span><span class="cx">     unsigned m_isCSSAnimating : 1;
</span><ins>+    unsigned m_hasContinuation : 1;
</ins><span class="cx"> 
</span><span class="cx">     RenderObject* m_firstChild;
</span><span class="cx">     RenderObject* m_lastChild;
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderInlinecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (175209 => 175210)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderInline.cpp        2014-10-26 05:47:13 UTC (rev 175209)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp        2014-10-26 20:20:31 UTC (rev 175210)
</span><span class="lines">@@ -81,15 +81,6 @@
</span><span class="cx">     // Make sure to destroy anonymous children first while they are still connected to the rest of the tree, so that they will
</span><span class="cx">     // properly dirty line boxes that they are removed from.  Effects that do :before/:after only on hover could crash otherwise.
</span><span class="cx">     destroyLeftoverChildren();
</span><del>-
-    // Destroy our continuation before anything other than anonymous children.
-    // The reason we don't destroy it before anonymous children is that they may
-    // have continuations of their own that are anonymous children of our continuation.
-    RenderBoxModelObject* continuation = this-&gt;continuation();
-    if (continuation) {
-        continuation-&gt;destroy();
-        setContinuation(nullptr);
-    }
</del><span class="cx">     
</span><span class="cx">     if (!documentBeingDestroyed()) {
</span><span class="cx">         if (firstLineBox()) {
</span></span></pre>
</div>
</div>

</body>
</html>