Skip to content

Commit 61a2d96

Browse files
David Awogbemilachromium-wpt-export-bot
David Awogbemila
authored andcommitted
[carousel] Implement targeted scroll-marker selection for ::column
::column pseudos[1] may create ::scroll-markers, but do not exist in the DOM tree as parents of the elements which are flowed into them. They also do not appear to have LayoutObjects and are not found[2] in the layout tree. So, when searching for the appropriate scroll-marker to select for a targeted scroll we need to consider whether the scroll-marker-generating element (marker-generating-element) found in the layout tree is also flowed into the same scroll-marker-generating ::column (marker-generating-column) as the target of the scrollIntoView operation. If the target and marker-generating-element are both in marker-generating-column, marker-generating-element is the preferred[3] choice. The only means we have of checking whether an element is flowed into a ::column is by looking at the rect associated with that ::column. [1] https://drafts.csswg.org/css-multicol-2/#column-pseudo [2] https://source.chromium.org/chromium/chromium/src/+/165f5ddad25b289f886a248ca810d075b1e7bb87:third_party/blink/renderer/core/page/scrolling/snap_coordinator.cc;l=254-255 [3] w3c/csswg-drafts#10738 (comment) Bug: 380062280 Change-Id: Ie2ad58c3beca13a4945325d9aa9c4aec6a5fc332 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6088285 Commit-Queue: David Awogbemila <[email protected]> Reviewed-by: Steve Kobes <[email protected]> Cr-Commit-Position: refs/heads/main@{#1399198}
1 parent 9bbcdbf commit 61a2d96

8 files changed

+857
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>CSS Test: scroll tracking for ::scroll-markers whose orignatin elements cannot be scroll-aligned </title>
7+
<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-container-scroll">
8+
</head>
9+
10+
<body>
11+
<style>
12+
.wrapper {
13+
display: grid;
14+
justify-content: center;
15+
}
16+
17+
.carousel {
18+
width: 800px;
19+
height: 200px;
20+
overflow-x: scroll;
21+
scroll-snap-type: x mandatory;
22+
list-style-type: none;
23+
scroll-behavior: smooth;
24+
border: solid 2px grey;
25+
padding-top: 10%;
26+
text-align: center;
27+
counter-set: markeridx -1;
28+
columns: 2;
29+
30+
& > :nth-child(odd)::scroll-marker {
31+
content: counter(markeridx);
32+
counter-increment: markeridx;
33+
align-content: center;
34+
text-align: center;
35+
width: 35px;
36+
height: 35px;
37+
border-radius: 50%;
38+
margin: 3px;
39+
background-color: red;
40+
}
41+
/* item 2 is child 3 */
42+
& > :nth-child(3)::scroll-marker {
43+
background-color: green;
44+
}
45+
46+
&>.item {
47+
scroll-snap-align: center;
48+
height: 80%;
49+
width: 158px;
50+
border: 1px solid;
51+
place-content: center;
52+
display: inline-block;
53+
}
54+
55+
scroll-marker-group: after;
56+
57+
&::scroll-marker-group {
58+
height: 45px;
59+
display: flex;
60+
align-items: center;
61+
justify-content: center;
62+
border: solid 1px black;
63+
border-radius: 30px;
64+
}
65+
}
66+
</style>
67+
<div class="wrapper" id="wrapper">
68+
<div class="carousel" id="carousel">
69+
<div class="item item0" tabindex=0>0</div>
70+
<div class="item item1" tabindex=0>1</div>
71+
<div class="item item2" tabindex=0>2</div>
72+
<div class="item item3" tabindex=0>3</div>
73+
<div class="item item4" tabindex=0>4</div>
74+
<div class="item item5" tabindex=0>5</div>
75+
<div class="item item6" tabindex=0>6</div>
76+
<div class="item item7" tabindex=0>7</div>
77+
<div class="item item8" tabindex=0>8</div>
78+
<div class="item item9" tabindex=0>9</div>
79+
<div class="item item10" tabindex=0>10</div>
80+
<div class="item item11" tabindex=0>11</div>
81+
<div class="item item12" tabindex=0>12</div>
82+
<div class="item item13" tabindex=0>13</div>
83+
<div class="item item14" tabindex=0>14</div>
84+
<div class="item item15" tabindex=0>15</div>
85+
</div>
86+
</div>
87+
</body>
88+
89+
</html>
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<!DOCTYPE html>
2+
<html class="reftest-wait">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>CSS Test: scroll tracking for ::scroll-markers whose orignatin elements cannot be scroll-aligned </title>
7+
<link rel="match" href="targeted-column-scroll-marker-selection-001-ref.html">
8+
<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-container-scroll">
9+
<script src="/css/css-transitions/support/helper.js"></script>
10+
<script src="/dom/events/scrolling/scroll_support.js"></script>
11+
<script src="/common/reftest-wait.js"></script>
12+
</head>
13+
14+
<body>
15+
<style>
16+
.wrapper {
17+
display: grid;
18+
justify-content: center;
19+
}
20+
21+
.carousel {
22+
width: 800px;
23+
height: 200px;
24+
overflow-x: scroll;
25+
scroll-snap-type: x mandatory;
26+
list-style-type: none;
27+
scroll-behavior: smooth;
28+
border: solid 2px grey;
29+
padding-top: 10%;
30+
text-align: center;
31+
counter-set: markeridx -1;
32+
columns: 2;
33+
34+
&::column::scroll-marker {
35+
content: counter(markeridx);
36+
counter-increment: markeridx;
37+
align-content: center;
38+
text-align: center;
39+
width: 35px;
40+
height: 35px;
41+
border-radius: 50%;
42+
margin: 3px;
43+
background-color: red;
44+
}
45+
&::column::scroll-marker:target-current {
46+
background-color: green;
47+
}
48+
&>.item {
49+
scroll-snap-align: center;
50+
height: 80%;
51+
width: 158px;
52+
border: 1px solid;
53+
place-content: center;
54+
display: inline-block;
55+
}
56+
57+
scroll-marker-group: after;
58+
59+
&::scroll-marker-group {
60+
height: 45px;
61+
display: flex;
62+
align-items: center;
63+
justify-content: center;
64+
border: solid 1px black;
65+
border-radius: 30px;
66+
}
67+
}
68+
</style>
69+
<div class="wrapper" id="wrapper">
70+
<div class="carousel" id="carousel">
71+
<div class="item item0" tabindex=0>0</div>
72+
<div class="item item1" tabindex=0>1</div>
73+
<div class="item item2" tabindex=0>2</div>
74+
<div class="item item3" tabindex=0>3</div>
75+
<div class="item item4" tabindex=0>4</div>
76+
<div class="item item5" tabindex=0>5</div>
77+
<div class="item item6" tabindex=0>6</div>
78+
<div class="item item7" tabindex=0>7</div>
79+
<div class="item item8" tabindex=0>8</div>
80+
<div class="item item9" tabindex=0>9</div>
81+
<div class="item item10" tabindex=0>10</div>
82+
<div class="item item11" tabindex=0>11</div>
83+
<div class="item item12" tabindex=0>12</div>
84+
<div class="item item13" tabindex=0>13</div>
85+
<div class="item item14" tabindex=0>14</div>
86+
<div class="item item15" tabindex=0>15</div>
87+
</div>
88+
</div>
89+
<script>
90+
91+
const items = document.querySelectorAll(".item");
92+
function runTest() {
93+
const item2 = items[2];
94+
item2.scrollIntoView();
95+
waitForAnimationFrames(2).then(() => {
96+
takeScreenshot();
97+
});
98+
}
99+
waitForCompositorReady().then(runTest);
100+
</script>
101+
</body>
102+
103+
</html>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>CSS Test: scroll tracking for ::scroll-markers whose orignatin elements cannot be scroll-aligned </title>
7+
<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-container-scroll">
8+
</head>
9+
10+
<body>
11+
<style>
12+
.wrapper {
13+
display: grid;
14+
justify-content: center;
15+
}
16+
17+
.carousel {
18+
width: 800px;
19+
height: 200px;
20+
overflow-x: scroll;
21+
scroll-snap-type: x mandatory;
22+
list-style-type: none;
23+
scroll-behavior: smooth;
24+
border: solid 2px grey;
25+
padding-top: 10%;
26+
text-align: center;
27+
counter-set: markeridx -1;
28+
columns: 2;
29+
30+
& > :nth-child(odd)::scroll-marker {
31+
content: counter(markeridx);
32+
counter-increment: markeridx;
33+
align-content: center;
34+
text-align: center;
35+
width: 35px;
36+
height: 35px;
37+
border-radius: 50%;
38+
margin: 3px;
39+
background-color: red;
40+
}
41+
/* item 4 is child 5 */
42+
& > :nth-child(5)::scroll-marker {
43+
background-color: green;
44+
}
45+
46+
&>.item {
47+
scroll-snap-align: none;
48+
height: 80%;
49+
width: 158px;
50+
border: 1px solid;
51+
place-content: center;
52+
display: inline-block;
53+
}
54+
55+
/* Item 3 is child 4. Starting from scrollLeft=0, calling
56+
box4.scrollIntoView ends up in a position that aligns box 3. */
57+
& > :nth-child(4){
58+
scroll-snap-align: center;
59+
}
60+
61+
scroll-marker-group: after;
62+
63+
&::scroll-marker-group {
64+
height: 45px;
65+
display: flex;
66+
align-items: center;
67+
justify-content: center;
68+
border: solid 1px black;
69+
border-radius: 30px;
70+
}
71+
}
72+
</style>
73+
<div class="wrapper" id="wrapper">
74+
<div class="carousel" id="carousel">
75+
<div class="item item0" tabindex=0>0</div>
76+
<div class="item item1" tabindex=0>1</div>
77+
<div class="item item2" tabindex=0>2</div>
78+
<div class="item item3" tabindex=0>3</div>
79+
<div class="item item4" tabindex=0>4</div>
80+
<div class="item item5" tabindex=0>5</div>
81+
<div class="item item6" tabindex=0>6</div>
82+
<div class="item item7" tabindex=0>7</div>
83+
<div class="item item8" tabindex=0>8</div>
84+
<div class="item item9" tabindex=0>9</div>
85+
<div class="item item10" tabindex=0>10</div>
86+
<div class="item item11" tabindex=0>11</div>
87+
<div class="item item12" tabindex=0>12</div>
88+
<div class="item item13" tabindex=0>13</div>
89+
<div class="item item14" tabindex=0>14</div>
90+
<div class="item item15" tabindex=0>15</div>
91+
</div>
92+
</div>
93+
</body>
94+
95+
</html>
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<!DOCTYPE html>
2+
<html class="reftest-wait">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>CSS Test: scroll tracking for ::scroll-markers whose orignatin elements cannot be scroll-aligned </title>
7+
<link rel="match" href="targeted-column-scroll-marker-selection-002-ref.html">
8+
<link rel="help" href="https://drafts.csswg.org/css-overflow-5/#scroll-container-scroll">
9+
<script src="/css/css-transitions/support/helper.js"></script>
10+
<script src="/dom/events/scrolling/scroll_support.js"></script>
11+
<script src="/common/reftest-wait.js"></script>
12+
</head>
13+
14+
<body>
15+
<style>
16+
.wrapper {
17+
display: grid;
18+
justify-content: center;
19+
}
20+
21+
.carousel {
22+
width: 800px;
23+
height: 200px;
24+
overflow-x: scroll;
25+
scroll-snap-type: x mandatory;
26+
list-style-type: none;
27+
scroll-behavior: smooth;
28+
border: solid 2px grey;
29+
padding-top: 10%;
30+
text-align: center;
31+
counter-set: markeridx -1;
32+
columns: 2;
33+
34+
&::column::scroll-marker {
35+
content: counter(markeridx);
36+
counter-increment: markeridx;
37+
align-content: center;
38+
text-align: center;
39+
width: 35px;
40+
height: 35px;
41+
border-radius: 50%;
42+
margin: 3px;
43+
background-color: red;
44+
}
45+
&::column::scroll-marker:target-current {
46+
background-color: green;
47+
}
48+
49+
&>.item {
50+
scroll-snap-align: center;
51+
height: 80%;
52+
width: 158px;
53+
border: 1px solid;
54+
place-content: center;
55+
display: inline-block;
56+
}
57+
58+
scroll-marker-group: after;
59+
60+
&::scroll-marker-group {
61+
height: 45px;
62+
display: flex;
63+
align-items: center;
64+
justify-content: center;
65+
border: solid 1px black;
66+
border-radius: 30px;
67+
}
68+
}
69+
</style>
70+
<div class="wrapper" id="wrapper">
71+
<div class="carousel" id="carousel">
72+
<div class="item item0" tabindex=0>0</div>
73+
<div class="item item1" tabindex=0>1</div>
74+
<div class="item item2" tabindex=0>2</div>
75+
<div class="item item3" tabindex=0>3</div>
76+
<div class="item item4" tabindex=0>4</div>
77+
<div class="item item5" tabindex=0>5</div>
78+
<div class="item item6" tabindex=0>6</div>
79+
<div class="item item7" tabindex=0>7</div>
80+
<div class="item item8" tabindex=0>8</div>
81+
<div class="item item9" tabindex=0>9</div>
82+
<div class="item item10" tabindex=0>10</div>
83+
<div class="item item11" tabindex=0>11</div>
84+
<div class="item item12" tabindex=0>12</div>
85+
<div class="item item13" tabindex=0>13</div>
86+
<div class="item item14" tabindex=0>14</div>
87+
<div class="item item15" tabindex=0>15</div>
88+
</div>
89+
</div>
90+
<script>
91+
92+
const carousel = document.getElementById("carousel");
93+
const items = document.querySelectorAll(".item");
94+
function runTest() {
95+
const item4 = items[4];
96+
item4.scrollIntoView();
97+
carousel.onscrollend = () => { takeScreenshot(); };
98+
}
99+
waitForCompositorReady().then(runTest);
100+
</script>
101+
</body>
102+
103+
</html>

0 commit comments

Comments
 (0)