Skip to content

Commit 57730b4

Browse files
committed
Support ::before and ::after pseudo elements after ::slotted
https://bugs.webkit.org/show_bug.cgi?id=178237 Reviewed by Ryosuke Niwa. LayoutTests/imported/w3c: Update the tests from WPT repo. * web-platform-tests/css/css-scoping/host-context-parsing-expected.txt: Added. * web-platform-tests/css/css-scoping/host-context-parsing.html: Added. * web-platform-tests/css/css-scoping/host-parsing-expected.txt: Added. * web-platform-tests/css/css-scoping/host-parsing.html: Added. * web-platform-tests/css/css-scoping/keyframes-001-expected.txt: * web-platform-tests/css/css-scoping/shadow-shared-style-cache-001-expected.txt: Added. * web-platform-tests/css/css-scoping/shadow-shared-style-cache-001.html: Added. * web-platform-tests/css/css-scoping/slotted-link-expected.txt: * web-platform-tests/css/css-scoping/slotted-parsing-expected.txt: * web-platform-tests/css/css-scoping/slotted-parsing.html: * web-platform-tests/css/css-scoping/w3c-import.log: Source/WebCore: Change the way we resolve ::slotted to improve compatibility. We now traverse through the assigned slot chain in a single pass, similar to ::part matching. * css/CSSSelector.cpp: (WebCore::CSSSelector::selectorText const): * css/CSSSelector.h: Add a new selection relation ShadowSlotted, similar to the existing ShadowDescendant and ShadowPartDescendant, for switching scopes during selector matching. * css/SelectorChecker.cpp: (WebCore::SelectorChecker::matchRecursively const): Find the right scope to continue matching on ShadowSlotted relation. Pass in the scope ordinal to find the scope. (WebCore::SelectorChecker::checkOne const): Match the ::slotted() element. * css/SelectorChecker.h: * css/SelectorFilter.cpp: (WebCore::collectSelectorHashes): * css/parser/CSSParserSelector.h: (WebCore::CSSParserSelector::needsImplicitShadowCombinatorForMatching const): * css/parser/CSSSelectorParser.cpp: (WebCore::isPseudoClassValidAfterPseudoElement): (WebCore::isTreeAbidingPseudoElement): Add a spec-termed helper. (WebCore::isSimpleSelectorValidAfterPseudoElement): (WebCore::CSSSelectorParser::splitCompoundAtImplicitShadowCrossingCombinator): Insert ShadowSlotted relation for ::slotted(). * cssjit/SelectorCompiler.cpp: (WebCore::SelectorCompiler::fragmentRelationForSelectorRelation): (WebCore::SelectorCompiler::constructFragmentsInternal): * style/ElementRuleCollector.cpp: (WebCore::Style::ElementRuleCollector::clearMatchedRules): (WebCore::Style::ElementRuleCollector::matchSlottedPseudoElementRules): Simply get the rules from scopes in the assinged slot chaing and match against them. No need for two passes. (WebCore::Style::ElementRuleCollector::ruleMatches): (WebCore::Style::ElementRuleCollector::collectMatchingRulesForList): (WebCore::Style::ElementRuleCollector::collectSlottedPseudoElementRulesForSlot): Deleted. Not needed anymore. (WebCore::Style::findSlottedPseudoElementSelector): Deleted. * style/ElementRuleCollector.h: * style/RuleFeature.cpp: (WebCore::Style::RuleFeatureSet::computeNextMatchElement): LayoutTests: * TestExpectations: Canonical link: https://commits.webkit.org/243623@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284973 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 7fd76d1 commit 57730b4

26 files changed

Lines changed: 294 additions & 95 deletions

LayoutTests/ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2021-10-28 Antti Koivisto <antti@apple.com>
2+
3+
Support ::before and ::after pseudo elements after ::slotted
4+
https://bugs.webkit.org/show_bug.cgi?id=178237
5+
6+
Reviewed by Ryosuke Niwa.
7+
8+
* TestExpectations:
9+
110
2021-10-28 Carlos Garcia Campos <cgarcia@igalia.com>
211

312
AX: AXValueChanged is only sent for range elements when value is changed with the keyboard

LayoutTests/TestExpectations

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3097,7 +3097,6 @@ imported/w3c/web-platform-tests/css/css-display/run-in/run-in-table-row-between-
30973097
imported/w3c/web-platform-tests/css/css-display/run-in/run-in-text-between-004.xht [ ImageOnlyFailure ]
30983098
imported/w3c/web-platform-tests/css/css-display/run-in/run-in-text-between-005.xht [ ImageOnlyFailure ]
30993099
imported/w3c/web-platform-tests/css/css-pseudo/placeholder-input-number.html [ ImageOnlyFailure ]
3100-
imported/w3c/web-platform-tests/css/css-scoping/slotted-with-pseudo-element.html [ ImageOnlyFailure ]
31013100
imported/w3c/web-platform-tests/css/css-text-decor/text-emphasis-color-001.xht [ ImageOnlyFailure ]
31023101
imported/w3c/web-platform-tests/css/css-text-decor/text-emphasis-position-above-left-001.xht [ ImageOnlyFailure ]
31033102
imported/w3c/web-platform-tests/css/css-text-decor/text-emphasis-position-above-left-002.xht [ ImageOnlyFailure ]
@@ -3208,7 +3207,6 @@ webkit.org/b/190032 compositing/layer-creation/scale-rotation-transition-overlap
32083207
webkit.org/b/190032 compositing/layer-creation/translate-scale-transition-overlap.html [ Failure ]
32093208
webkit.org/b/190032 compositing/layer-creation/translate-transition-overlap.html [ Failure ]
32103209
webkit.org/b/190032 imported/w3c/web-platform-tests/css/css-logical/animation-003.tentative.html [ Failure ]
3211-
webkit.org/b/190032 imported/w3c/web-platform-tests/css/css-scoping/keyframes-001.html [ Failure ]
32123210

32133211
# FIXME: Need to implement MediaRecorder dataavailable event to support these testcases
32143212
fast/mediacapturefromelement/CanvasCaptureMediaStream-imagebitmaprenderingcontext.html [ Skip ]

LayoutTests/imported/w3c/ChangeLog

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
2021-10-28 Antti Koivisto <antti@apple.com>
2+
3+
Support ::before and ::after pseudo elements after ::slotted
4+
https://bugs.webkit.org/show_bug.cgi?id=178237
5+
6+
Reviewed by Ryosuke Niwa.
7+
8+
Update the tests from WPT repo.
9+
10+
* web-platform-tests/css/css-scoping/host-context-parsing-expected.txt: Added.
11+
* web-platform-tests/css/css-scoping/host-context-parsing.html: Added.
12+
* web-platform-tests/css/css-scoping/host-parsing-expected.txt: Added.
13+
* web-platform-tests/css/css-scoping/host-parsing.html: Added.
14+
* web-platform-tests/css/css-scoping/keyframes-001-expected.txt:
15+
* web-platform-tests/css/css-scoping/shadow-shared-style-cache-001-expected.txt: Added.
16+
* web-platform-tests/css/css-scoping/shadow-shared-style-cache-001.html: Added.
17+
* web-platform-tests/css/css-scoping/slotted-link-expected.txt:
18+
* web-platform-tests/css/css-scoping/slotted-parsing-expected.txt:
19+
* web-platform-tests/css/css-scoping/slotted-parsing.html:
20+
* web-platform-tests/css/css-scoping/w3c-import.log:
21+
122
2021-10-27 Kiet Ho <tho22@apple.com>
223

324
Add discrete animation support between PathOperations
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
FAIL ":host-context(.a)" should be a valid selector The string did not match the expected pattern.
3+
FAIL ":host-context(div.a)" should be a valid selector The string did not match the expected pattern.
4+
PASS ":host-context" should be an invalid selector
5+
PASS ":host-context()" should be an invalid selector
6+
PASS ":host-context(.a, .b)" should be an invalid selector
7+
PASS ":host-context(.a + .b)" should be an invalid selector
8+
PASS ":host-context(.a + .b, #c > #d)" should be an invalid selector
9+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<title>Test parsing of the host-context() pseudo-classes</title>
3+
<link rel="help" href="https://drafts.csswg.org/css-scoping/#selectordef-host-context">
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
<script src="/css/support/parsing-testcommon.js"></script>
7+
<script>
8+
test_valid_selector(':host-context(.a)');
9+
test_valid_selector(':host-context(div.a)');
10+
11+
test_invalid_selector(':host-context');
12+
test_invalid_selector(':host-context()');
13+
test_invalid_selector(':host-context(.a, .b)');
14+
test_invalid_selector(':host-context(.a + .b)');
15+
test_invalid_selector(':host-context(.a + .b, #c > #d)');
16+
</script>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
PASS ":host" should be a valid selector
3+
PASS ":host(.a)" should be a valid selector
4+
PASS ":host(div.a)" should be a valid selector
5+
PASS ":host()" should be an invalid selector
6+
FAIL ":host(.a, .b)" should be an invalid selector assert_throws_dom: ":host(.a, .b)" should throw in querySelector function "() => document.querySelector(selector)" did not throw
7+
PASS ":host(.a + .b)" should be an invalid selector
8+
PASS ":host(.a + .b, #c > #d)" should be an invalid selector
9+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<title>Test parsing of the :host/host() pseudo-classes</title>
3+
<link rel="help" href="https://drafts.csswg.org/css-scoping/#selectordef-host-function">
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
<script src="/css/support/parsing-testcommon.js"></script>
7+
<script>
8+
test_valid_selector(':host');
9+
test_valid_selector(':host(.a)');
10+
test_valid_selector(':host(div.a)');
11+
12+
test_invalid_selector(':host()');
13+
test_invalid_selector(':host(.a, .b)');
14+
test_invalid_selector(':host(.a + .b)');
15+
test_invalid_selector(':host(.a + .b, #c > #d)');
16+
</script>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

2-
FAIL @keyframes applies in the shadow tree assert_equals: expected 1 but got 0
2+
PASS @keyframes applies in the shadow tree
33

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
PASS Shared style invalidation with removals
3+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>Shared style invalidation with removals</title>
4+
<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1707116">
5+
<link rel="help" href="https://drafts.csswg.org/css-scoping/">
6+
<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
7+
<link rel="author" href="https://mozilla.org" title="Mozilla">
8+
<script src="/resources/testharness.js"></script>
9+
<script src="/resources/testharnessreport.js"></script>
10+
<div id="host-1"></div>
11+
<div id="host-2"></div>
12+
<script>
13+
const INITIALLY_COMMON_STYLE = `<style>:host { background-color: red !important }</style>`;
14+
let helper = document.querySelector("#host-1");
15+
let host = document.querySelector("#host-2");
16+
17+
test(function() {
18+
helper.attachShadow({ mode: "open" }).innerHTML = INITIALLY_COMMON_STYLE;
19+
assert_equals(getComputedStyle(helper).backgroundColor, "rgb(255, 0, 0)", "Common style should apply to helper");
20+
21+
host.attachShadow({ mode: "open" }).innerHTML = INITIALLY_COMMON_STYLE;
22+
assert_equals(getComputedStyle(host).backgroundColor, "rgb(255, 0, 0)", "Common style should apply to host");
23+
24+
host.shadowRoot.innerHTML = `<style>:host { background-color: lime; width: 100px; height: 100px; }</style>`;
25+
assert_equals(getComputedStyle(host).backgroundColor, "rgb(0, 255, 0)", "Common style should no longer apply to host");
26+
});
27+
</script>

0 commit comments

Comments
 (0)