Skip to content

Commit 2935338

Browse files
dizhang168chromium-wpt-export-bot
authored andcommitted
[reading-flow] display: contents participate in the flow
From CSSWG resolution [1]: > display:contents focusable element occurs immediately before its first child in visual order [1] w3c/csswg-drafts#9230 (comment) Currently, reading flow items in display: contents are ignored and display: contents elements are visited last in the focus order. That means we lose that order information. We update the algorithm so when we loop reading items and find one that is not in the focus scope, we traverse its parent to find an ancestor that is. This element can then be added in the reading flow instead. We update A11Y to behave the same way as focus navigation. Since the A11Y tree uses LayoutTreeBuilder, we update the algorithm to loop through each reading flow item's ancestor until its parent is the LayoutTreeBuilderTraversal::Parent. This element can then be added in the reading flow instead. Change-Id: I1c3c3ab3a6548611af9a2cfddecc9d889b0ecb14 Bug: 371024057 Bug: 40932006
1 parent 4452d36 commit 2935338

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

Diff for: shadow-dom/focus-navigation/reading-flow/tentative/grid-order-across-scopes.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
}
1919
</style>
2020

21-
<!-- Since C is a direct reading flow item, it is visited first. -->
22-
<!-- Since B,A are inside a display: contents, they are visited after. -->
23-
<div class="test-case" data-expect="C,B,A"
21+
<!-- Since B,A are inside a display: contents, they are visited together. -->
22+
<!-- Since B has order 1, its display: contents parent is visited first. -->
23+
<div class="test-case" data-expect="B,A,C"
2424
data-description="Grid items in shadow host that is a display contents grid item">
2525
<div class=wrapper>
2626
<div style="display: contents">

Diff for: shadow-dom/focus-navigation/reading-flow/tentative/grid-order-with-display-contents.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
}
2020
</style>
2121

22-
<div class="test-case" data-expect="order1,order3,order2,order4"
23-
data-description="Items in display contents are sorted in same grid container.">
22+
<div class="test-case" data-expect="order1,order2,order4,order3"
23+
data-description="Items in display contents are sorted in same grid container and are placed in the position where their first child resides.">
2424
<div class="wrapper">
2525
<div style="display: contents">
2626
<button id="order3" style="order: 3">Order 3</button>
@@ -33,8 +33,8 @@
3333
</div>
3434
</div>
3535

36-
<div class="test-case" data-expect="div1B,order1B,order3B,div2B,order2B,order4B"
37-
data-description="Items in display contents are sorted in same grid container, with focusable display contents divs at the end of the focus sequence.">
36+
<div class="test-case" data-expect="div1B,order1B,div2B,order2B,order4B,order3B"
37+
data-description="Items in display contents are sorted in same grid container and are placed in the position where their first child resides. The display contents have tabindex and should be focusable.">
3838
<div class="wrapper">
3939
<div id="div1B" style="display: contents" tabindex="0">
4040
<button id="order3B" style="order: 3">Order 3</button>
@@ -47,9 +47,9 @@
4747
</div>
4848
</div>
4949

50-
<div class="test-case" data-expect="A1,A2,A3,B1,B2,B3,C1,C2,C3,D1,D2,D3"
50+
<div class="test-case" data-expect="C1,C2,C3,D1,D2,D3,B1,B2,B3,A1,A2,A3"
5151
data-description="Grid items are in nested display contents containers.">
52-
<div class=box>
52+
<div class=wrapper>
5353
<div style="display:contents" tabindex="0" id="A1">
5454
<div style="display:contents" tabindex="0" id="A2">
5555
<button style="order: 4" id="A3">A</button>

Diff for: shadow-dom/focus-navigation/reading-flow/tentative/grid-order-with-slots.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
</span>
5656
<br>
5757

58-
<span id="host3" class="test-case" data-expect="host3/o2,host3/o4,o1,o3,o5"
58+
<span id="host3" class="test-case" data-expect="o1,o3,o5,host3/o2,host3/o4"
5959
data-description="Slot is inside a grid container with reading-flow.">
6060
<template shadowrootmode="open">
6161
<style>
@@ -77,7 +77,7 @@
7777
<br>
7878

7979
<span id="host4" class="test-case"
80-
data-expect="host4/after,host4/before,b4,a4,d42,d41,d43,c4"
80+
data-expect="b4,a4,d42,d41,d43,c4,host4/after,host4/before"
8181
data-description="Slot is a grid with reading-flow inside a grid container with reading-flow.">
8282
<template shadowrootmode="open">
8383
<style>
@@ -120,7 +120,7 @@
120120
</span>
121121
<br>
122122

123-
<span id="host6" class="test-case" data-expect="host6/after,host6/before,b6,a6"
123+
<span id="host6" class="test-case" data-expect="b6,a6,host6/after,host6/before"
124124
data-description="Slot is a display contents inside a grid container.">
125125
<template shadowrootmode="open">
126126
<style>
@@ -140,7 +140,7 @@
140140
</span>
141141
<br>
142142

143-
<span id="host7" class="test-case" data-expect="a7,b7,host7/after,host7/before"
143+
<span id="host7" class="test-case" data-expect="host7/after,a7,b7,host7/before"
144144
data-description="Slot is a display block inside a grid container.">
145145
<template shadowrootmode="open">
146146
<style>
@@ -150,8 +150,8 @@
150150
}
151151
</style>
152152
<div class="wrapper">
153-
<button style="order: 4" id="before">Before</button>
154-
<slot style="display: block" style="order: 4"></slot>
153+
<button style="order: 5" id="before">Before</button>
154+
<slot style="display: block; order: 4"></slot>
155155
<button style="order: 3" id="after">After</button>
156156
</div>
157157
</template>

0 commit comments

Comments
 (0)