<!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>[189824] 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/189824">189824</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2015-09-15 14:31:31 -0700 (Tue, 15 Sep 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>ContentDistribution should be only used for details elements
https://bugs.webkit.org/show_bug.cgi?id=149148

Reviewed by Antti Koivisto.

Extracted ShadowRootWithInsertionPoints out of ShadowRoot for HTMLDetailsElement and HTMLSummaryElement.

We don't add a separate .h and .cpp files since this is a temporary measure until we replace it with
a slot-based shadow DOM implementation.

No new tests. There should be no observable behavioral change.

* dom/Element.cpp:
(WebCore::Element::addShadowRoot): Removed the call to didShadowBoundaryChange since this function is only
called in ensureUserAgentShadowRoot. Also moved the call to didAddUserAgentShadowRoot for
HTMLDetailsElement's shadow root which uses this function instead of ensureUserAgentShadowRoot.
(WebCore::Element::removeShadowRoot): Removed the call to invalidateDistribution since it's only called by
~Element.
(WebCore::Element::createShadowRoot):
(WebCore::Element::ensureUserAgentShadowRoot): Moved the call didAddUserAgentShadowRoot into addShadowRoot
since HTMLDetailsElement uses a subclass of ShadowRoot.
(WebCore::Element::childrenChanged):
(WebCore::Element::removeAllEventListeners):

* dom/Element.h:
(Element::addShadowRoot): Made this function a protected member as it's now used by HTMLDetailsElement.

* dom/ShadowRoot.cpp:
(WebCore::ShadowRoot::childrenChanged): Deleted.

* dom/ShadowRoot.h:
(WebCore::ShadowRoot::distributor): Made this a virtual function and return nullptr by default.
(WebCore::ShadowRoot::isOrphan):

* html/HTMLDetailsElement.cpp:
(WebCore::HTMLDetailsElement::create): Uses ShadowRootWithInsertionPoints instead of ShadowRoot.

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::runPostTypeUpdateTasks): Removed the call to invalidateDistribution since it's
only relevant for HTMLDetailsElement's shadow DOM.

* html/HTMLSummaryElement.cpp:
(WebCore::HTMLSummaryElement::create): Uses ShadowRootWithInsertionPoints instead of ShadowRoot.

* html/shadow/ContentDistributor.cpp:
(WebCore::ContentDistributor::distribute):
(WebCore::ContentDistributor::ensureDistribution):
(WebCore::ContentDistributor::invalidateDistribution):

* html/shadow/InsertionPoint.cpp:
(WebCore::InsertionPoint::childrenChanged):
(WebCore::InsertionPoint::insertedInto):
(WebCore::InsertionPoint::removedFrom):
(WebCore::findInsertionPointOf):
(WebCore::ShadowRootWithInsertionPoints::childrenChanged): Moved from ShadowRoot.

* html/shadow/InsertionPoint.h:
(WebCore::ShadowRootWithInsertionPoints::create): Added.
(WebCore::ShadowRootWithInsertionPoints::ShadowRootWithInsertionPoints): Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomElementcpp">trunk/Source/WebCore/dom/Element.cpp</a></li>
<li><a href="#trunkSourceWebCoredomElementh">trunk/Source/WebCore/dom/Element.h</a></li>
<li><a href="#trunkSourceWebCoredomShadowRootcpp">trunk/Source/WebCore/dom/ShadowRoot.cpp</a></li>
<li><a href="#trunkSourceWebCoredomShadowRooth">trunk/Source/WebCore/dom/ShadowRoot.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLDetailsElementcpp">trunk/Source/WebCore/html/HTMLDetailsElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLInputElementcpp">trunk/Source/WebCore/html/HTMLInputElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLSummaryElementcpp">trunk/Source/WebCore/html/HTMLSummaryElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlshadowContentDistributorcpp">trunk/Source/WebCore/html/shadow/ContentDistributor.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlshadowInsertionPointcpp">trunk/Source/WebCore/html/shadow/InsertionPoint.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlshadowInsertionPointh">trunk/Source/WebCore/html/shadow/InsertionPoint.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (189823 => 189824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-09-15 20:42:22 UTC (rev 189823)
+++ trunk/Source/WebCore/ChangeLog        2015-09-15 21:31:31 UTC (rev 189824)
</span><span class="lines">@@ -1,3 +1,65 @@
</span><ins>+2015-09-15  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        ContentDistribution should be only used for details elements
+        https://bugs.webkit.org/show_bug.cgi?id=149148
+
+        Reviewed by Antti Koivisto.
+
+        Extracted ShadowRootWithInsertionPoints out of ShadowRoot for HTMLDetailsElement and HTMLSummaryElement.
+
+        We don't add a separate .h and .cpp files since this is a temporary measure until we replace it with
+        a slot-based shadow DOM implementation.
+
+        No new tests. There should be no observable behavioral change.
+
+        * dom/Element.cpp:
+        (WebCore::Element::addShadowRoot): Removed the call to didShadowBoundaryChange since this function is only
+        called in ensureUserAgentShadowRoot. Also moved the call to didAddUserAgentShadowRoot for
+        HTMLDetailsElement's shadow root which uses this function instead of ensureUserAgentShadowRoot.
+        (WebCore::Element::removeShadowRoot): Removed the call to invalidateDistribution since it's only called by
+        ~Element.
+        (WebCore::Element::createShadowRoot):
+        (WebCore::Element::ensureUserAgentShadowRoot): Moved the call didAddUserAgentShadowRoot into addShadowRoot
+        since HTMLDetailsElement uses a subclass of ShadowRoot.
+        (WebCore::Element::childrenChanged):
+        (WebCore::Element::removeAllEventListeners):
+
+        * dom/Element.h:
+        (Element::addShadowRoot): Made this function a protected member as it's now used by HTMLDetailsElement.
+
+        * dom/ShadowRoot.cpp:
+        (WebCore::ShadowRoot::childrenChanged): Deleted.
+
+        * dom/ShadowRoot.h:
+        (WebCore::ShadowRoot::distributor): Made this a virtual function and return nullptr by default.
+        (WebCore::ShadowRoot::isOrphan):
+
+        * html/HTMLDetailsElement.cpp:
+        (WebCore::HTMLDetailsElement::create): Uses ShadowRootWithInsertionPoints instead of ShadowRoot.
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::runPostTypeUpdateTasks): Removed the call to invalidateDistribution since it's
+        only relevant for HTMLDetailsElement's shadow DOM.
+
+        * html/HTMLSummaryElement.cpp:
+        (WebCore::HTMLSummaryElement::create): Uses ShadowRootWithInsertionPoints instead of ShadowRoot.
+
+        * html/shadow/ContentDistributor.cpp:
+        (WebCore::ContentDistributor::distribute):
+        (WebCore::ContentDistributor::ensureDistribution):
+        (WebCore::ContentDistributor::invalidateDistribution):
+
+        * html/shadow/InsertionPoint.cpp:
+        (WebCore::InsertionPoint::childrenChanged):
+        (WebCore::InsertionPoint::insertedInto):
+        (WebCore::InsertionPoint::removedFrom):
+        (WebCore::findInsertionPointOf):
+        (WebCore::ShadowRootWithInsertionPoints::childrenChanged): Moved from ShadowRoot.
+
+        * html/shadow/InsertionPoint.h:
+        (WebCore::ShadowRootWithInsertionPoints::create): Added.
+        (WebCore::ShadowRootWithInsertionPoints::ShadowRootWithInsertionPoints): Added.
+
</ins><span class="cx"> 2015-09-15  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Win] Tiled drawing is rendering more times than it should
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.cpp (189823 => 189824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.cpp        2015-09-15 20:42:22 UTC (rev 189823)
+++ trunk/Source/WebCore/dom/Element.cpp        2015-09-15 21:31:31 UTC (rev 189824)
</span><span class="lines">@@ -1613,7 +1613,6 @@
</span><span class="cx"> 
</span><span class="cx">     shadowRoot.setHost(this);
</span><span class="cx">     shadowRoot.setParentTreeScope(&amp;treeScope());
</span><del>-    shadowRoot.distributor().didShadowBoundaryChange(this);
</del><span class="cx"> 
</span><span class="cx">     NodeVector postInsertionNotificationTargets;
</span><span class="cx">     ChildNodeInsertionNotifier(*this).notify(shadowRoot, postInsertionNotificationTargets);
</span><span class="lines">@@ -1626,6 +1625,9 @@
</span><span class="cx">     setNeedsStyleRecalc(ReconstructRenderTree);
</span><span class="cx"> 
</span><span class="cx">     InspectorInstrumentation::didPushShadowRoot(*this, shadowRoot);
</span><ins>+
+    if (shadowRoot.type() == ShadowRoot::UserAgentShadowRoot)
+        didAddUserAgentShadowRoot(&amp;shadowRoot);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Element::removeShadowRoot()
</span><span class="lines">@@ -1644,8 +1646,6 @@
</span><span class="cx">     oldRoot-&gt;setParentTreeScope(&amp;document());
</span><span class="cx"> 
</span><span class="cx">     ChildNodeRemovalNotifier(*this).notify(*oldRoot);
</span><del>-
-    oldRoot-&gt;distributor().invalidateDistribution(this);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> RefPtr&lt;ShadowRoot&gt; Element::createShadowRoot(ExceptionCode&amp; ec)
</span><span class="lines">@@ -1672,7 +1672,6 @@
</span><span class="cx">     if (!shadowRoot) {
</span><span class="cx">         addShadowRoot(ShadowRoot::create(document(), ShadowRoot::UserAgentShadowRoot));
</span><span class="cx">         shadowRoot = userAgentShadowRoot();
</span><del>-        didAddUserAgentShadowRoot(shadowRoot);
</del><span class="cx">     }
</span><span class="cx">     return *shadowRoot;
</span><span class="cx"> }
</span><span class="lines">@@ -1795,8 +1794,10 @@
</span><span class="cx">         checkForSiblingStyleChanges(*this, checkType, change.previousSiblingElement, change.nextSiblingElement);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (ShadowRoot* shadowRoot = this-&gt;shadowRoot())
-        shadowRoot-&gt;invalidateDistribution();
</del><ins>+    if (ShadowRoot* shadowRoot = this-&gt;shadowRoot()) {
+        if (auto* distributor = shadowRoot-&gt;distributor())
+            distributor-&gt;invalidateDistribution(this);
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void Element::removeAllEventListeners()
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.h (189823 => 189824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.h        2015-09-15 20:42:22 UTC (rev 189823)
+++ trunk/Source/WebCore/dom/Element.h        2015-09-15 21:31:31 UTC (rev 189824)
</span><span class="lines">@@ -500,6 +500,8 @@
</span><span class="cx">     // svgAttributeChanged (called when element.className.baseValue is set)
</span><span class="cx">     void classAttributeChanged(const AtomicString&amp; newClassString);
</span><span class="cx"> 
</span><ins>+    void addShadowRoot(Ref&lt;ShadowRoot&gt;&amp;&amp;);
+
</ins><span class="cx">     static void mergeWithNextTextNode(Text&amp; node, ExceptionCode&amp;);
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="lines">@@ -564,7 +566,6 @@
</span><span class="cx">     virtual Ref&lt;Node&gt; cloneNodeInternal(Document&amp;, CloningOperation) override;
</span><span class="cx">     virtual Ref&lt;Element&gt; cloneElementWithoutAttributesAndChildren(Document&amp;);
</span><span class="cx"> 
</span><del>-    void addShadowRoot(Ref&lt;ShadowRoot&gt;&amp;&amp;);
</del><span class="cx">     void removeShadowRoot();
</span><span class="cx"> 
</span><span class="cx">     bool rareDataStyleAffectedByEmpty() const;
</span></span></pre></div>
<a id="trunkSourceWebCoredomShadowRootcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (189823 => 189824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ShadowRoot.cpp        2015-09-15 20:42:22 UTC (rev 189823)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp        2015-09-15 21:31:31 UTC (rev 189824)
</span><span class="lines">@@ -38,7 +38,6 @@
</span><span class="cx"> 
</span><span class="cx"> struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope {
</span><span class="cx">     unsigned countersAndFlags[1];
</span><del>-    ContentDistributor distributor;
</del><span class="cx">     void* host;
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="lines">@@ -122,15 +121,6 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void ShadowRoot::childrenChanged(const ChildChange&amp; change)
-{
-    if (isOrphan())
-        return;
-
-    ContainerNode::childrenChanged(change);
-    invalidateDistribution();
-}
-
</del><span class="cx"> Ref&lt;Node&gt; ShadowRoot::cloneNodeInternal(Document&amp;, CloningOperation)
</span><span class="cx"> {
</span><span class="cx">     RELEASE_ASSERT_NOT_REACHED();
</span></span></pre></div>
<a id="trunkSourceWebCoredomShadowRooth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ShadowRoot.h (189823 => 189824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ShadowRoot.h        2015-09-15 20:42:22 UTC (rev 189823)
+++ trunk/Source/WebCore/dom/ShadowRoot.h        2015-09-15 21:31:31 UTC (rev 189824)
</span><span class="lines">@@ -28,7 +28,6 @@
</span><span class="cx"> #define ShadowRoot_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;ContainerNode.h&quot;
</span><del>-#include &quot;ContentDistributor.h&quot;
</del><span class="cx"> #include &quot;Document.h&quot;
</span><span class="cx"> #include &quot;DocumentFragment.h&quot;
</span><span class="cx"> #include &quot;Element.h&quot;
</span><span class="lines">@@ -37,7 +36,9 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class ShadowRoot final : public DocumentFragment, public TreeScope {
</del><ins>+class ContentDistributor;
+
+class ShadowRoot : public DocumentFragment, public TreeScope {
</ins><span class="cx"> public:
</span><span class="cx">     enum ShadowRootType {
</span><span class="cx">         UserAgentShadowRoot = 0,
</span><span class="lines">@@ -65,28 +66,25 @@
</span><span class="cx"> 
</span><span class="cx">     PassRefPtr&lt;Node&gt; cloneNode(bool, ExceptionCode&amp;);
</span><span class="cx"> 
</span><del>-    ContentDistributor&amp; distributor() { return m_distributor; }
-    void invalidateDistribution() { m_distributor.invalidateDistribution(m_host); }
-
</del><span class="cx">     virtual void removeAllEventListeners() override;
</span><span class="cx"> 
</span><del>-private:
</del><ins>+    virtual ContentDistributor* distributor() { return nullptr; }
+
+protected:
</ins><span class="cx">     ShadowRoot(Document&amp;, ShadowRootType);
</span><span class="cx"> 
</span><ins>+    // FIXME: This shouldn't happen. https://bugs.webkit.org/show_bug.cgi?id=88834
+    bool isOrphan() const { return !m_host; }
+
+private:
</ins><span class="cx">     virtual bool childTypeAllowed(NodeType) const override;
</span><del>-    virtual void childrenChanged(const ChildChange&amp;) override;
</del><span class="cx"> 
</span><span class="cx">     virtual Ref&lt;Node&gt; cloneNodeInternal(Document&amp;, CloningOperation) override;
</span><span class="cx"> 
</span><del>-    // FIXME: This shouldn't happen. https://bugs.webkit.org/show_bug.cgi?id=88834
-    bool isOrphan() const { return !m_host; }
-
</del><span class="cx">     unsigned m_resetStyleInheritance : 1;
</span><span class="cx">     unsigned m_type : 1;
</span><span class="cx"> 
</span><span class="cx">     Element* m_host;
</span><del>-
-    ContentDistributor m_distributor;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> inline Element* ShadowRoot::activeElement() const
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLDetailsElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLDetailsElement.cpp (189823 => 189824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLDetailsElement.cpp        2015-09-15 20:42:22 UTC (rev 189823)
+++ trunk/Source/WebCore/html/HTMLDetailsElement.cpp        2015-09-15 21:31:31 UTC (rev 189824)
</span><span class="lines">@@ -23,6 +23,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(DETAILS_ELEMENT)
</span><span class="cx"> #include &quot;AXObjectCache.h&quot;
</span><ins>+#include &quot;ContentDistributor.h&quot;
</ins><span class="cx"> #include &quot;ElementIterator.h&quot;
</span><span class="cx"> #include &quot;HTMLSummaryElement.h&quot;
</span><span class="cx"> #include &quot;InsertionPoint.h&quot;
</span><span class="lines">@@ -101,7 +102,7 @@
</span><span class="cx"> Ref&lt;HTMLDetailsElement&gt; HTMLDetailsElement::create(const QualifiedName&amp; tagName, Document&amp; document)
</span><span class="cx"> {
</span><span class="cx">     Ref&lt;HTMLDetailsElement&gt; details = adoptRef(*new HTMLDetailsElement(tagName, document));
</span><del>-    details-&gt;ensureUserAgentShadowRoot();
</del><ins>+    details-&gt;addShadowRoot(ShadowRootWithInsertionPoints::create(document));
</ins><span class="cx">     return details;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLInputElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (189823 => 189824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLInputElement.cpp        2015-09-15 20:42:22 UTC (rev 189823)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp        2015-09-15 21:31:31 UTC (rev 189824)
</span><span class="lines">@@ -531,9 +531,6 @@
</span><span class="cx">     if (document().focusedElement() == this)
</span><span class="cx">         updateFocusAppearance(true);
</span><span class="cx"> 
</span><del>-    if (ShadowRoot* shadowRoot = shadowRootOfParentForDistribution(this))
-        shadowRoot-&gt;invalidateDistribution();
-
</del><span class="cx">     setChangedSinceLastFormControlChangeEvent(false);
</span><span class="cx"> 
</span><span class="cx">     addToRadioButtonGroup();
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLSummaryElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLSummaryElement.cpp (189823 => 189824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLSummaryElement.cpp        2015-09-15 20:42:22 UTC (rev 189823)
+++ trunk/Source/WebCore/html/HTMLSummaryElement.cpp        2015-09-15 21:31:31 UTC (rev 189824)
</span><span class="lines">@@ -55,7 +55,7 @@
</span><span class="cx"> Ref&lt;HTMLSummaryElement&gt; HTMLSummaryElement::create(const QualifiedName&amp; tagName, Document&amp; document)
</span><span class="cx"> {
</span><span class="cx">     Ref&lt;HTMLSummaryElement&gt; summary = adoptRef(*new HTMLSummaryElement(tagName, document));
</span><del>-    summary-&gt;ensureUserAgentShadowRoot();
</del><ins>+    summary-&gt;addShadowRoot(ShadowRootWithInsertionPoints::create(document));
</ins><span class="cx">     return summary;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlshadowContentDistributorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/shadow/ContentDistributor.cpp (189823 => 189824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/shadow/ContentDistributor.cpp        2015-09-15 20:42:22 UTC (rev 189823)
+++ trunk/Source/WebCore/html/shadow/ContentDistributor.cpp        2015-09-15 21:31:31 UTC (rev 189824)
</span><span class="lines">@@ -71,7 +71,9 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(needsDistribution());
</span><span class="cx">     ASSERT(m_nodeToInsertionPoint.isEmpty());
</span><del>-    ASSERT(!host-&gt;containingShadowRoot() || host-&gt;containingShadowRoot()-&gt;distributor().isValid());
</del><ins>+    ASSERT(!host-&gt;containingShadowRoot()
+        || !host-&gt;containingShadowRoot()-&gt;distributor()
+        || host-&gt;containingShadowRoot()-&gt;distributor()-&gt;isValid());
</ins><span class="cx"> 
</span><span class="cx">     m_validity = Valid;
</span><span class="cx"> 
</span><span class="lines">@@ -128,13 +130,13 @@
</span><span class="cx">     Vector&lt;ShadowRoot*, 8&gt; shadowRoots;
</span><span class="cx">     for (Element* current = shadowRoot-&gt;host(); current; current = current-&gt;shadowHost()) {
</span><span class="cx">         ShadowRoot* currentRoot = current-&gt;shadowRoot();
</span><del>-        if (!currentRoot-&gt;distributor().needsDistribution())
</del><ins>+        if (!currentRoot-&gt;distributor() || !currentRoot-&gt;distributor()-&gt;needsDistribution())
</ins><span class="cx">             break;
</span><span class="cx">         shadowRoots.append(currentRoot);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     for (size_t i = shadowRoots.size(); i &gt; 0; --i)
</span><del>-        shadowRoots[i - 1]-&gt;distributor().distribute(shadowRoots[i - 1]-&gt;host());
</del><ins>+        shadowRoots[i - 1]-&gt;distributor()-&gt;distribute(shadowRoots[i - 1]-&gt;host());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ContentDistributor::invalidateDistribution(Element* host)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlshadowInsertionPointcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.cpp (189823 => 189824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/shadow/InsertionPoint.cpp        2015-09-15 20:42:22 UTC (rev 189823)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.cpp        2015-09-15 21:31:31 UTC (rev 189824)
</span><span class="lines">@@ -76,8 +76,10 @@
</span><span class="cx"> void InsertionPoint::childrenChanged(const ChildChange&amp; change)
</span><span class="cx"> {
</span><span class="cx">     HTMLElement::childrenChanged(change);
</span><del>-    if (ShadowRoot* root = containingShadowRoot())
-        root-&gt;invalidateDistribution();
</del><ins>+    if (ShadowRoot* root = containingShadowRoot()) {
+        RELEASE_ASSERT(root-&gt;distributor());
+        root-&gt;distributor()-&gt;invalidateDistribution(root-&gt;host());
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Node::InsertionNotificationRequest InsertionPoint::insertedInto(ContainerNode&amp; insertionPoint)
</span><span class="lines">@@ -85,8 +87,9 @@
</span><span class="cx">     HTMLElement::insertedInto(insertionPoint);
</span><span class="cx"> 
</span><span class="cx">     if (ShadowRoot* root = containingShadowRoot()) {
</span><del>-        root-&gt;distributor().didShadowBoundaryChange(root-&gt;host());
-        root-&gt;distributor().invalidateInsertionPointList();
</del><ins>+        RELEASE_ASSERT(root-&gt;distributor());
+        root-&gt;distributor()-&gt;didShadowBoundaryChange(root-&gt;host());
+        root-&gt;distributor()-&gt;invalidateInsertionPointList();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     return InsertionDone;
</span><span class="lines">@@ -99,8 +102,9 @@
</span><span class="cx">         root = insertionPoint.containingShadowRoot();
</span><span class="cx"> 
</span><span class="cx">     if (root &amp;&amp; root-&gt;host()) {
</span><del>-        root-&gt;invalidateDistribution();
-        root-&gt;distributor().invalidateInsertionPointList();
</del><ins>+        RELEASE_ASSERT(root-&gt;distributor());
+        root-&gt;distributor()-&gt;invalidateDistribution(root-&gt;host());
+        root-&gt;distributor()-&gt;invalidateInsertionPointList();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Since this insertion point is no longer visible from the shadow subtree, it need to clean itself up.
</span><span class="lines">@@ -154,9 +158,18 @@
</span><span class="cx">     if (ShadowRoot* shadowRoot = shadowRootOfParentForDistribution(projectedNode)) {
</span><span class="cx">         if (ShadowRoot* root = projectedNode-&gt;containingShadowRoot())
</span><span class="cx">             ContentDistributor::ensureDistribution(root);
</span><del>-        return shadowRoot-&gt;distributor().findInsertionPointFor(projectedNode);
</del><ins>+        if (auto* distributor = shadowRoot-&gt;distributor())
+            return distributor-&gt;findInsertionPointFor(projectedNode);
</ins><span class="cx">     }
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ShadowRootWithInsertionPoints::childrenChanged(const ChildChange&amp; change)
+{
+    ContainerNode::childrenChanged(change);
+    
+    if (!isOrphan())
+        m_distributor.invalidateDistribution(host());
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlshadowInsertionPointh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/shadow/InsertionPoint.h (189823 => 189824)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/shadow/InsertionPoint.h        2015-09-15 20:42:22 UTC (rev 189823)
+++ trunk/Source/WebCore/html/shadow/InsertionPoint.h        2015-09-15 21:31:31 UTC (rev 189824)
</span><span class="lines">@@ -75,6 +75,26 @@
</span><span class="cx">     bool m_hasDistribution;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+class ShadowRootWithInsertionPoints : public ShadowRoot {
+public:
+    
+    static Ref&lt;ShadowRootWithInsertionPoints&gt; create(Document&amp; document)
+    {
+        return adoptRef(*new ShadowRootWithInsertionPoints(document));
+    }
+    
+    virtual ContentDistributor* distributor() override { return &amp;m_distributor; }
+    
+private:
+    ShadowRootWithInsertionPoints(Document&amp; document)
+        : ShadowRoot(document, UserAgentShadowRoot)
+    { }
+
+    virtual void childrenChanged(const ChildChange&amp;) override;
+
+    ContentDistributor m_distributor;
+};
+
</ins><span class="cx"> inline bool isActiveInsertionPoint(const Node* node)
</span><span class="cx"> {
</span><span class="cx">     return is&lt;InsertionPoint&gt;(node) &amp;&amp; downcast&lt;InsertionPoint&gt;(*node).isActive();
</span></span></pre>
</div>
</div>

</body>
</html>