Skip to content

Commit 6c1e982

Browse files
Sam Davis Omekara Jrchromium-wpt-export-bot
authored andcommitted
[Gap Decorations]: Major paint logic for Optimized GapGeometry
This CL implements the core paint logic for the optimized approach to gap geometry. The main changes are in the "population" methods in `gap_geometry.h` and the addition of the new `GapPainter` class in `gap_painter.h`. Gap decorations are painted relative to intersections within a gap, as a result this change generates these intersection points at paint time rather than storing precomputed intersections from layout. The general principle for generating intersection points is: content-start → intersections between main × cross gaps → content-end However, the way we compute the middle intersections depends on the container type. For flex cross gaps, there are only two intersections (start and end), so the pattern doesn’t fully apply. This distinction requires calculating the end offset for flex cross gaps dynamically. The code is exercised through existing web tests in the virtual/css-gap-decorations-optimized/external/wpt/css/css-gaps/ folder as all changes are behind the CSSGapDecorationOptimized feature flag. Note: This CL does not yet handle rule-break behavior as a result tests that are exercising that logic are marked as failing in this CL. Currently, decorations are painted from the start to the end of a gap without interruption. Rule-break handling will be addressed in an upcoming change. Other changes made in this CL are: * For flex: - Previously, ContentStart and ContentEnd offsets were not set when a flex line contained only a single item. This has been corrected. - The offset for the main gap no longer needs to be adjusted based on flex direction. It now consistently represents the position where the flex line ends plus the gap. (Relevant test updated accordingly.) * For `MainGap` and `CrossGapRange`: - Introduced getters and setters for `CrossGapRange`, improving ease of use during paint time. * For grid tests: - Updated test references to use standard div elements instead of relying on column rules from multi-column layout. Bug: 436140061, 357648037 Change-Id: I0a0eadbad7f4911a98ae22060327ef1acc526ab3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6848348 Reviewed-by: Alison Maher <[email protected]> Commit-Queue: Sam Davis Omekara <[email protected]> Cr-Commit-Position: refs/heads/main@{#1511107}
1 parent bdaf2db commit 6c1e982

File tree

3 files changed

+79
-77
lines changed

3 files changed

+79
-77
lines changed

css/css-gaps/grid/grid-gap-decorations-003-ref.html

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,37 @@
77
}
88

99
.container {
10-
width: 110px;
1110
height: 110px;
12-
column-count: 2;
11+
width: 110px;
12+
13+
display: grid;
14+
grid-template-columns: repeat(2, 1fr);
15+
1316
column-gap: 10px;
14-
column-rule-color: pink;
15-
column-rule-style: dotted;
16-
column-rule-width: 10px;
17-
overflow: hidden;
18-
position: relative;
17+
row-gap: 10px;
1918
}
2019

20+
2121
.item {
2222
background: skyblue;
2323
height: 50px;
2424
width: 100%;
2525
margin: 0;
2626
}
2727

28-
/* For 2x2 grid-like layout, add a 10px bottom margin to
29-
odd children(#1 & #3) to simulate a horizontal row gap.*/
30-
.item:nth-child(odd) {
31-
margin-bottom: 10px;
28+
.col-rule {
29+
margin: 0px;
30+
padding: 0px;
31+
width: 0px;
32+
33+
34+
height: 110px;
35+
border-right: 10px dotted;
36+
border-color: pink;
37+
position: absolute;
38+
left: 50px;
39+
top: 0px;
40+
3241
}
3342

3443
.row-rule {
@@ -42,13 +51,12 @@
4251
position: absolute;
4352
top: 50px;
4453
}
45-
4654
</style>
4755
<div class="container">
4856
<div class="item"></div>
4957
<div class="item"></div>
5058
<div class="item"></div>
5159
<div class="item"></div>
5260
</div>
53-
<div class="row-rule">
54-
</div>
61+
<div class="col-rule"></div>
62+
<div class="row-rule"></div>

css/css-gaps/grid/grid-gap-decorations-004-ref.html

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,54 @@
66
margin: 0px;
77
}
88

9-
.container {
10-
width: 108px;
9+
.grid-container {
1110
height: 108px;
12-
background: green;
13-
14-
column-count: 2;
11+
width: 108px;
12+
display: grid;
13+
grid-template-columns: repeat(2, 1fr);
1514
column-gap: 12px;
15+
row-gap: 12px;
16+
background-color: green;
1617

17-
column-rule-color: pink;
18-
column-rule-style: double;
19-
column-rule-width: 12px;
20-
21-
overflow: hidden;
2218
}
2319

24-
.item {
20+
.grid-item {
2521
background: skyblue;
26-
height: 48px;
27-
width: 100%;
28-
margin: 0;
2922
}
3023

31-
/* For 2x2 grid-like layout, add a 10px bottom margin to
32-
odd children(#1 & #3) to simulate a horizontal row gap.*/
33-
.item:nth-child(odd) {
34-
margin-bottom: 12px;
24+
.col-rule {
25+
margin: 0px;
26+
padding: 0px;
27+
width: 0px;
28+
29+
30+
height: 108px;
31+
border-right: 12px double;
32+
border-color: pink;
33+
position: absolute;
34+
left: 48px;
35+
top: 0px;
36+
3537
}
3638

37-
.row-gap {
39+
.row-rule {
3840
margin: 0px;
3941
padding: 0px;
40-
height: 4px;
41-
background: pink;
42+
height: 0px;
43+
4244
width: 108px;
45+
border-bottom: 12px double;
46+
border-color: pink;
4347
position: absolute;
48+
top: 48px;
4449
}
45-
4650
</style>
47-
<div class="container">
48-
<div class="item"></div>
49-
<div class="item"></div>
50-
<div class="item"></div>
51-
<div class="item"></div>
51+
<div class="grid-container">
52+
<div class="grid-item"></div>
53+
<div class="grid-item"></div>
54+
<div class="grid-item"></div>
55+
<div class="grid-item"></div>
5256
</div>
5357

54-
<!-- Two horizontal bars to simulate row gaps with style double -->
55-
<div id="horizontal1" class="row-gap" style="top: 48px;"></div>
56-
<div id="horizontal2" class="row-gap" style="top: 56px;"></div>
58+
<div class="row-rule"> </div>
59+
<div class="col-rule"> </div>
Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,53 @@
1+
12
<!DOCTYPE html>
23
<link rel="help" href="https://drafts.csswg.org/css-gaps-1/">
34
<link rel="author" title="Sam Davis Omekara Jr." href="mailto:[email protected]">
45
<style>
56
body {
67
margin: 0px;
78
}
8-
99
.container {
10-
width: 110px;
1110
height: 110px;
12-
background: green;
13-
14-
column-count: 2;
11+
width: 110px;
12+
display: grid;
13+
grid-template-columns: repeat(2, 1fr);
1514
column-gap: 10px;
16-
17-
column-rule-color: pink;
18-
column-rule-style: double;
19-
column-rule-width: 5px;
20-
21-
overflow: hidden;
15+
row-gap: 10px;
16+
background: green;
2217
}
23-
2418
.item {
2519
background: skyblue;
2620
height: 50px;
2721
width: 100%;
2822
margin: 0;
2923
}
30-
31-
.double {
24+
.col-rule {
25+
margin: 0px;
26+
padding: 0px;
27+
width: 0px;
28+
height: 110px;
29+
border-right: 5px double;
30+
border-color: pink;
31+
position: absolute;
32+
left: 52.5px;
33+
top: 0px;
34+
}
35+
.row-rule {
3236
margin: 0px;
3337
padding: 0px;
3438
height: 0px;
35-
3639
width: 110px;
3740
border-bottom: 5px double;
3841
border-color: pink;
3942
position: absolute;
40-
/*
41-
The top position of the double border is set to 52.5px
42-
to account for 10px gap and 5px height of the double border,
43-
in order to center it in the gap.
44-
*/
4543
top: 52.5px;
4644
}
47-
48-
/* For 2x2 grid-like layout, add a 10px bottom margin to
49-
odd children(#1 & #3) to simulate a horizontal row gap.*/
50-
.item:nth-child(odd) {
51-
margin-bottom: 10px;
52-
}
5345
</style>
5446
<div class="container">
55-
<div class="item"></div>
56-
<div class="item"></div>
57-
<div class="item"></div>
58-
<div class="item"></div>
47+
<div class="item"></div>
48+
<div class="item"></div>
49+
<div class="item"></div>
50+
<div class="item"></div>
5951
</div>
60-
61-
<div class="double">
62-
</div>
52+
<div class="col-rule"></div>
53+
<div class="row-rule"></div>

0 commit comments

Comments
 (0)