<!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>[190006] trunk</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/190006">190006</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2015-09-18 19:31:01 -0700 (Fri, 18 Sep 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Don't create renderers for children of shadow host
https://bugs.webkit.org/show_bug.cgi?id=149363

Reviewed by Ryosuke Niwa.

Source/WebCore:

Test: fast/shadow-dom/css-scoping-shadow-root-hides-children.html

* dom/ShadowRoot.h:
* style/StyleResolveTree.cpp:
(WebCore::Style::attachRenderTree):
(WebCore::Style::resolveShadowTree):
(WebCore::Style::resolveChildren):
(WebCore::Style::resolveTree):

LayoutTests:

* fast/shadow-dom/css-scoping-shadow-root-hides-children-expected.html: Added.
* fast/shadow-dom/css-scoping-shadow-root-hides-children.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomShadowRooth">trunk/Source/WebCore/dom/ShadowRoot.h</a></li>
<li><a href="#trunkSourceWebCorestyleStyleResolveTreecpp">trunk/Source/WebCore/style/StyleResolveTree.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastshadowdomcssscopingshadowroothideschildrenexpectedhtml">trunk/LayoutTests/fast/shadow-dom/css-scoping-shadow-root-hides-children-expected.html</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomcssscopingshadowroothideschildrenhtml">trunk/LayoutTests/fast/shadow-dom/css-scoping-shadow-root-hides-children.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (190005 => 190006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-09-19 02:18:56 UTC (rev 190005)
+++ trunk/LayoutTests/ChangeLog        2015-09-19 02:31:01 UTC (rev 190006)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2015-09-18  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Don't create renderers for children of shadow host
+        https://bugs.webkit.org/show_bug.cgi?id=149363
+
+        Reviewed by Ryosuke Niwa.
+
+        * fast/shadow-dom/css-scoping-shadow-root-hides-children-expected.html: Added.
+        * fast/shadow-dom/css-scoping-shadow-root-hides-children.html: Added.
+
</ins><span class="cx"> 2015-09-18  Jake Nielsen  &lt;jacob_nielsen@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Adds more flaky tests to TestExpecations for iOS and WK2
</span></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomcssscopingshadowroothideschildrenexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/css-scoping-shadow-root-hides-children-expected.html (0 => 190006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/css-scoping-shadow-root-hides-children-expected.html                                (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/css-scoping-shadow-root-hides-children-expected.html        2015-09-19 02:31:01 UTC (rev 190006)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+    &lt;p&gt;Test passes if you see a single 100px by 100px green box below.&lt;/p&gt;
+    &lt;div style=&quot;width: 100px; height: 100px; background: green;&quot;&gt;&lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomcssscopingshadowroothideschildrenhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/css-scoping-shadow-root-hides-children.html (0 => 190006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/css-scoping-shadow-root-hides-children.html                                (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/css-scoping-shadow-root-hides-children.html        2015-09-19 02:31:01 UTC (rev 190006)
</span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;title&gt;CSS Scoping - a shadow tree hides non-distributed children of the host&lt;/title&gt;
+    &lt;link rel=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;/&gt;
+    &lt;link rel=&quot;help&quot; href=&quot;http://www.w3.org/TR/css-scoping-1/#selectors-data-model&quot;&gt;
+    &lt;link rel=&quot;match&quot; href=&quot;reference/green-box.html&quot;/&gt;
+&lt;/head&gt;
+&lt;body&gt;
+    &lt;style&gt;
+    my-host {
+        display: block;
+        width: 100px;
+        height: 100px;
+    }
+    div {
+        width: 100%; height: 100%; background: red;
+    }
+    &lt;/style&gt;
+    &lt;p&gt;Test passes if you see a single 100px by 100px green box below.&lt;/p&gt; 
+    &lt;my-host&gt;
+        &lt;div&gt;FAIL&lt;/div&gt;
+    &lt;/my-host&gt;
+    &lt;script&gt;
+
+    try {
+        var shadowHost = document.querySelector('my-host');
+        shadowRoot = shadowHost.attachShadow({mode: 'open'});
+        shadowRoot.innerHTML = '&lt;div style=&quot;width: 100px; height: 100px; background: green; color:green&quot;&gt;FAIL&lt;/div&gt;';
+    } catch (exception) {
+        document.body.appendChild(document.createTextNode(exception));
+    }
+
+    &lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (190005 => 190006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-09-19 02:18:56 UTC (rev 190005)
+++ trunk/Source/WebCore/ChangeLog        2015-09-19 02:31:01 UTC (rev 190006)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2015-09-18  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Don't create renderers for children of shadow host
+        https://bugs.webkit.org/show_bug.cgi?id=149363
+
+        Reviewed by Ryosuke Niwa.
+
+        Test: fast/shadow-dom/css-scoping-shadow-root-hides-children.html
+
+        * dom/ShadowRoot.h:
+        * style/StyleResolveTree.cpp:
+        (WebCore::Style::attachRenderTree):
+        (WebCore::Style::resolveShadowTree):
+        (WebCore::Style::resolveChildren):
+        (WebCore::Style::resolveTree):
+
</ins><span class="cx"> 2015-09-08  Darin Adler  &lt;darin@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Refine and simplify some color-related code
</span></span></pre></div>
<a id="trunkSourceWebCoredomShadowRooth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/ShadowRoot.h (190005 => 190006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/ShadowRoot.h        2015-09-19 02:18:56 UTC (rev 190005)
+++ trunk/Source/WebCore/dom/ShadowRoot.h        2015-09-19 02:31:01 UTC (rev 190006)
</span><span class="lines">@@ -98,7 +98,7 @@
</span><span class="cx"> 
</span><span class="cx">     virtual Ref&lt;Node&gt; cloneNodeInternal(Document&amp;, CloningOperation) override;
</span><span class="cx"> 
</span><del>-    bool m_resetStyleInheritance : 1;
</del><ins>+    bool m_resetStyleInheritance;
</ins><span class="cx">     Type m_type;
</span><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;StyleResolver&gt; m_styleResolver;
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleResolveTreecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleResolveTree.cpp (190005 => 190006)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleResolveTree.cpp        2015-09-19 02:18:56 UTC (rev 190005)
+++ trunk/Source/WebCore/style/StyleResolveTree.cpp        2015-09-19 02:31:01 UTC (rev 190006)
</span><span class="lines">@@ -491,13 +491,16 @@
</span><span class="cx">         RenderTreePosition childRenderTreePosition(*renderer);
</span><span class="cx">         attachBeforeOrAfterPseudoElementIfNeeded(current, BEFORE, childRenderTreePosition);
</span><span class="cx"> 
</span><del>-        if (ShadowRoot* shadowRoot = current.shadowRoot()) {
</del><ins>+        auto* shadowRoot = current.shadowRoot();
+        if (shadowRoot) {
</ins><span class="cx">             parentPusher.push();
</span><span class="cx">             attachShadowRoot(*shadowRoot);
</span><span class="cx">         } else if (current.firstChild())
</span><span class="cx">             parentPusher.push();
</span><span class="cx"> 
</span><del>-        attachChildren(current, renderer-&gt;style(), childRenderTreePosition);
</del><ins>+        bool skipChildren = shadowRoot &amp;&amp; shadowRoot-&gt;type() != ShadowRoot::Type::UserAgent;
+        if (!skipChildren)
+            attachChildren(current, renderer-&gt;style(), childRenderTreePosition);
</ins><span class="cx"> 
</span><span class="cx">         if (AXObjectCache* cache = current.document().axObjectCache())
</span><span class="cx">             cache-&gt;updateCacheAfterNodeIsAttached(&amp;current);
</span><span class="lines">@@ -676,6 +679,8 @@
</span><span class="cx"> 
</span><span class="cx"> static void resolveShadowTree(ShadowRoot&amp; shadowRoot, Element&amp; host, Style::Change change)
</span><span class="cx"> {
</span><ins>+    StyleResolverParentPusher parentPusher(&amp;host);
+
</ins><span class="cx">     ASSERT(shadowRoot.host() == &amp;host);
</span><span class="cx">     ASSERT(host.renderer());
</span><span class="cx">     RenderTreePosition renderTreePosition(*host.renderer());
</span><span class="lines">@@ -686,8 +691,10 @@
</span><span class="cx">             resolveTextNode(downcast&lt;Text&gt;(*child), renderTreePosition);
</span><span class="cx">             continue;
</span><span class="cx">         }
</span><del>-        if (is&lt;Element&gt;(*child))
</del><ins>+        if (is&lt;Element&gt;(*child)) {
+            parentPusher.push();
</ins><span class="cx">             resolveTree(downcast&lt;Element&gt;(*child), host.renderer()-&gt;style(), renderTreePosition, change);
</span><ins>+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     shadowRoot.clearNeedsStyleRecalc();
</span><span class="lines">@@ -762,6 +769,35 @@
</span><span class="cx"> };
</span><span class="cx"> #endif // PLATFORM(IOS)
</span><span class="cx"> 
</span><ins>+static void resolveChildren(Element&amp; current, RenderStyle&amp; inheritedStyle, Change change, RenderTreePosition&amp; childRenderTreePosition)
+{
+    StyleResolverParentPusher parentPusher(&amp;current);
+
+    bool elementNeedingStyleRecalcAffectsNextSiblingElementStyle = false;
+    for (Node* child = current.firstChild(); child; child = child-&gt;nextSibling()) {
+        if (RenderObject* childRenderer = child-&gt;renderer())
+            childRenderTreePosition.invalidateNextSibling(*childRenderer);
+        if (is&lt;Text&gt;(*child) &amp;&amp; child-&gt;needsStyleRecalc()) {
+            resolveTextNode(downcast&lt;Text&gt;(*child), childRenderTreePosition);
+            continue;
+        }
+        if (!is&lt;Element&gt;(*child))
+            continue;
+
+        Element&amp; childElement = downcast&lt;Element&gt;(*child);
+        if (elementNeedingStyleRecalcAffectsNextSiblingElementStyle) {
+            if (childElement.styleIsAffectedByPreviousSibling())
+                childElement.setNeedsStyleRecalc();
+            elementNeedingStyleRecalcAffectsNextSiblingElementStyle = childElement.affectsNextSiblingElementStyle();
+        } else if (childElement.needsStyleRecalc())
+            elementNeedingStyleRecalcAffectsNextSiblingElementStyle = childElement.affectsNextSiblingElementStyle();
+        if (change &gt;= Inherit || childElement.childNeedsStyleRecalc() || childElement.needsStyleRecalc()) {
+            parentPusher.push();
+            resolveTree(childElement, inheritedStyle, childRenderTreePosition, change);
+        }
+    }
+}
+
</ins><span class="cx"> void resolveTree(Element&amp; current, RenderStyle&amp; inheritedStyle, RenderTreePosition&amp; renderTreePosition, Change change)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(change != Detach);
</span><span class="lines">@@ -790,42 +826,17 @@
</span><span class="cx">     auto* renderer = current.renderer();
</span><span class="cx"> 
</span><span class="cx">     if (change != Detach &amp;&amp; renderer) {
</span><del>-        StyleResolverParentPusher parentPusher(&amp;current);
</del><ins>+        auto* shadowRoot = current.shadowRoot();
+        if (shadowRoot &amp;&amp; (change &gt;= Inherit || shadowRoot-&gt;childNeedsStyleRecalc() || shadowRoot-&gt;needsStyleRecalc()))
+            resolveShadowTree(*shadowRoot, current, change);
</ins><span class="cx"> 
</span><del>-        if (ShadowRoot* shadowRoot = current.shadowRoot()) {
-            if (change &gt;= Inherit || shadowRoot-&gt;childNeedsStyleRecalc() || shadowRoot-&gt;needsStyleRecalc()) {
-                parentPusher.push();
-                resolveShadowTree(*shadowRoot, current, change);
-            }
-        }
-
</del><span class="cx">         RenderTreePosition childRenderTreePosition(*renderer);
</span><span class="cx">         updateBeforeOrAfterPseudoElement(current, change, BEFORE, childRenderTreePosition);
</span><span class="cx"> 
</span><del>-        bool elementNeedingStyleRecalcAffectsNextSiblingElementStyle = false;
-        for (Node* child = current.firstChild(); child; child = child-&gt;nextSibling()) {
-            if (RenderObject* childRenderer = child-&gt;renderer())
-                childRenderTreePosition.invalidateNextSibling(*childRenderer);
-            if (is&lt;Text&gt;(*child) &amp;&amp; child-&gt;needsStyleRecalc()) {
-                resolveTextNode(downcast&lt;Text&gt;(*child), childRenderTreePosition);
-                continue;
-            }
-            if (!is&lt;Element&gt;(*child))
-                continue;
</del><ins>+        bool skipChildren = shadowRoot &amp;&amp; shadowRoot-&gt;type() != ShadowRoot::Type::UserAgent;
+        if (!skipChildren)
+            resolveChildren(current, renderer-&gt;style(), change, childRenderTreePosition);
</ins><span class="cx"> 
</span><del>-            Element&amp; childElement = downcast&lt;Element&gt;(*child);
-            if (elementNeedingStyleRecalcAffectsNextSiblingElementStyle) {
-                if (childElement.styleIsAffectedByPreviousSibling())
-                    childElement.setNeedsStyleRecalc();
-                elementNeedingStyleRecalcAffectsNextSiblingElementStyle = childElement.affectsNextSiblingElementStyle();
-            } else if (childElement.needsStyleRecalc())
-                elementNeedingStyleRecalcAffectsNextSiblingElementStyle = childElement.affectsNextSiblingElementStyle();
-            if (change &gt;= Inherit || childElement.childNeedsStyleRecalc() || childElement.needsStyleRecalc()) {
-                parentPusher.push();
-                resolveTree(childElement, renderer-&gt;style(), childRenderTreePosition, change);
-            }
-        }
-
</del><span class="cx">         updateBeforeOrAfterPseudoElement(current, change, AFTER, childRenderTreePosition);
</span><span class="cx">     }
</span><span class="cx">     if (change != Detach &amp;&amp; !renderer)
</span></span></pre>
</div>
</div>

</body>
</html>