<!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>[150430] 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/150430">150430</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2013-05-21 01:40:41 -0700 (Tue, 21 May 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Simplify Shadow DOM distribution code
https://bugs.webkit.org/show_bug.cgi?id=116454

Reviewed by Andreas Kling.
        
Remove code supporting nested insertion points and distributing to multiple insertion points.
    
* html/HTMLDetailsElement.cpp:
(DetailsContentElement):
        
    Make distribution to &lt;details&gt; and &lt;summary&gt; mutually exclusive.

* html/shadow/ContentDistributor.cpp:
(WebCore):
(WebCore::ContentDistributor::distribute):
(WebCore::ContentDistributor::invalidate):
(WebCore::ContentDistributor::distributeSelectionsTo):
* html/shadow/ContentDistributor.h:
* html/shadow/InsertionPoint.cpp:
(WebCore::resolveReprojection):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLDetailsElementcpp">trunk/Source/WebCore/html/HTMLDetailsElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlshadowContentDistributorcpp">trunk/Source/WebCore/html/shadow/ContentDistributor.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlshadowContentDistributorh">trunk/Source/WebCore/html/shadow/ContentDistributor.h</a></li>
<li><a href="#trunkSourceWebCorehtmlshadowInsertionPointcpp">trunk/Source/WebCore/html/shadow/InsertionPoint.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (150429 => 150430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-05-21 08:07:40 UTC (rev 150429)
+++ trunk/Source/WebCore/ChangeLog        2013-05-21 08:40:41 UTC (rev 150430)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2013-05-20  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Simplify Shadow DOM distribution code
+        https://bugs.webkit.org/show_bug.cgi?id=116454
+
+        Reviewed by Andreas Kling.
+        
+        Remove code supporting nested insertion points and distributing to multiple insertion points.
+    
+        * html/HTMLDetailsElement.cpp:
+        (DetailsContentElement):
+        
+            Make distribution to &lt;details&gt; and &lt;summary&gt; mutually exclusive.
+
+        * html/shadow/ContentDistributor.cpp:
+        (WebCore):
+        (WebCore::ContentDistributor::distribute):
+        (WebCore::ContentDistributor::invalidate):
+        (WebCore::ContentDistributor::distributeSelectionsTo):
+        * html/shadow/ContentDistributor.h:
+        * html/shadow/InsertionPoint.cpp:
+        (WebCore::resolveReprojection):
+
</ins><span class="cx"> 2013-05-21  Mihnea Ovidenie  &lt;mihnea@adobe.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [CSSRegions] Constrain auto-height region computation in a different way
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLDetailsElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLDetailsElement.cpp (150429 => 150430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLDetailsElement.cpp        2013-05-21 08:07:40 UTC (rev 150429)
+++ trunk/Source/WebCore/html/HTMLDetailsElement.cpp        2013-05-21 08:40:41 UTC (rev 150430)
</span><span class="lines">@@ -51,6 +51,13 @@
</span><span class="cx">         : HTMLContentElement(HTMLNames::webkitShadowContentTag, document)
</span><span class="cx">     {
</span><span class="cx">     }
</span><ins>+
+    virtual MatchType matchTypeFor(Node* node) OVERRIDE
+    {
+        if (node-&gt;isElementNode() &amp;&amp; node == node-&gt;parentNode()-&gt;querySelector(summaryQuerySelector(), ASSERT_NO_EXCEPTION))
+            return NeverMatches;
+        return AlwaysMatches;
+    }
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> PassRefPtr&lt;DetailsContentElement&gt; DetailsContentElement::create(Document* document)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlshadowContentDistributorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/shadow/ContentDistributor.cpp (150429 => 150430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/shadow/ContentDistributor.cpp        2013-05-21 08:07:40 UTC (rev 150429)
+++ trunk/Source/WebCore/html/shadow/ContentDistributor.cpp        2013-05-21 08:40:41 UTC (rev 150430)
</span><span class="lines">@@ -125,23 +125,6 @@
</span><span class="cx">     return m_nodeToInsertionPoint.get(key);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ContentDistributor::populate(Node* node, ContentDistribution&amp; pool)
-{
-    if (!isActiveInsertionPoint(node)) {
-        pool.append(node);
-        return;
-    }
-
-    InsertionPoint* insertionPoint = toInsertionPoint(node);
-    if (insertionPoint-&gt;hasDistribution()) {
-        for (size_t i = 0; i &lt; insertionPoint-&gt;size(); ++i)
-            populate(insertionPoint-&gt;at(i), pool);
-    } else {
-        for (Node* fallbackNode = insertionPoint-&gt;firstChild(); fallbackNode; fallbackNode = fallbackNode-&gt;nextSibling())
-            pool.append(fallbackNode);
-    }
-}
-
</del><span class="cx"> void ContentDistributor::distribute(Element* host)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(needsDistribution());
</span><span class="lines">@@ -150,13 +133,6 @@
</span><span class="cx"> 
</span><span class="cx">     m_validity = Valid;
</span><span class="cx"> 
</span><del>-    ContentDistribution pool;
-    for (Node* node = host-&gt;firstChild(); node; node = node-&gt;nextSibling())
-        populate(node, pool);
-
-    Vector&lt;bool&gt; distributed(pool.size());
-    distributed.fill(false);
-
</del><span class="cx">     if (ShadowRoot* root = host-&gt;shadowRoot()) {
</span><span class="cx">         if (ScopeContentDistribution* scope = root-&gt;scopeDistribution()) {
</span><span class="cx">             const Vector&lt;RefPtr&lt;InsertionPoint&gt; &gt;&amp; insertionPoints = scope-&gt;ensureInsertionPointList(root);
</span><span class="lines">@@ -165,9 +141,7 @@
</span><span class="cx">                 if (!point-&gt;isActive())
</span><span class="cx">                     continue;
</span><span class="cx"> 
</span><del>-                distributeSelectionsTo(point, pool, distributed);
-                if (ElementShadow* shadow = point-&gt;parentNode()-&gt;isElementNode() ? toElement(point-&gt;parentNode())-&gt;shadow() : 0)
-                    shadow-&gt;invalidateDistribution();
</del><ins>+                distributeSelectionsTo(point, host);
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -184,15 +158,6 @@
</span><span class="cx">             for (size_t i = 0; i &lt; insertionPoints.size(); ++i) {
</span><span class="cx">                 needsReattach = needsReattach || true;
</span><span class="cx">                 insertionPoints[i]-&gt;clearDistribution();
</span><del>-
-                // After insertionPoint's distribution is invalidated, its reprojection should also be invalidated.
-                if (!insertionPoints[i]-&gt;isActive())
-                    continue;
-
-                if (Element* parent = insertionPoints[i]-&gt;parentElement()) {
-                    if (ElementShadow* shadow = parent-&gt;shadow())
-                        shadow-&gt;invalidateDistribution();
-                }
</del><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -202,21 +167,18 @@
</span><span class="cx">     return needsReattach;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ContentDistributor::distributeSelectionsTo(InsertionPoint* insertionPoint, const ContentDistribution&amp; pool, Vector&lt;bool&gt;&amp; distributed)
</del><ins>+void ContentDistributor::distributeSelectionsTo(InsertionPoint* insertionPoint, Element* host)
</ins><span class="cx"> {
</span><span class="cx">     ContentDistribution distribution;
</span><span class="cx"> 
</span><del>-    for (size_t i = 0; i &lt; pool.size(); ++i) {
-        if (distributed[i])
-            continue;
</del><ins>+    for (Node* child = host-&gt;firstChild(); child; child = child-&gt;nextSibling()) {
+        ASSERT(!child-&gt;isInsertionPoint());
</ins><span class="cx"> 
</span><del>-        if (insertionPoint-&gt;matchTypeFor(pool.nodes().at(i).get()) != InsertionPoint::AlwaysMatches)
</del><ins>+        if (insertionPoint-&gt;matchTypeFor(child) != InsertionPoint::AlwaysMatches)
</ins><span class="cx">             continue;
</span><span class="cx"> 
</span><del>-        Node* child = pool.at(i).get();
</del><span class="cx">         distribution.append(child);
</span><span class="cx">         m_nodeToInsertionPoint.add(child, insertionPoint);
</span><del>-        distributed[i] = true;
</del><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     insertionPoint-&gt;setDistribution(distribution);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlshadowContentDistributorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/shadow/ContentDistributor.h (150429 => 150430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/shadow/ContentDistributor.h        2013-05-21 08:07:40 UTC (rev 150429)
+++ trunk/Source/WebCore/html/shadow/ContentDistributor.h        2013-05-21 08:40:41 UTC (rev 150430)
</span><span class="lines">@@ -100,7 +100,7 @@
</span><span class="cx"> 
</span><span class="cx">     InsertionPoint* findInsertionPointFor(const Node* key) const;
</span><span class="cx"> 
</span><del>-    void distributeSelectionsTo(InsertionPoint*, const ContentDistribution&amp; pool, Vector&lt;bool&gt;&amp; distributed);
</del><ins>+    void distributeSelectionsTo(InsertionPoint*, Element* host);
</ins><span class="cx"> 
</span><span class="cx">     void invalidateDistribution(Element* host);
</span><span class="cx">     void didShadowBoundaryChange(Element* host);
</span><span class="lines">@@ -110,7 +110,6 @@
</span><span class="cx"> private:
</span><span class="cx">     void distribute(Element* host);
</span><span class="cx">     bool invalidate(Element* host);
</span><del>-    void populate(Node*, ContentDistribution&amp;);
</del><span class="cx"> 
</span><span class="cx">     void setValidity(Validity validity) { m_validity = validity; }
</span><span class="cx">     bool isValid() const { return m_validity == Valid; }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlshadowInsertionPointcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.cpp (150429 => 150430)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/shadow/InsertionPoint.cpp        2013-05-21 08:07:40 UTC (rev 150429)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.cpp        2013-05-21 08:40:41 UTC (rev 150430)
</span><span class="lines">@@ -197,23 +197,12 @@
</span><span class="cx"> 
</span><span class="cx"> InsertionPoint* resolveReprojection(const Node* projectedNode)
</span><span class="cx"> {
</span><del>-    InsertionPoint* insertionPoint = 0;
-    const Node* current = projectedNode;
-
-    while (current) {
-        if (ElementShadow* shadow = shadowOfParentForDistribution(current)) {
-            if (ShadowRoot* root = current-&gt;containingShadowRoot())
-                ContentDistributor::ensureDistribution(root);
-            if (InsertionPoint* insertedTo = shadow-&gt;distributor().findInsertionPointFor(projectedNode)) {
-                current = insertedTo;
-                insertionPoint = insertedTo;
-                continue;
-            }
-        }
-        break;
</del><ins>+    if (ElementShadow* shadow = shadowOfParentForDistribution(projectedNode)) {
+        if (ShadowRoot* root = projectedNode-&gt;containingShadowRoot())
+            ContentDistributor::ensureDistribution(root);
+        return shadow-&gt;distributor().findInsertionPointFor(projectedNode);
</ins><span class="cx">     }
</span><del>-
-    return insertionPoint;
</del><ins>+    return 0;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre>
</div>
</div>

</body>
</html>