<!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>[284865] 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/284865">284865</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2021-10-26 07:55:58 -0700 (Tue, 26 Oct 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix ::part(foo):hover
https://bugs.webkit.org/show_bug.cgi?id=232301

Reviewed by Alan Bujtas.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class-expected.html: Added.
* web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class.html: Added.
* web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo-expected.txt: Added.
* web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo.html: Added.
* web-platform-tests/css/css-shadow-parts/part-nested-pseudo-expected.html: Added.
* web-platform-tests/css/css-shadow-parts/part-nested-pseudo.html: Added.
* web-platform-tests/css/css-shadow-parts/w3c-import.log:

Source/WebCore:

We fail to match on shadow tree border if the right side of ::part() has other selectors.

Tests: imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo.html

* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText const):
* css/CSSSelector.h:

Add a new ShadowPartDescendant relation type that behaves like the existing ShadowDescendant relation
except it is only used for ::part.

* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::matchRecursively const):

We can now identify the ::part case easily from the relation type.

(WebCore::canMatchHoverOrActiveInQuirksMode):
* css/SelectorFilter.cpp:
(WebCore::collectSelectorHashes):
* css/parser/CSSParserSelector.h:
(WebCore::CSSParserSelector::hasShadowDescendant const): Deleted.
* css/parser/CSSSelectorParser.cpp:
(WebCore::CSSSelectorParser::splitCompoundAtImplicitShadowCrossingCombinator):

Use ShadowPartDescendant as appropriate.

* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::fragmentRelationForSelectorRelation):
(WebCore::SelectorCompiler::constructFragmentsInternal):
* style/RuleFeature.cpp:
(WebCore::Style::RuleFeatureSet::computeNextMatchElement):

LayoutTests:

* TestExpectations:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestscsscssshadowpartsw3cimportlog">trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/w3c-import.log</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</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="#trunkSourceWebCorecssSelectorCheckercpp">trunk/Source/WebCore/css/SelectorChecker.cpp</a></li>
<li><a href="#trunkSourceWebCorecssSelectorFiltercpp">trunk/Source/WebCore/css/SelectorFilter.cpp</a></li>
<li><a href="#trunkSourceWebCorecssparserCSSParserSelectorh">trunk/Source/WebCore/css/parser/CSSParserSelector.h</a></li>
<li><a href="#trunkSourceWebCorecssparserCSSSelectorParsercpp">trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp</a></li>
<li><a href="#trunkSourceWebCorecssjitSelectorCompilercpp">trunk/Source/WebCore/cssjit/SelectorCompiler.cpp</a></li>
<li><a href="#trunkSourceWebCorestyleRuleFeaturecpp">trunk/Source/WebCore/style/RuleFeature.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestscsscssshadowpartsinteractionwithnestedpseudoclassexpectedhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class-expected.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestscsscssshadowpartsinteractionwithnestedpseudoclasshtml">trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestscsscssshadowpartsinvalidationpartpseudoexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestscsscssshadowpartsinvalidationpartpseudohtml">trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestscsscssshadowpartspartnestedpseudoexpectedhtml">trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/part-nested-pseudo-expected.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestscsscssshadowpartspartnestedpseudohtml">trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/part-nested-pseudo.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (284864 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2021-10-26 14:28:58 UTC (rev 284864)
+++ trunk/LayoutTests/ChangeLog 2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -1,5 +1,14 @@
</span><span class="cx"> 2021-10-26  Antti Koivisto  <antti@apple.com>
</span><span class="cx"> 
</span><ins>+        Fix ::part(foo):hover
+        https://bugs.webkit.org/show_bug.cgi?id=232301
+
+        Reviewed by Alan Bujtas.
+
+        * TestExpectations:
+
+2021-10-26  Antti Koivisto  <antti@apple.com>
+
</ins><span class="cx">         [CSS Cascade Layers] Media queries should be able to affect layer order
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=232238
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (284864 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations       2021-10-26 14:28:58 UTC (rev 284864)
+++ trunk/LayoutTests/TestExpectations  2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -5191,3 +5191,5 @@
</span><span class="cx"> 
</span><span class="cx"> # IPC test failing in Debug mode due to assert.
</span><span class="cx"> [ Debug ] ipc/send-invalid-message.html [ Skip ]
</span><ins>+
+imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class.html [ ImageOnlyFailure ]
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (284864 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-10-26 14:28:58 UTC (rev 284864)
+++ trunk/LayoutTests/imported/w3c/ChangeLog    2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -1,5 +1,20 @@
</span><span class="cx"> 2021-10-26  Antti Koivisto  <antti@apple.com>
</span><span class="cx"> 
</span><ins>+        Fix ::part(foo):hover
+        https://bugs.webkit.org/show_bug.cgi?id=232301
+
+        Reviewed by Alan Bujtas.
+
+        * web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class-expected.html: Added.
+        * web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class.html: Added.
+        * web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo-expected.txt: Added.
+        * web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo.html: Added.
+        * web-platform-tests/css/css-shadow-parts/part-nested-pseudo-expected.html: Added.
+        * web-platform-tests/css/css-shadow-parts/part-nested-pseudo.html: Added.
+        * web-platform-tests/css/css-shadow-parts/w3c-import.log:
+
+2021-10-26  Antti Koivisto  <antti@apple.com>
+
</ins><span class="cx">         Serialize :part() argument as identifier
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=232297
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestscsscssshadowpartsinteractionwithnestedpseudoclassexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class-expected.html (0 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class-expected.html                                (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class-expected.html   2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -0,0 +1,2 @@
</span><ins>+<!DOCTYPE html>
+<button style="color:green">Should be green on focus</button>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestscsscssshadowpartsinteractionwithnestedpseudoclasshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class.html (0 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class.html                         (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class.html    2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -0,0 +1,23 @@
</span><ins>+<!DOCTYPE html>
+<html class="reftest-wait">
+<title>CSS Shadow Parts - Nested Pseudo Classes</title>
+<link rel="help" href="https://drafts.csswg.org/css-shadow-parts" >
+<link rel="help" href="https://drafts.csswg.org/selectors/#matches">
+<link href="https://drafts.csswg.org/selectors/#matches" rel="help">
+<link rel="match" href="interaction-with-nested-pseudo-class-ref.html">
+<script src="/common/reftest-wait.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<style>
+  :root { color: red; }
+  ::part(test):is(:focus) { color: green; }
+</style>
+<div id=host></div>
+<script>
+  const root = host.attachShadow({mode: 'closed'});
+  root.innerHTML = '<button part=test>Should be green on focus</button>';
+  const button = root.querySelector('button');
+  button.addEventListener('focus', takeScreenshot);
+  test_driver.bless('focus button', () => button.focus());
+</script>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestscsscssshadowpartsinvalidationpartpseudoexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo-expected.txt (0 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo-expected.txt                             (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo-expected.txt        2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -0,0 +1,3 @@
</span><ins>+
+PASS Invalidation of nested part on hover
+
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestscsscssshadowpartsinvalidationpartpseudohtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo.html (0 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo.html                             (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo.html        2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -0,0 +1,50 @@
</span><ins>+<!doctype html>
+<title>CSS Shadow Parts - Pseudo class and exported parts</title>
+<link rel="help" href="https://drafts.csswg.org/css-shadow-parts" >
+<link rel="help" href="https://drafts.csswg.org/selectors/#matches">
+<link href="https://drafts.csswg.org/selectors/#matches" rel="help">
+<link rel="match" href="interaction-with-nested-pseudo-class-ref.html">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-actions.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<style>
+/* NOTE: Even though it might be tempting to use :focus instead, because we
+   can more easily add that state programmatically, that'd defeat the point
+   of the test, since :focus / :focus-visible has default styles which
+   invalidate the element's style anyways */
+#host::part(a):hover {
+  background: blue;
+}
+</style>
+<div id="host"></div>
+<script>
+let host = document.querySelector('#host')
+host.attachShadow({mode: 'open'}).innerHTML = `<div part="b" exportparts="a"></div>`;
+
+let innerHost = host.shadowRoot.querySelector('div');
+innerHost.attachShadow({mode: 'open'}).innerHTML = `
+  <style>
+    div {
+      width: 100px;
+      height: 100px;
+      background: black;
+      color: white;
+    }
+  </style>
+  <div part="a">hover, the background should be blue</div>
+`;
+
+let part = innerHost.shadowRoot.querySelector("div");
+let t = async_test("Invalidation of nested part on hover");
+part.addEventListener("mouseover", t.step_func_done(function() {
+  assert_true(part.matches(":hover"), "Element should be hovered");
+  assert_equals(getComputedStyle(part).backgroundColor, "rgb(0, 0, 255)", "Hover style should apply");
+}));
+
+new test_driver.Actions()
+    .pointerMove(0, 0)
+    .pointerMove(50, 50)
+    .send();
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestscsscssshadowpartspartnestedpseudoexpectedhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/part-nested-pseudo-expected.html (0 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/part-nested-pseudo-expected.html                          (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/part-nested-pseudo-expected.html     2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+<!doctype html>
+<title>CSS Test Reference</title>
+<style>
+input {
+  border: 1px solid green;
+}
+</style>
+<input type=file part=input>
+<input type=text part=input placeholder=Foobar>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestscsscssshadowpartspartnestedpseudohtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/part-nested-pseudo.html (0 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/part-nested-pseudo.html                           (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/part-nested-pseudo.html      2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+<!doctype html>
+<title>::part() doesn't incorrectly match pseudo-elements of the part</title>
+<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=978105">
+<link rel="help" href="https://drafts.csswg.org/css-shadow-parts/">
+<link rel="match" href="part-nested-pseudo-ref.html">
+<style>
+#host::part(input) {
+  border: 1px solid green;
+}
+</style>
+<div id="host"></div>
+<script>
+  document.getElementById("host").attachShadow({ mode: "open" }).innerHTML = `
+    <input type=file part=input>
+    <input type=text part=input placeholder=Foobar>
+  `;
+</script>
</ins></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestscsscssshadowpartsw3cimportlog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/w3c-import.log (284864 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/w3c-import.log    2021-10-26 14:28:58 UTC (rev 284864)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/w3c-import.log       2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -26,6 +26,8 @@
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/host-stylesheet.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/idlharness.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/inner-host.html
</span><ins>+/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class-expected.html
+/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class.html
</ins><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-placeholder-expected.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-placeholder.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-pseudo-elements.html
</span><span class="lines">@@ -36,8 +38,12 @@
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-change-part-name.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-complex-selector-forward.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-complex-selector.html
</span><ins>+/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo-expected.html
+/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo.html
</ins><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/multiple-parts.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/part-name-idl.html
</span><ins>+/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/part-nested-pseudo-expected.html
+/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/part-nested-pseudo.html
</ins><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/precedence-part-vs-part.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/serialization.html
</span><span class="cx"> /LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/simple-forward-shorthand.html
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (284864 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-10-26 14:28:58 UTC (rev 284864)
+++ trunk/Source/WebCore/ChangeLog      2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -1,5 +1,44 @@
</span><span class="cx"> 2021-10-26  Antti Koivisto  <antti@apple.com>
</span><span class="cx"> 
</span><ins>+        Fix ::part(foo):hover
+        https://bugs.webkit.org/show_bug.cgi?id=232301
+
+        Reviewed by Alan Bujtas.
+
+        We fail to match on shadow tree border if the right side of ::part() has other selectors.
+
+        Tests: imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo.html
+
+        * css/CSSSelector.cpp:
+        (WebCore::CSSSelector::selectorText const):
+        * css/CSSSelector.h:
+
+        Add a new ShadowPartDescendant relation type that behaves like the existing ShadowDescendant relation
+        except it is only used for ::part.
+
+        * css/SelectorChecker.cpp:
+        (WebCore::SelectorChecker::matchRecursively const):
+
+        We can now identify the ::part case easily from the relation type.
+
+        (WebCore::canMatchHoverOrActiveInQuirksMode):
+        * css/SelectorFilter.cpp:
+        (WebCore::collectSelectorHashes):
+        * css/parser/CSSParserSelector.h:
+        (WebCore::CSSParserSelector::hasShadowDescendant const): Deleted.
+        * css/parser/CSSSelectorParser.cpp:
+        (WebCore::CSSSelectorParser::splitCompoundAtImplicitShadowCrossingCombinator):
+
+        Use ShadowPartDescendant as appropriate.
+
+        * cssjit/SelectorCompiler.cpp:
+        (WebCore::SelectorCompiler::fragmentRelationForSelectorRelation):
+        (WebCore::SelectorCompiler::constructFragmentsInternal):
+        * style/RuleFeature.cpp:
+        (WebCore::Style::RuleFeatureSet::computeNextMatchElement):
+
+2021-10-26  Antti Koivisto  <antti@apple.com>
+
</ins><span class="cx">         Serialize :part() argument as identifier
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=232297
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSSelectorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSSelector.cpp (284864 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSSelector.cpp 2021-10-26 14:28:58 UTC (rev 284864)
+++ trunk/Source/WebCore/css/CSSSelector.cpp    2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -822,6 +822,7 @@
</span><span class="cx">             FALLTHROUGH;
</span><span class="cx"> #endif
</span><span class="cx">         case CSSSelector::ShadowDescendant:
</span><ins>+        case CSSSelector::ShadowPartDescendant:
</ins><span class="cx">             builder.append(rightSide);
</span><span class="cx">             return tagHistory->selectorText(builder.toString());
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebCorecssCSSSelectorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/CSSSelector.h (284864 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/CSSSelector.h   2021-10-26 14:28:58 UTC (rev 284864)
+++ trunk/Source/WebCore/css/CSSSelector.h      2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -86,7 +86,8 @@
</span><span class="cx">             Child,
</span><span class="cx">             DirectAdjacent,
</span><span class="cx">             IndirectAdjacent,
</span><del>-            ShadowDescendant
</del><ins>+            ShadowDescendant,
+            ShadowPartDescendant
</ins><span class="cx">         };
</span><span class="cx"> 
</span><span class="cx">         enum PseudoClassType {
</span></span></pre></div>
<a id="trunkSourceWebCorecssSelectorCheckercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (284864 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/SelectorChecker.cpp     2021-10-26 14:28:58 UTC (rev 284864)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp        2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -77,7 +77,6 @@
</span><span class="cx">     bool hasScrollbarPseudo { false };
</span><span class="cx">     bool hasSelectionPseudo { false };
</span><span class="cx">     bool mayMatchHostPseudoClass { false };
</span><del>-
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> static inline void addStyleRelation(SelectorChecker::CheckingContext& checkingContext, const Element& element, Style::Relation::Type type, unsigned value = 1)
</span><span class="lines">@@ -409,10 +408,10 @@
</span><span class="cx">             return MatchResult::updateWithMatchType(result, matchType);
</span><span class="cx">         }
</span><span class="cx">     case CSSSelector::ShadowDescendant:
</span><ins>+    case CSSSelector::ShadowPartDescendant:
</ins><span class="cx">         {
</span><span class="cx">             // When matching foo::part(bar) we skip directly to the tree of element 'foo'.
</span><del>-            bool isPart = context.selector->match() == CSSSelector::PseudoElement && context.selector->pseudoElementType() == CSSSelector::PseudoElementPart;
-            auto* shadowHost = isPart ? checkingContext.shadowHostInPartRuleScope : context.element->shadowHost();
</del><ins>+            auto* shadowHost = relation == CSSSelector::ShadowPartDescendant ? checkingContext.shadowHostInPartRuleScope : context.element->shadowHost();
</ins><span class="cx">             if (!shadowHost)
</span><span class="cx">                 return MatchResult::fails(Match::SelectorFailsCompletely);
</span><span class="cx">             nextContext.element = shadowHost;
</span><span class="lines">@@ -425,7 +424,6 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-
</del><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="cx">     return MatchResult::fails(Match::SelectorFailsCompletely);
</span><span class="cx"> }
</span><span class="lines">@@ -599,7 +597,7 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         auto relation = selector->relation();
</span><del>-        if (relation == CSSSelector::ShadowDescendant)
</del><ins>+        if (relation == CSSSelector::ShadowDescendant || relation == CSSSelector::ShadowPartDescendant)
</ins><span class="cx">             return true;
</span><span class="cx"> 
</span><span class="cx">         if (relation != CSSSelector::Subselector)
</span></span></pre></div>
<a id="trunkSourceWebCorecssSelectorFiltercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/SelectorFilter.cpp (284864 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/SelectorFilter.cpp      2021-10-26 14:28:58 UTC (rev 284864)
+++ trunk/Source/WebCore/css/SelectorFilter.cpp 2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -194,6 +194,7 @@
</span><span class="cx">         case CSSSelector::DirectAdjacent:
</span><span class="cx">         case CSSSelector::IndirectAdjacent:
</span><span class="cx">         case CSSSelector::ShadowDescendant:
</span><ins>+        case CSSSelector::ShadowPartDescendant:
</ins><span class="cx">             skipOverSubselectors = true;
</span><span class="cx">             break;
</span><span class="cx">         case CSSSelector::DescendantSpace:
</span></span></pre></div>
<a id="trunkSourceWebCorecssparserCSSParserSelectorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/parser/CSSParserSelector.h (284864 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/parser/CSSParserSelector.h      2021-10-26 14:28:58 UTC (rev 284864)
+++ trunk/Source/WebCore/css/parser/CSSParserSelector.h 2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -71,7 +71,6 @@
</span><span class="cx"> 
</span><span class="cx">     bool isPseudoElementCueFunction() const;
</span><span class="cx"> 
</span><del>-    bool hasShadowDescendant() const;
</del><span class="cx">     bool matchesPseudoElement() const;
</span><span class="cx"> 
</span><span class="cx">     bool isHostPseudoSelector() const;
</span><span class="lines">@@ -96,11 +95,6 @@
</span><span class="cx">     std::unique_ptr<CSSParserSelector> m_tagHistory;
</span><span class="cx"> };
</span><span class="cx"> 
</span><del>-inline bool CSSParserSelector::hasShadowDescendant() const
-{
-    return m_selector->relation() == CSSSelector::ShadowDescendant;
-}
-
</del><span class="cx"> inline bool CSSParserSelector::needsImplicitShadowCombinatorForMatching() const
</span><span class="cx"> {
</span><span class="cx">     return match() == CSSSelector::PseudoElement
</span></span></pre></div>
<a id="trunkSourceWebCorecssparserCSSSelectorParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp (284864 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp    2021-10-26 14:28:58 UTC (rev 284864)
+++ trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp       2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -1068,7 +1068,7 @@
</span><span class="cx">     } else
</span><span class="cx">         secondCompound = splitAfter->releaseTagHistory();
</span><span class="cx"> 
</span><del>-    secondCompound->appendTagHistory(CSSSelector::ShadowDescendant, WTFMove(compoundSelector));
</del><ins>+    secondCompound->appendTagHistory(isPart ? CSSSelector::ShadowPartDescendant : CSSSelector::ShadowDescendant, WTFMove(compoundSelector));
</ins><span class="cx">     return secondCompound;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorecssjitSelectorCompilercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/cssjit/SelectorCompiler.cpp (284864 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/cssjit/SelectorCompiler.cpp 2021-10-26 14:28:58 UTC (rev 284864)
+++ trunk/Source/WebCore/cssjit/SelectorCompiler.cpp    2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -500,6 +500,7 @@
</span><span class="cx">         return FragmentRelation::IndirectAdjacent;
</span><span class="cx">     case CSSSelector::Subselector:
</span><span class="cx">     case CSSSelector::ShadowDescendant:
</span><ins>+    case CSSSelector::ShadowPartDescendant:
</ins><span class="cx">         ASSERT_NOT_REACHED();
</span><span class="cx">     }
</span><span class="cx">     ASSERT_NOT_REACHED();
</span><span class="lines">@@ -1322,7 +1323,7 @@
</span><span class="cx">         if (relation == CSSSelector::Subselector)
</span><span class="cx">             continue;
</span><span class="cx"> 
</span><del>-        if (relation == CSSSelector::ShadowDescendant && !selector->isLastInTagHistory())
</del><ins>+        if ((relation == CSSSelector::ShadowDescendant || relation == CSSSelector::ShadowPartDescendant) && !selector->isLastInTagHistory())
</ins><span class="cx">             return FunctionType::CannotCompile;
</span><span class="cx"> 
</span><span class="cx">         if (relation == CSSSelector::DirectAdjacent || relation == CSSSelector::IndirectAdjacent) {
</span></span></pre></div>
<a id="trunkSourceWebCorestyleRuleFeaturecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/style/RuleFeature.cpp (284864 => 284865)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/style/RuleFeature.cpp       2021-10-26 14:28:58 UTC (rev 284864)
+++ trunk/Source/WebCore/style/RuleFeature.cpp  2021-10-26 14:55:58 UTC (rev 284865)
</span><span class="lines">@@ -84,6 +84,7 @@
</span><span class="cx">                 return MatchElement::AnySibling;
</span><span class="cx">             return matchElement == MatchElement::Subject ? MatchElement::DirectSibling : MatchElement::IndirectSibling;
</span><span class="cx">         case CSSSelector::ShadowDescendant:
</span><ins>+        case CSSSelector::ShadowPartDescendant:
</ins><span class="cx">             return MatchElement::Host;
</span><span class="cx">         };
</span><span class="cx">     }
</span><span class="lines">@@ -97,6 +98,7 @@
</span><span class="cx">     case CSSSelector::DirectAdjacent:
</span><span class="cx">         return matchElement == MatchElement::Parent ? MatchElement::ParentSibling : MatchElement::AncestorSibling;
</span><span class="cx">     case CSSSelector::ShadowDescendant:
</span><ins>+    case CSSSelector::ShadowPartDescendant:
</ins><span class="cx">         return MatchElement::Host;
</span><span class="cx">     };
</span><span class="cx">     ASSERT_NOT_REACHED();
</span></span></pre>
</div>
</div>

</body>
</html>