<!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 <antti@apple.com>
+
+ 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 <jacob_nielsen@apple.com>
</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>+<!DOCTYPE html>
+<html>
+<body>
+ <p>Test passes if you see a single 100px by 100px green box below.</p>
+ <div style="width: 100px; height: 100px; background: green;"></div>
+</body>
+</html>
</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>+<!DOCTYPE html>
+<html>
+<head>
+ <title>CSS Scoping - a shadow tree hides non-distributed children of the host</title>
+ <link rel="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"/>
+ <link rel="help" href="http://www.w3.org/TR/css-scoping-1/#selectors-data-model">
+ <link rel="match" href="reference/green-box.html"/>
+</head>
+<body>
+ <style>
+ my-host {
+ display: block;
+ width: 100px;
+ height: 100px;
+ }
+ div {
+ width: 100%; height: 100%; background: red;
+ }
+ </style>
+ <p>Test passes if you see a single 100px by 100px green box below.</p>
+ <my-host>
+ <div>FAIL</div>
+ </my-host>
+ <script>
+
+ try {
+ var shadowHost = document.querySelector('my-host');
+ shadowRoot = shadowHost.attachShadow({mode: 'open'});
+ shadowRoot.innerHTML = '<div style="width: 100px; height: 100px; background: green; color:green">FAIL</div>';
+ } catch (exception) {
+ document.body.appendChild(document.createTextNode(exception));
+ }
+
+ </script>
+</body>
+</html>
</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 <antti@apple.com>
+
+ 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 <darin@apple.com>
</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<Node> cloneNodeInternal(Document&, 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<StyleResolver> 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->style(), childRenderTreePosition);
</del><ins>+ bool skipChildren = shadowRoot && shadowRoot->type() != ShadowRoot::Type::UserAgent;
+ if (!skipChildren)
+ attachChildren(current, renderer->style(), childRenderTreePosition);
</ins><span class="cx">
</span><span class="cx"> if (AXObjectCache* cache = current.document().axObjectCache())
</span><span class="cx"> cache->updateCacheAfterNodeIsAttached(&current);
</span><span class="lines">@@ -676,6 +679,8 @@
</span><span class="cx">
</span><span class="cx"> static void resolveShadowTree(ShadowRoot& shadowRoot, Element& host, Style::Change change)
</span><span class="cx"> {
</span><ins>+ StyleResolverParentPusher parentPusher(&host);
+
</ins><span class="cx"> ASSERT(shadowRoot.host() == &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<Text>(*child), renderTreePosition);
</span><span class="cx"> continue;
</span><span class="cx"> }
</span><del>- if (is<Element>(*child))
</del><ins>+ if (is<Element>(*child)) {
+ parentPusher.push();
</ins><span class="cx"> resolveTree(downcast<Element>(*child), host.renderer()->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& current, RenderStyle& inheritedStyle, Change change, RenderTreePosition& childRenderTreePosition)
+{
+ StyleResolverParentPusher parentPusher(&current);
+
+ bool elementNeedingStyleRecalcAffectsNextSiblingElementStyle = false;
+ for (Node* child = current.firstChild(); child; child = child->nextSibling()) {
+ if (RenderObject* childRenderer = child->renderer())
+ childRenderTreePosition.invalidateNextSibling(*childRenderer);
+ if (is<Text>(*child) && child->needsStyleRecalc()) {
+ resolveTextNode(downcast<Text>(*child), childRenderTreePosition);
+ continue;
+ }
+ if (!is<Element>(*child))
+ continue;
+
+ Element& childElement = downcast<Element>(*child);
+ if (elementNeedingStyleRecalcAffectsNextSiblingElementStyle) {
+ if (childElement.styleIsAffectedByPreviousSibling())
+ childElement.setNeedsStyleRecalc();
+ elementNeedingStyleRecalcAffectsNextSiblingElementStyle = childElement.affectsNextSiblingElementStyle();
+ } else if (childElement.needsStyleRecalc())
+ elementNeedingStyleRecalcAffectsNextSiblingElementStyle = childElement.affectsNextSiblingElementStyle();
+ if (change >= Inherit || childElement.childNeedsStyleRecalc() || childElement.needsStyleRecalc()) {
+ parentPusher.push();
+ resolveTree(childElement, inheritedStyle, childRenderTreePosition, change);
+ }
+ }
+}
+
</ins><span class="cx"> void resolveTree(Element& current, RenderStyle& inheritedStyle, RenderTreePosition& 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 && renderer) {
</span><del>- StyleResolverParentPusher parentPusher(&current);
</del><ins>+ auto* shadowRoot = current.shadowRoot();
+ if (shadowRoot && (change >= Inherit || shadowRoot->childNeedsStyleRecalc() || shadowRoot->needsStyleRecalc()))
+ resolveShadowTree(*shadowRoot, current, change);
</ins><span class="cx">
</span><del>- if (ShadowRoot* shadowRoot = current.shadowRoot()) {
- if (change >= Inherit || shadowRoot->childNeedsStyleRecalc() || shadowRoot->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->nextSibling()) {
- if (RenderObject* childRenderer = child->renderer())
- childRenderTreePosition.invalidateNextSibling(*childRenderer);
- if (is<Text>(*child) && child->needsStyleRecalc()) {
- resolveTextNode(downcast<Text>(*child), childRenderTreePosition);
- continue;
- }
- if (!is<Element>(*child))
- continue;
</del><ins>+ bool skipChildren = shadowRoot && shadowRoot->type() != ShadowRoot::Type::UserAgent;
+ if (!skipChildren)
+ resolveChildren(current, renderer->style(), change, childRenderTreePosition);
</ins><span class="cx">
</span><del>- Element& childElement = downcast<Element>(*child);
- if (elementNeedingStyleRecalcAffectsNextSiblingElementStyle) {
- if (childElement.styleIsAffectedByPreviousSibling())
- childElement.setNeedsStyleRecalc();
- elementNeedingStyleRecalcAffectsNextSiblingElementStyle = childElement.affectsNextSiblingElementStyle();
- } else if (childElement.needsStyleRecalc())
- elementNeedingStyleRecalcAffectsNextSiblingElementStyle = childElement.affectsNextSiblingElementStyle();
- if (change >= Inherit || childElement.childNeedsStyleRecalc() || childElement.needsStyleRecalc()) {
- parentPusher.push();
- resolveTree(childElement, renderer->style(), childRenderTreePosition, change);
- }
- }
-
</del><span class="cx"> updateBeforeOrAfterPseudoElement(current, change, AFTER, childRenderTreePosition);
</span><span class="cx"> }
</span><span class="cx"> if (change != Detach && !renderer)
</span></span></pre>
</div>
</div>
</body>
</html>