<!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>[197165] 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/197165">197165</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2016-02-26 06:57:01 -0800 (Fri, 26 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Implement ::slotted pseudo element
https://bugs.webkit.org/show_bug.cgi?id=149441
&lt;rdar://problem/22731987&gt;

Reviewed by Andreas Kling.

Source/WebCore:

Based on latest in https://github.com/w3c/webcomponents/issues/331

* css/CSSGrammar.y.in:

    Parse ::slotted.

* css/CSSParser.cpp:
(WebCore::CSSParser::detectFunctionTypeToken):
* css/CSSParserValues.cpp:
(WebCore::CSSParserSelector::parsePseudoElementCueFunctionSelector):
(WebCore::CSSParserSelector::parsePseudoElementSlottedFunctionSelector):

    Tokenize ::slotted.

(WebCore::CSSParserSelector::parsePseudoClassAndCompatibilityElementSelector):
* css/CSSParserValues.h:
* css/CSSSelector.cpp:
(WebCore::CSSSelector::pseudoId):
* css/CSSSelector.h:
* css/ElementRuleCollector.cpp:
(WebCore::ElementRuleCollector::matchAuthorRules):
(WebCore::ElementRuleCollector::matchHostPseudoClassRules):
(WebCore::ElementRuleCollector::matchSlottedPseudoElementRules):

    Match ::slotted selector.

(WebCore::ElementRuleCollector::collectSlottedPseudoElementRulesForSlot):

    Collect ::slotted rules that may apply to an element in a slot.

(WebCore::ElementRuleCollector::matchUserRules):
(WebCore::ElementRuleCollector::matchUARules):
(WebCore::findSlottedPseudoElementSelector):
(WebCore::ElementRuleCollector::ruleMatches):
* css/ElementRuleCollector.h:
* css/RuleSet.cpp:
(WebCore::RuleSet::addRule):

    Collect ::slotted rules.

(WebCore::RuleSet::shrinkToFit):
* css/RuleSet.h:
(WebCore::RuleSet::hostPseudoClassRules):
(WebCore::RuleSet::slottedPseudoElementRules):
(WebCore::RuleSet::focusPseudoClassRules):
(WebCore::RuleSet::universalRules):
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOne):
* style/StyleSharingResolver.cpp:
(WebCore::Style::SharingResolver::resolve):

    Disable style sharing for children of shadow host. They may be affected by the shadow tree style
    which is not considered in style sharing checks.

LayoutTests:

* fast/shadow-dom/css-scoping-shadow-slotted-rule.html:

    Enable the test, fix it and update it to the current spec.

* fast/shadow-dom/slotted-pseudo-element-css-text-expected.txt: Added.
* fast/shadow-dom/slotted-pseudo-element-css-text.html: Added.

    Add parsing/cssText test based on a Blink test.
    There are a few failures due to * not roundtripping and the parser being too lenient with pseudo elements.

* platform/mac/TestExpectations:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomcssscopingshadowslottedrulehtml">trunk/LayoutTests/fast/shadow-dom/css-scoping-shadow-slotted-rule.html</a></li>
<li><a href="#trunkLayoutTestsplatformmacTestExpectations">trunk/LayoutTests/platform/mac/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorecssCSSGrammaryin">trunk/Source/WebCore/css/CSSGrammar.y.in</a></li>
<li><a href="#trunkSourceWebCorecssCSSParsercpp">trunk/Source/WebCore/css/CSSParser.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSParserValuescpp">trunk/Source/WebCore/css/CSSParserValues.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSParserValuesh">trunk/Source/WebCore/css/CSSParserValues.h</a></li>
<li><a href="#trunkSourceWebCorecssCSSSelectorcpp">trunk/Source/WebCore/css/CSSSelector.cpp</a></li>
<li><a href="#trunkSourceWebCorecssCSSSelectorh">trunk/Source/WebCore/css/CSSSelector.h</a></li>
<li><a href="#trunkSourceWebCorecssElementRuleCollectorcpp">trunk/Source/WebCore/css/ElementRuleCollector.cpp</a></li>
<li><a href="#trunkSourceWebCorecssElementRuleCollectorh">trunk/Source/WebCore/css/ElementRuleCollector.h</a></li>
<li><a href="#trunkSourceWebCorecssRuleSetcpp">trunk/Source/WebCore/css/RuleSet.cpp</a></li>
<li><a href="#trunkSourceWebCorecssRuleSeth">trunk/Source/WebCore/css/RuleSet.h</a></li>
<li><a href="#trunkSourceWebCorecssSelectorCheckercpp">trunk/Source/WebCore/css/SelectorChecker.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleStyleSharingResolvercpp">trunk/Source/WebCore/style/StyleSharingResolver.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastshadowdomslottedpseudoelementcsstextexpectedtxt">trunk/LayoutTests/fast/shadow-dom/slotted-pseudo-element-css-text-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastshadowdomslottedpseudoelementcsstexthtml">trunk/LayoutTests/fast/shadow-dom/slotted-pseudo-element-css-text.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (197164 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-02-26 11:49:49 UTC (rev 197164)
+++ trunk/LayoutTests/ChangeLog        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-02-26  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Implement ::slotted pseudo element
+        https://bugs.webkit.org/show_bug.cgi?id=149441
+        &lt;rdar://problem/22731987&gt;
+
+        Reviewed by Andreas Kling.
+
+        * fast/shadow-dom/css-scoping-shadow-slotted-rule.html:
+
+            Enable the test, fix it and update it to the current spec.
+
+        * fast/shadow-dom/slotted-pseudo-element-css-text-expected.txt: Added.
+        * fast/shadow-dom/slotted-pseudo-element-css-text.html: Added.
+
+            Add parsing/cssText test based on a Blink test.
+            There are a few failures due to * not roundtripping and the parser being too lenient with pseudo elements.
+
+        * platform/mac/TestExpectations:
+
</ins><span class="cx"> 2016-02-26  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
</span><span class="cx"> 
</span><span class="cx">         Sync web-platform-tests up to revision 5ca8b46
</span></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomcssscopingshadowslottedrulehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/shadow-dom/css-scoping-shadow-slotted-rule.html (197164 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/css-scoping-shadow-slotted-rule.html        2016-02-26 11:49:49 UTC (rev 197164)
+++ trunk/LayoutTests/fast/shadow-dom/css-scoping-shadow-slotted-rule.html        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> &lt;!DOCTYPE html&gt;
</span><span class="cx"> &lt;html&gt;
</span><span class="cx"> &lt;head&gt;
</span><del>-    &lt;title&gt;CSS Scoping - :slotted pesudo element must allow selecting elements assigned to a slot element&lt;/title&gt;
</del><ins>+    &lt;title&gt;CSS Scoping - :slotted pseudo element must allow selecting elements assigned to a slot element&lt;/title&gt;
</ins><span class="cx">     &lt;link rel=&quot;author&quot; title=&quot;Ryosuke Niwa&quot; href=&quot;mailto:rniwa@webkit.org&quot;/&gt;
</span><span class="cx">     &lt;link rel=&quot;help&quot; href=&quot;http://www.w3.org/TR/css-scoping-1/#selectors-data-model&quot;&gt;
</span><span class="cx">     &lt;link rel=&quot;match&quot; href=&quot;reference/green-box.html&quot;/&gt;
</span><span class="lines">@@ -12,7 +12,8 @@
</span><span class="cx">             display: block;
</span><span class="cx">             width: 100px;
</span><span class="cx">             height: 100px;
</span><del>-            background: red;
</del><ins>+            color: red;
+            background: green;
</ins><span class="cx">         }
</span><span class="cx">         my-host &gt; div, nested-host {
</span><span class="cx">             display: block;
</span><span class="lines">@@ -23,7 +24,7 @@
</span><span class="cx">     &lt;p&gt;Test passes if you see a single 100px by 100px green box below.&lt;/p&gt; 
</span><span class="cx">     &lt;my-host&gt;
</span><span class="cx">         &lt;div class=&quot;green&quot;&gt;FAIL1&lt;/div&gt;
</span><del>-        &lt;div&gt;&lt;span&gt;FAIL2&lt;/span&gt;&lt;/div&gt;
</del><ins>+        &lt;myelem&gt;&lt;span&gt;FAIL2&lt;/span&gt;&lt;/myelem&gt;
</ins><span class="cx">         &lt;nested-host&gt;
</span><span class="cx">             &lt;span&gt;FAIL3&lt;/span&gt;
</span><span class="cx">         &lt;/nested-host&gt;
</span><span class="lines">@@ -36,15 +37,15 @@
</span><span class="cx">         try {
</span><span class="cx">             var shadowHost = document.querySelector('my-host');
</span><span class="cx">             shadowRoot = shadowHost.attachShadow({mode: 'open'});
</span><del>-            shadowRoot.innerHTML = '&lt;slot&gt;&lt;/slot&gt;&lt;style&gt; ::slotted &gt; .green, ::slotted span { color:green; } &lt;/style&gt;';
</del><ins>+            shadowRoot.innerHTML = '&lt;slot&gt;&lt;/slot&gt;&lt;style&gt; ::slotted(.green), ::slotted(myelem) { color:green; } &lt;/style&gt;';
</ins><span class="cx"> 
</span><span class="cx">             shadowHost = document.querySelector('nested-host');
</span><span class="cx">             shadowRoot = shadowHost.attachShadow({mode: 'open'});
</span><del>-            shadowRoot.innerHTML = '&lt;slot&gt;&lt;/slot&gt;';
</del><ins>+            shadowRoot.innerHTML = '&lt;style&gt; .mydiv ::slotted(*) { color:green; } &lt;/style&gt;&lt;div class=mydiv&gt;&lt;slot&gt;&lt;/slot&gt;&lt;/div&gt;';
</ins><span class="cx"> 
</span><span class="cx">             shadowHost = document.querySelector('another-host');
</span><span class="cx">             shadowRoot = shadowHost.attachShadow({mode: 'open'});
</span><del>-            shadowRoot.innerHTML = '&lt;style&gt; ::slotted { color:green; } &lt;/style&gt;&lt;slot&gt;&lt;/slot&gt;';
</del><ins>+            shadowRoot.innerHTML = '&lt;style&gt; ::slotted(*) { color:green; } &lt;/style&gt;&lt;slot&gt;&lt;/slot&gt;';
</ins><span class="cx">         } catch (exception) {
</span><span class="cx">             document.body.appendChild(document.createTextNode(exception));
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomslottedpseudoelementcsstextexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/slotted-pseudo-element-css-text-expected.txt (0 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/slotted-pseudo-element-css-text-expected.txt                                (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/slotted-pseudo-element-css-text-expected.txt        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+
+PASS ::slotted { display: block; } 
+PASS ::slotted() { display: block; } 
+PASS ::slotted(*) { display: block; } 
+FAIL *::slotted(*) { display: block; } assert_equals: expected &quot;*::slotted(*) { display: block; }&quot; but got &quot;::slotted(*) { display: block; }&quot;
+PASS ::slotted(div) { display: block; } 
+PASS ::slotted( div) { display: block; } 
+PASS ::slotted(div ) { display: block; } 
+PASS ::slotted(div::before) { display: block; } 
+PASS .foo::slotted(div) { color: blue; } 
+PASS #id::slotted(*) { color: blue; } 
+PASS [attr=foo]::slotted(*) { color: blue; } 
+PASS .foo .bar::slotted(div) { color: blue; } 
+FAIL .foo::before .bar::slotted(div) { color: blue; } assert_equals: expected &quot;&quot; but got &quot;.foo::before .bar::slotted(div) { color: blue; }&quot;
+FAIL .foo::slotted(div) .bar { color: blue; } assert_equals: expected &quot;&quot; but got &quot;.foo::slotted(div) .bar { color: blue; }&quot;
+PASS ::slotted(div, div) { color: blue; } 
+PASS ::slotted(div div) { color: blue; } 
+PASS slot::slotted(.green) { color: green; } 
+PASS slot::slotted(#green) { color: green; } 
+PASS slot::slotted([green=green]) { color: green; } 
+PASS slot::slotted(div.green) { color: green; } 
+PASS div ::slotted(div) { color: red; } 
+PASS div + slot::slotted(div) { color: red; } 
+PASS span::slotted(*) { color: red; } 
+FAIL ::slotted(span)::slotted(span) { color: red; } assert_equals: expected &quot;&quot; but got &quot;::slotted(span)::slotted(span) { color: red; }&quot;
+PASS ::slotted(::slotted(div)) { color: red; } 
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastshadowdomslottedpseudoelementcsstexthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/shadow-dom/slotted-pseudo-element-css-text.html (0 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/shadow-dom/slotted-pseudo-element-css-text.html                                (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/slotted-pseudo-element-css-text.html        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -0,0 +1,76 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;script src='../../resources/testharness.js'&gt;&lt;/script&gt;
+&lt;script src='../../resources/testharnessreport.js'&gt;&lt;/script&gt;
+&lt;script&gt;
+var rules = [
+&quot;::slotted { display: block; }&quot;, /* invalid - no parameter */
+&quot;::slotted() { display: block; }&quot;, /* invalid - empty parameter */
+&quot;::slotted(*) { display: block; }&quot;,
+&quot;*::slotted(*) { display: block; }&quot;,
+&quot;::slotted(div) { display: block; }&quot;, /* expects universal selector (*) on the left in cssText */
+&quot;::slotted( div) { display: block; }&quot;, /* allow a space on left */
+&quot;::slotted(div ) { display: block; }&quot;, /* allow a space on right */
+&quot;::slotted(div::before) { display: block; }&quot;, /* having a pseudo element in () is invalid */
+&quot;.foo::slotted(div) { color: blue; }&quot;,
+&quot;#id::slotted(*) { color: blue; }&quot;,
+&quot;[attr=foo]::slotted(*) { color: blue; }&quot;,
+&quot;.foo .bar::slotted(div) { color: blue; }&quot;,
+&quot;.foo::before .bar::slotted(div) { color: blue; }&quot;, /* invalid, only one pseudo element is allowed at the rightmost compound */
+&quot;.foo::slotted(div) .bar { color: blue; }&quot;, /* invalid, same as above */
+&quot;::slotted(div, div) { color: blue; }&quot;, /* invalid - selector list */
+&quot;::slotted(div div) { color: blue; }&quot;, /* invalid - complex selector (combinator is used) */
+&quot;slot::slotted(.green) { color: green; }&quot;,
+&quot;slot::slotted(#green) { color: green; }&quot;,
+&quot;slot::slotted([green=green]) { color: green; }&quot;,
+&quot;slot::slotted(div.green) { color: green; }&quot;,
+&quot;div ::slotted(div) { color: red; }&quot;,
+&quot;div + slot::slotted(div) { color: red; }&quot;,
+&quot;span::slotted(*) { color: red; }&quot;, /* never matches, but valid as a selector */
+&quot;::slotted(span)::slotted(span) { color: red; }&quot;, /* invalid */
+&quot;::slotted(::slotted(div)) { color: red; }&quot; /* invalid */
+];
+
+var expectedCSSTexts = [
+&quot;&quot;, 
+&quot;&quot;,
+&quot;::slotted(*) { display: block; }&quot;,
+&quot;*::slotted(*) { display: block; }&quot;,
+&quot;::slotted(div) { display: block; }&quot;,
+&quot;::slotted(div) { display: block; }&quot;, 
+&quot;::slotted(div) { display: block; }&quot;,
+&quot;&quot;,
+&quot;.foo::slotted(div) { color: blue; }&quot;,
+&quot;#id::slotted(*) { color: blue; }&quot;,
+&quot;[attr=\&quot;foo\&quot;]::slotted(*) { color: blue; }&quot;,
+&quot;.foo .bar::slotted(div) { color: blue; }&quot;,
+&quot;&quot;,
+&quot;&quot;,
+&quot;&quot;,
+&quot;&quot;,
+&quot;slot::slotted(.green) { color: green; }&quot;,
+&quot;slot::slotted(#green) { color: green; }&quot;,
+&quot;slot::slotted([green=\&quot;green\&quot;]) { color: green; }&quot;,
+&quot;slot::slotted(div.green) { color: green; }&quot;,
+&quot;div ::slotted(div) { color: red; }&quot;,
+&quot;div + slot::slotted(div) { color: red; }&quot;,
+&quot;span::slotted(*) { color: red; }&quot;,
+&quot;&quot;,
+&quot;&quot;,
+];
+
+function ruleCSSText(rule)
+{
+    var style = document.createElement(&quot;style&quot;);
+    style.innerText = rule;
+    document.head.appendChild(style);
+    if (style.sheet.cssRules.length == 0)
+        return &quot;&quot;;
+    return style.sheet.cssRules.item(0).cssText;
+}
+
+for (var i = 0; i &lt; rules.length; ++i) {
+    test(() =&gt; {
+        assert_equals(ruleCSSText(rules[i]), expectedCSSTexts[i]);
+    }, rules[i]);
+}
+&lt;/script&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/TestExpectations (197164 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/TestExpectations        2016-02-26 11:49:49 UTC (rev 197164)
+++ trunk/LayoutTests/platform/mac/TestExpectations        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -1249,7 +1249,6 @@
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/148695 fast/shadow-dom [ Pass ]
</span><span class="cx"> webkit.org/b/149440 fast/shadow-dom/css-scoping-shadow-host-functional-rule.html [ ImageOnlyFailure ]
</span><del>-webkit.org/b/149441 fast/shadow-dom/css-scoping-shadow-slotted-rule.html [ ImageOnlyFailure ]
</del><span class="cx"> webkit.org/b/149441 fast/shadow-dom/css-scoping-shadow-slot-display-override.html [ ImageOnlyFailure ]
</span><span class="cx"> 
</span><span class="cx"> # Touch events is not enabled on Mac
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (197164 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-02-26 11:49:49 UTC (rev 197164)
+++ trunk/Source/WebCore/ChangeLog        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -1,3 +1,65 @@
</span><ins>+2016-02-25  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Implement ::slotted pseudo element
+        https://bugs.webkit.org/show_bug.cgi?id=149441
+        &lt;rdar://problem/22731987&gt;
+
+        Reviewed by Andreas Kling.
+
+        Based on latest in https://github.com/w3c/webcomponents/issues/331
+
+        * css/CSSGrammar.y.in:
+
+            Parse ::slotted.
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::detectFunctionTypeToken):
+        * css/CSSParserValues.cpp:
+        (WebCore::CSSParserSelector::parsePseudoElementCueFunctionSelector):
+        (WebCore::CSSParserSelector::parsePseudoElementSlottedFunctionSelector):
+
+            Tokenize ::slotted.
+
+        (WebCore::CSSParserSelector::parsePseudoClassAndCompatibilityElementSelector):
+        * css/CSSParserValues.h:
+        * css/CSSSelector.cpp:
+        (WebCore::CSSSelector::pseudoId):
+        * css/CSSSelector.h:
+        * css/ElementRuleCollector.cpp:
+        (WebCore::ElementRuleCollector::matchAuthorRules):
+        (WebCore::ElementRuleCollector::matchHostPseudoClassRules):
+        (WebCore::ElementRuleCollector::matchSlottedPseudoElementRules):
+
+            Match ::slotted selector.
+
+        (WebCore::ElementRuleCollector::collectSlottedPseudoElementRulesForSlot):
+
+            Collect ::slotted rules that may apply to an element in a slot.
+
+        (WebCore::ElementRuleCollector::matchUserRules):
+        (WebCore::ElementRuleCollector::matchUARules):
+        (WebCore::findSlottedPseudoElementSelector):
+        (WebCore::ElementRuleCollector::ruleMatches):
+        * css/ElementRuleCollector.h:
+        * css/RuleSet.cpp:
+        (WebCore::RuleSet::addRule):
+
+            Collect ::slotted rules.
+
+        (WebCore::RuleSet::shrinkToFit):
+        * css/RuleSet.h:
+        (WebCore::RuleSet::hostPseudoClassRules):
+        (WebCore::RuleSet::slottedPseudoElementRules):
+        (WebCore::RuleSet::focusPseudoClassRules):
+        (WebCore::RuleSet::universalRules):
+        * css/SelectorChecker.cpp:
+        (WebCore::SelectorChecker::checkOne):
+        * style/StyleSharingResolver.cpp:
+        (WebCore::Style::SharingResolver::resolve):
+
+            Disable style sharing for children of shadow host. They may be affected by the shadow tree style
+            which is not considered in style sharing checks.
+
</ins><span class="cx"> 2016-02-25  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Font size computed style is innaccurate
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSGrammaryin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSGrammar.y.in (197164 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSGrammar.y.in        2016-02-26 11:49:49 UTC (rev 197164)
+++ trunk/Source/WebCore/css/CSSGrammar.y.in        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -365,6 +365,12 @@
</span><span class="cx"> 
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE_SHADOW_DOM
+
+%token &lt;string&gt; SLOTTEDFUNCTION
+
+#endif
+
</ins><span class="cx"> %%
</span><span class="cx"> 
</span><span class="cx"> stylesheet:
</span><span class="lines">@@ -1357,6 +1363,11 @@
</span><span class="cx">         $$ = CSSParserSelector::parsePseudoElementCueFunctionSelector($3, $5);
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><ins>+#if ENABLE_SHADOW_DOM
+    | ':' ':' SLOTTEDFUNCTION maybe_space compound_selector maybe_space ')' {
+        $$ = CSSParserSelector::parsePseudoElementSlottedFunctionSelector($3, $5);
+    }
+#endif
</ins><span class="cx">     // use by :-webkit-any.
</span><span class="cx">     // FIXME: should we support generic selectors here or just simple_selectors?
</span><span class="cx">     // Use simple_selector_list for now to match -moz-any.
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSParser.cpp (197164 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSParser.cpp        2016-02-26 11:49:49 UTC (rev 197164)
+++ trunk/Source/WebCore/css/CSSParser.cpp        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -11894,6 +11894,12 @@
</span><span class="cx">             m_token = MATCHESFUNCTION;
</span><span class="cx">             return true;
</span><span class="cx">         }
</span><ins>+#if ENABLE(SHADOW_DOM)
+        if (isEqualToCSSIdentifier(name, &quot;slotted&quot;)) {
+            m_token = SLOTTEDFUNCTION;
+            return true;
+        }
+#endif
</ins><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     case 9:
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSParserValuescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSParserValues.cpp (197164 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSParserValues.cpp        2016-02-26 11:49:49 UTC (rev 197164)
+++ trunk/Source/WebCore/css/CSSParserValues.cpp        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -231,6 +231,32 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE(SHADOW_DOM)
+CSSParserSelector* CSSParserSelector::parsePseudoElementSlottedFunctionSelector(const CSSParserString&amp; functionIdentifier, CSSParserSelector* parsedSelector)
+{
+    ASSERT_UNUSED(functionIdentifier, String(functionIdentifier) == &quot;slotted(&quot;);
+
+    if (!parsedSelector)
+        return nullptr;
+
+    std::unique_ptr&lt;CSSParserSelector&gt; ownedParsedSelector(parsedSelector);
+
+    for (auto* component = parsedSelector; component; component = component-&gt;tagHistory()) {
+        if (component-&gt;matchesPseudoElement())
+            return nullptr;
+    }
+
+    auto selectorVector = std::make_unique&lt;Vector&lt;std::unique_ptr&lt;CSSParserSelector&gt;&gt;&gt;();
+    selectorVector-&gt;append(WTFMove(ownedParsedSelector));
+
+    auto selector = std::make_unique&lt;CSSParserSelector&gt;();
+    selector-&gt;m_selector-&gt;setMatch(CSSSelector::PseudoElement);
+    selector-&gt;m_selector-&gt;setPseudoElementType(CSSSelector::PseudoElementSlotted);
+    selector-&gt;adoptSelectorVector(*selectorVector);
+    return selector.release();
+}
+#endif
+
</ins><span class="cx"> CSSParserSelector* CSSParserSelector::parsePseudoClassAndCompatibilityElementSelector(CSSParserString&amp; pseudoTypeString)
</span><span class="cx"> {
</span><span class="cx">     if (pseudoTypeString.length() &amp;&amp; pseudoTypeString[pseudoTypeString.length() - 1] == '(')
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSParserValuesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSParserValues.h (197164 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSParserValues.h        2016-02-26 11:49:49 UTC (rev 197164)
+++ trunk/Source/WebCore/css/CSSParserValues.h        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -203,7 +203,10 @@
</span><span class="cx"> public:
</span><span class="cx">     static CSSParserSelector* parsePagePseudoSelector(const CSSParserString&amp; pseudoTypeString);
</span><span class="cx">     static CSSParserSelector* parsePseudoElementSelector(CSSParserString&amp; pseudoTypeString);
</span><del>-    static CSSParserSelector* parsePseudoElementCueFunctionSelector(const CSSParserString&amp; functionIdentifier, Vector&lt;std::unique_ptr&lt;CSSParserSelector&gt;&gt;* selectorVector);
</del><ins>+    static CSSParserSelector* parsePseudoElementCueFunctionSelector(const CSSParserString&amp; functionIdentifier, Vector&lt;std::unique_ptr&lt;CSSParserSelector&gt;&gt;*);
+#if ENABLE(SHADOW_DOM)
+    static CSSParserSelector* parsePseudoElementSlottedFunctionSelector(const CSSParserString&amp; functionIdentifier, CSSParserSelector*);
+#endif
</ins><span class="cx">     static CSSParserSelector* parsePseudoClassAndCompatibilityElementSelector(CSSParserString&amp; pseudoTypeString);
</span><span class="cx"> 
</span><span class="cx">     CSSParserSelector();
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSSelectorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSSelector.cpp (197164 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSSelector.cpp        2016-02-26 11:49:49 UTC (rev 197164)
+++ trunk/Source/WebCore/css/CSSSelector.cpp        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -299,6 +299,9 @@
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx">     case PseudoElementCue:
</span><span class="cx"> #endif
</span><ins>+#if ENABLE(SHADOW_DOM)
+    case PseudoElementSlotted:
+#endif
</ins><span class="cx">     case PseudoElementUnknown:
</span><span class="cx">     case PseudoElementUserAgentCustom:
</span><span class="cx">     case PseudoElementWebKitCustom:
</span><span class="lines">@@ -644,8 +647,18 @@
</span><span class="cx">                 ASSERT_NOT_REACHED();
</span><span class="cx">             }
</span><span class="cx">         } else if (cs-&gt;match() == CSSSelector::PseudoElement) {
</span><del>-            str.appendLiteral(&quot;::&quot;);
-            str.append(cs-&gt;value());
</del><ins>+            switch (cs-&gt;pseudoElementType()) {
+#if ENABLE(SHADOW_DOM)
+            case CSSSelector::PseudoElementSlotted:
+                str.appendLiteral(&quot;::slotted(&quot;);
+                cs-&gt;selectorList()-&gt;buildSelectorsText(str);
+                str.append(')');
+                break;
+#endif
+            default:
+                str.appendLiteral(&quot;::&quot;);
+                str.append(cs-&gt;value());
+            }
</ins><span class="cx">         } else if (cs-&gt;isAttributeSelector()) {
</span><span class="cx">             str.append('[');
</span><span class="cx">             const AtomicString&amp; prefix = cs-&gt;attribute().prefix();
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSSelectorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSSelector.h (197164 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSSelector.h        2016-02-26 11:49:49 UTC (rev 197164)
+++ trunk/Source/WebCore/css/CSSSelector.h        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -181,6 +181,9 @@
</span><span class="cx">             PseudoElementScrollbarTrack,
</span><span class="cx">             PseudoElementScrollbarTrackPiece,
</span><span class="cx">             PseudoElementSelection,
</span><ins>+#if ENABLE(SHADOW_DOM)
+            PseudoElementSlotted,
+#endif
</ins><span class="cx">             PseudoElementUserAgentCustom,
</span><span class="cx">             PseudoElementWebKitCustom,
</span><span class="cx">         };
</span></span></pre></div>
<a id="trunkSourceWebCorecssElementRuleCollectorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/ElementRuleCollector.cpp (197164 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/ElementRuleCollector.cpp        2016-02-26 11:49:49 UTC (rev 197164)
+++ trunk/Source/WebCore/css/ElementRuleCollector.cpp        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include &quot;CSSSelectorList.h&quot;
</span><span class="cx"> #include &quot;CSSValueKeywords.h&quot;
</span><span class="cx"> #include &quot;HTMLElement.h&quot;
</span><ins>+#include &quot;HTMLSlotElement.h&quot;
</ins><span class="cx"> #include &quot;InspectorInstrumentation.h&quot;
</span><span class="cx"> #include &quot;NodeRenderStyle.h&quot;
</span><span class="cx"> #include &quot;RenderRegion.h&quot;
</span><span class="lines">@@ -206,6 +207,10 @@
</span><span class="cx"> #if ENABLE(SHADOW_DOM)
</span><span class="cx">     if (m_element.shadowRoot())
</span><span class="cx">         matchHostPseudoClassRules(includeEmptyRules);
</span><ins>+
+    auto* parent = m_element.parentNode();
+    if (parent &amp;&amp; parent-&gt;shadowRoot())
+        matchSlottedPseudoElementRules(includeEmptyRules);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     clearMatchedRules();
</span><span class="lines">@@ -241,6 +246,62 @@
</span><span class="cx">     // FIXME: Match the spec when it is finalized.
</span><span class="cx">     sortAndTransferMatchedRules();
</span><span class="cx"> }
</span><ins>+
+void ElementRuleCollector::matchSlottedPseudoElementRules(bool includeEmptyRules)
+{
+    auto* hostShadowRoot = m_element.parentNode()-&gt;shadowRoot();
+    ASSERT(hostShadowRoot);
+    auto* slot = hostShadowRoot-&gt;findAssignedSlot(m_element);
+    if (!slot)
+        return;
+    auto* shadowAuthorStyle = hostShadowRoot-&gt;styleResolver().ruleSets().authorStyle();
+    if (!shadowAuthorStyle)
+        return;
+    // Find out if there are any ::slotted rules in the shadow tree matching the current slot.
+    // FIXME: This is really part of the slot style and could be cached when resolving it.
+    ElementRuleCollector collector(*slot, *shadowAuthorStyle, nullptr);
+    auto slottedPseudoElementRules = collector.collectSlottedPseudoElementRulesForSlot(includeEmptyRules);
+    if (slottedPseudoElementRules.isEmpty())
+        return;
+
+    clearMatchedRules();
+    m_result.ranges.lastAuthorRule = m_result.matchedProperties().size() - 1;
+
+    {
+        // Match in the current scope.
+        TemporaryChange&lt;bool&gt; change(m_isMatchingSlottedPseudoElements, true);
+
+        MatchRequest matchRequest(nullptr, includeEmptyRules);
+        auto ruleRange = m_result.ranges.authorRuleRange();
+        collectMatchingRulesForList(&amp;slottedPseudoElementRules, matchRequest, ruleRange);
+    }
+
+    // FIXME: What is the correct order?
+    sortAndTransferMatchedRules();
+}
+
+RuleSet::RuleDataVector ElementRuleCollector::collectSlottedPseudoElementRulesForSlot(bool includeEmptyRules)
+{
+    ASSERT(is&lt;HTMLSlotElement&gt;(m_element));
+
+    clearMatchedRules();
+
+    m_mode = SelectorChecker::Mode::CollectingRules;
+
+    // Match global author rules.
+    MatchRequest matchRequest(&amp;m_authorStyle, includeEmptyRules);
+    StyleResolver::RuleRange ruleRange = m_result.ranges.authorRuleRange();
+    collectMatchingRulesForList(&amp;m_authorStyle.slottedPseudoElementRules(), matchRequest, ruleRange);
+
+    if (m_matchedRules.isEmpty())
+        return { };
+
+    RuleSet::RuleDataVector ruleDataVector;
+    ruleDataVector.reserveInitialCapacity(m_matchedRules.size());
+    for (auto&amp; matchedRule : m_matchedRules)
+        ruleDataVector.uncheckedAppend(*matchedRule.ruleData);
+    return ruleDataVector;
+}
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> void ElementRuleCollector::matchUserRules(bool includeEmptyRules)
</span><span class="lines">@@ -284,6 +345,20 @@
</span><span class="cx">     sortAndTransferMatchedRules();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(SHADOW_DOM)
+static const CSSSelector* findSlottedPseudoElementSelector(const CSSSelector* selector)
+{
+    for (; selector; selector = selector-&gt;tagHistory()) {
+        if (selector-&gt;match() == CSSSelector::PseudoElement &amp;&amp; selector-&gt;pseudoElementType() == CSSSelector::PseudoElementSlotted) {
+            if (auto* list = selector-&gt;selectorList())
+                return list-&gt;first();
+            break;
+        }
+    };
+    return nullptr;
+}
+#endif
+
</ins><span class="cx"> inline bool ElementRuleCollector::ruleMatches(const RuleData&amp; ruleData, unsigned&amp; specificity)
</span><span class="cx"> {
</span><span class="cx">     // We know a sufficiently simple single part selector matches simply because we found it from the rule hash when filtering the RuleSet.
</span><span class="lines">@@ -356,9 +431,17 @@
</span><span class="cx">     } else
</span><span class="cx"> #endif // ENABLE(CSS_SELECTOR_JIT)
</span><span class="cx">     {
</span><ins>+        auto* selector = ruleData.selector();
+#if ENABLE(SHADOW_DOM)
+        if (m_isMatchingSlottedPseudoElements) {
+            selector = findSlottedPseudoElementSelector(ruleData.selector());
+            if (!selector)
+                return false;
+        }
+#endif
</ins><span class="cx">         // Slow path.
</span><span class="cx">         SelectorChecker selectorChecker(m_element.document());
</span><del>-        selectorMatches = selectorChecker.match(*ruleData.selector(), m_element, context, specificity);
</del><ins>+        selectorMatches = selectorChecker.match(*selector, m_element, context, specificity);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     commitStyleRelations(context.styleRelations);
</span></span></pre></div>
<a id="trunkSourceWebCorecssElementRuleCollectorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/ElementRuleCollector.h (197164 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/ElementRuleCollector.h        2016-02-26 11:49:49 UTC (rev 197164)
+++ trunk/Source/WebCore/css/ElementRuleCollector.h        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -73,6 +73,8 @@
</span><span class="cx">     void matchUARules(RuleSet*);
</span><span class="cx"> #if ENABLE(SHADOW_DOM)
</span><span class="cx">     void matchHostPseudoClassRules(bool includeEmptyRules);
</span><ins>+    void matchSlottedPseudoElementRules(bool includeEmptyRules);
+    RuleSet::RuleDataVector collectSlottedPseudoElementRulesForSlot(bool includeEmptyRules);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     void collectMatchingRules(const MatchRequest&amp;, StyleResolver::RuleRange&amp;);
</span><span class="lines">@@ -98,6 +100,9 @@
</span><span class="cx">     PseudoStyleRequest m_pseudoStyleRequest { NOPSEUDO };
</span><span class="cx">     bool m_sameOriginOnly { false };
</span><span class="cx">     SelectorChecker::Mode m_mode { SelectorChecker::Mode::ResolvingStyle };
</span><ins>+#if ENABLE(SHADOW_DOM)
+    bool m_isMatchingSlottedPseudoElements { false };
+#endif
</ins><span class="cx"> 
</span><span class="cx">     Vector&lt;MatchedRule, 64&gt; m_matchedRules;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecssRuleSetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/RuleSet.cpp (197164 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/RuleSet.cpp        2016-02-26 11:49:49 UTC (rev 197164)
+++ trunk/Source/WebCore/css/RuleSet.cpp        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -266,6 +266,12 @@
</span><span class="cx">             m_hostPseudoClassRules.append(ruleData);
</span><span class="cx">             return;
</span><span class="cx">         }
</span><ins>+        if (selector-&gt;match() == CSSSelector::PseudoElement &amp;&amp; selector-&gt;pseudoElementType() == CSSSelector::PseudoElementSlotted) {
+            // ::slotted pseudo elements work accross shadow boundary making filtering difficult.
+            ruleData.disableSelectorFiltering();
+            m_slottedPseudoElementRules.append(ruleData);
+            return;
+        }
</ins><span class="cx"> #endif
</span><span class="cx">         if (selector-&gt;relation() != CSSSelector::SubSelector)
</span><span class="cx">             break;
</span><span class="lines">@@ -422,6 +428,10 @@
</span><span class="cx"> #if ENABLE(VIDEO_TRACK)
</span><span class="cx">     m_cuePseudoRules.shrinkToFit();
</span><span class="cx"> #endif
</span><ins>+#if ENABLE(SHADOW_DOM)
+    m_hostPseudoClassRules.shrinkToFit();
+    m_slottedPseudoElementRules.shrinkToFit();
+#endif
</ins><span class="cx">     m_focusPseudoClassRules.shrinkToFit();
</span><span class="cx">     m_universalRules.shrinkToFit();
</span><span class="cx">     m_pageRules.shrinkToFit();
</span></span></pre></div>
<a id="trunkSourceWebCorecssRuleSeth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/RuleSet.h (197164 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/RuleSet.h        2016-02-26 11:49:49 UTC (rev 197164)
+++ trunk/Source/WebCore/css/RuleSet.h        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -184,6 +184,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> #if ENABLE(SHADOW_DOM)
</span><span class="cx">     const RuleDataVector&amp; hostPseudoClassRules() const { return m_hostPseudoClassRules; }
</span><ins>+    const RuleDataVector&amp; slottedPseudoElementRules() const { return m_slottedPseudoElementRules; }
</ins><span class="cx"> #endif
</span><span class="cx">     const RuleDataVector* focusPseudoClassRules() const { return &amp;m_focusPseudoClassRules; }
</span><span class="cx">     const RuleDataVector* universalRules() const { return &amp;m_universalRules; }
</span><span class="lines">@@ -210,6 +211,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> #if ENABLE(SHADOW_DOM)
</span><span class="cx">     RuleDataVector m_hostPseudoClassRules;
</span><ins>+    RuleDataVector m_slottedPseudoElementRules;
</ins><span class="cx"> #endif
</span><span class="cx">     RuleDataVector m_focusPseudoClassRules;
</span><span class="cx">     RuleDataVector m_universalRules;
</span></span></pre></div>
<a id="trunkSourceWebCorecssSelectorCheckercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (197164 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/SelectorChecker.cpp        2016-02-26 11:49:49 UTC (rev 197164)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -44,6 +44,7 @@
</span><span class="cx"> #include &quot;HTMLOptionElement.h&quot;
</span><span class="cx"> #include &quot;HTMLParserIdioms.h&quot;
</span><span class="cx"> #include &quot;HTMLProgressElement.h&quot;
</span><ins>+#include &quot;HTMLSlotElement.h&quot;
</ins><span class="cx"> #include &quot;HTMLStyleElement.h&quot;
</span><span class="cx"> #include &quot;InspectorInstrumentation.h&quot;
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="lines">@@ -1038,7 +1039,13 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><del>-    // ### add the rest of the checks...
</del><ins>+#if ENABLE(SHADOW_DOM)
+    if (selector.match() == CSSSelector::PseudoElement &amp;&amp; selector.pseudoElementType() == CSSSelector::PseudoElementSlotted) {
+        // We see ::slotted() pseudo elements when collecting slotted rules from the slot shadow tree only.
+        ASSERT(checkingContext.resolvingMode == Mode::CollectingRules);
+        return is&lt;HTMLSlotElement&gt;(element);
+    }
+#endif
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorestyleStyleSharingResolvercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/StyleSharingResolver.cpp (197164 => 197165)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/StyleSharingResolver.cpp        2016-02-26 11:49:49 UTC (rev 197164)
+++ trunk/Source/WebCore/style/StyleSharingResolver.cpp        2016-02-26 14:57:01 UTC (rev 197165)
</span><span class="lines">@@ -76,6 +76,8 @@
</span><span class="cx">     if (!element.parentElement())
</span><span class="cx">         return nullptr;
</span><span class="cx">     auto&amp; parentElement = *element.parentElement();
</span><ins>+    if (parentElement.shadowRoot())
+        return nullptr;
</ins><span class="cx">     if (!parentElement.renderStyle())
</span><span class="cx">         return nullptr;
</span><span class="cx">     // If the element has inline style it is probably unique.
</span></span></pre>
</div>
</div>

</body>
</html>