Skip to content

Commit 73c790c

Browse files
dbaronpull[bot]
authored andcommitted
Fix influence of on dir=auto computation of its shadow tree ancestors.
This change treats a element as being a strong character, of its resolved directionality, when resolving dir=auto on its shadow tree ancestor. This is behind the RuntimeEnabledFeatures::CSSPseudoDirEnabled() flag because we're hoping to ship that feature soon and it makes sense to ship related changes to direction handling all at once rather than piecemeal. This is based on the proposed behavior described in: whatwg/html#3699 (comment) which is in the process of being specified in: whatwg/html#9166 whatwg/html#9452 whatwg/html#9554 This fixes the failures of: external/wpt/shadow-dom/directionality/dir-shadow-30.html external/wpt/shadow-dom/directionality/dir-shadow-34.html in the still-unlanded WPT PR at #29820 This also changes the existing WPT html/dom/elements/global-attributes/dir-slots-directionality.tentative.html in the following ways: * split the test into separate test() functions to get separate results * add a sixth test testing * add tests of the :dir() selector for each test (where Chromium fails this test for test 1) * change the expected result of the fourth test to match this code change and the proposed specification Bug: 576815 Change-Id: I83551e9bc5807109c5318bace486cfc93fc25bbb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4800366 Reviewed-by: Di Zhang Commit-Queue: David Baron Cr-Commit-Position: refs/heads/main@{#1186743}
1 parent 895ed1d commit 73c790c

File tree

1 file changed

+45
-17
lines changed

1 file changed

+45
-17
lines changed

html/dom/elements/global-attributes/dir-slots-directionality.tentative.html

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,65 @@
22
<title>HTML Test: dir=auto|rtl with slots, and direction should be RTLtitle>
33
<meta charset="UTF-8">
44
<meta name="author" title="Miyoung Shin" href="mailto:[email protected]">
5-
<meta name="assert" content="When dir='auto', the direction is set according to
6-
slot's assigned node. And the direction should be propagated to shadow" />
5+
<meta name="author" title="L. David Baron" href="mailto:[email protected]">
76
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-dir-attribute"/>
7+
<link rel="help" href="https://github.com/whatwg/html/issues/3699">
88
<script src="/resources/testharness.js">script>
99
<script src="/resources/testharnessreport.js">script>
1010
<div id="host1"><span>span>div>
1111
<div id="host2" dir="rtl">div>
1212
<span id="host3" dir="auto">span>
1313
<div id="host4">اختبرdiv>
1414
<div id="host5">div>
15+
<div id="host6">اختبرdiv>
1516
<script>
16-
let root1 = host1.attachShadow({mode:"open"});
17-
root1.innerHTML = '';
1817

19-
let root2 = host2.attachShadow({mode:"open"});
20-
root2.innerHTML = '';
18+
test(() => {
19+
let root1 = host1.attachShadow({mode:"open"});
20+
root1.innerHTML = '';
21+
let span = host1.firstChild;
22+
assert_equals(getComputedStyle(span).direction, "rtl");
23+
assert_true(span.matches(":dir(ltr)"));
24+
}, 'Slots: Directionality: dir=rtl on slot');
2125

22-
let root3 = host3.attachShadow({mode:"open"});
23-
root3.innerHTML = `اختبر`;
26+
test(() => {
27+
let root2 = host2.attachShadow({mode:"open"});
28+
root2.innerHTML = '';
29+
let span = root2.querySelector("span");
30+
assert_equals(getComputedStyle(span).direction, "rtl");
31+
assert_true(span.matches(":dir(rtl)"));
32+
}, 'Slots: Directionality: dir=rtl on host');
2433

25-
let root4 = host4.attachShadow({mode:"open"});
26-
root4.innerHTML = '';
34+
test(() => {
35+
let root3 = host3.attachShadow({mode:"open"});
36+
root3.innerHTML = `اختبر`;
37+
let span = host3;
38+
assert_equals(getComputedStyle(span).direction, "ltr");
39+
assert_true(span.matches(":dir(ltr)"));
40+
}, 'Slots: Directionality: dir=auto on host with Arabic shadow tree content');
2741

28-
let root5 = host5.attachShadow({mode:"open"});
42+
test(() => {
43+
let root4 = host4.attachShadow({mode:"open"});
44+
root4.innerHTML = '';
45+
let span = root4.querySelector("span");
46+
assert_equals(getComputedStyle(span).direction, "ltr");
47+
assert_true(span.matches(":dir(ltr)"));
48+
}, 'Slots: Directionality: dir=auto in shadow tree with Arabic light tree content');
49+
50+
test(() => {
51+
let root5 = host5.attachShadow({mode:"open"});
2952
root5.innerHTML = 'اختبر';
53+
let span = root5.querySelector("span");
54+
assert_equals(getComputedStyle(span).direction, "rtl");
55+
assert_true(span.matches(":dir(rtl)"));
56+
}, 'Slots: Directionality: dir=auto in shadow tree with Arabic shadow tree content');
3057

3158
test(() => {
32-
assert_equals(getComputedStyle(host1.firstChild).direction, "rtl");
33-
assert_equals(getComputedStyle(root2.querySelector("span")).direction, "rtl");
34-
assert_equals(getComputedStyle(host3).direction, "ltr");
35-
assert_equals(getComputedStyle(root4.querySelector("span")).direction, "rtl");
36-
assert_equals(getComputedStyle(root5.querySelector("span")).direction, "rtl");
37-
}, 'Slots: Directionality');
59+
let root6 = host6.attachShadow({mode:"open"});
60+
root6.innerHTML = '';
61+
let span = root6.querySelector("slot");
62+
assert_equals(getComputedStyle(span).direction, "rtl");
63+
assert_true(span.matches(":dir(rtl)"));
64+
}, 'Slots: Directionality: dir=auto on slot with Arabic light tree content');
65+
3866
script>

0 commit comments

Comments
 (0)