Skip to content

Commit 172557b

Browse files
REGRESSION(311393@main): Table cells after a width: 0 column are placed off-screen (#63232)
<table style="width: 300px"> <tr> <td style="width: 20px">text</td> ... <td style="width: 0; padding: 0"></td> <td style="width: 1%">text</td> </tr> </table> The last cell should be at the table's right edge. Instead it was placed at x = -33554152 (caused by NaN). 311393@main stopped ignoring width: 0 on cells, making an empty 'width: 0' column (with no padding) a fixed column with a max width of 0. When AutoTableLayout::layout() distributes leftover width over fixed columns, 1. first (and subsequent) columns use up totalFixed, 2. the zero width column computes 0/0 = NaN and 3. the last column gets pushed off-screen. This is also a pre-existing bug: a positive width that rounds down to 0 in LayoutUnit (e.g. width: 0.001px) is not ignored either (see first test case). Stop distributing when we run out of totalFixed space. The remaining fixed columns have a max width of 0, so they would get 0 anyway, and any width still left goes to the later passes (e.g. percent columns). WebKit-Bug: https://bugs.webkit.org/show_bug.cgi?id=325808 WebKit-Canonical-Link: https://commits.webkit.org/322376@main Co-authored-by: Alan Baradlay <[email protected]>
1 parent dc7f6a3 commit 172557b

4 files changed

Lines changed: 120 additions & 0 deletions
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>CSS Reference: a filled green rectangle</title>
4+
<style>
5+
div {
6+
width: 300px;
7+
height: 22px;
8+
background-color: green;
9+
}
10+
</style>
11+
<p>Test passes if there is a filled green rectangle.</p>
12+
<div></div>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>CSS Tables: cells after a width: 0.001px column stay in the row when fixed-width columns take the excess width</title>
4+
<link rel="help" href="https://drafts.csswg.org/css-tables-3/#distributing-width-to-columns">
5+
<link rel="match" href="table-cell-tiny-width-excess-width-distribution-ref.html">
6+
<meta name="assert" content="Distributing excess width to constrained columns grows them in proportion to their max-content width, so a width: 0.001px column takes a negligible share and the cells after it still fill the row.">
7+
<style>
8+
table {
9+
width: 300px;
10+
border-spacing: 0;
11+
}
12+
td {
13+
background-color: green;
14+
}
15+
.fixed-width {
16+
width: 20px;
17+
}
18+
.tiny-width {
19+
width: 0.001px;
20+
padding: 0;
21+
}
22+
.percent-width {
23+
width: 1%;
24+
}
25+
.content {
26+
width: 100px;
27+
height: 20px;
28+
}
29+
</style>
30+
<p>Test passes if there is a filled green rectangle.</p>
31+
<table>
32+
<tr>
33+
<td class="fixed-width"></td>
34+
<td class="tiny-width"></td>
35+
<td class="percent-width"><div class="content"></div></td>
36+
</tr>
37+
</table>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>CSS Reference: a filled green rectangle</title>
4+
<style>
5+
div {
6+
width: 656px;
7+
height: 22px;
8+
background-color: green;
9+
}
10+
</style>
11+
<p>Test passes if there is a filled green rectangle.</p>
12+
<div></div>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>CSS Tables: cells after width: 0 columns stay in the row when fixed-width columns take the excess width</title>
4+
<link rel="help" href="https://drafts.csswg.org/css-tables-3/#distributing-width-to-columns">
5+
<link rel="match" href="table-cell-width-0-excess-width-distribution-ref.html">
6+
<meta name="assert" content="Distributing excess width to constrained columns grows only the ones with a nonzero max-content width, so the empty width: 0 columns do not grow and the header cells after them still fill the row.">
7+
<link rel="stylesheet" href="/fonts/ahem.css">
8+
<style>
9+
.container {
10+
width: 656px;
11+
}
12+
table {
13+
border-spacing: 0;
14+
font: 20px/1 Ahem;
15+
color: transparent;
16+
}
17+
th {
18+
font-weight: normal;
19+
background-color: green;
20+
}
21+
.zero-width {
22+
width: 0;
23+
padding: 0;
24+
}
25+
.narrow-fixed-width {
26+
width: 85.79px;
27+
}
28+
.wide-fixed-width {
29+
width: 255px;
30+
}
31+
.percent-width {
32+
width: 1%;
33+
}
34+
.content {
35+
margin-right: 20px;
36+
margin-left: 10px;
37+
width: 225px;
38+
}
39+
</style>
40+
<p>Test passes if there is a filled green rectangle.</p>
41+
<div class="container">
42+
<table>
43+
<tr>
44+
<th colspan="2"></th>
45+
<th class="zero-width"></th>
46+
<th class="zero-width"></th>
47+
<th></th>
48+
<th class="zero-width"></th>
49+
<th class="zero-width"></th>
50+
<th class="percent-width">XXXX</th>
51+
<th>XXXX XXXX</th>
52+
</tr>
53+
<tr>
54+
<td></td>
55+
<td class="narrow-fixed-width"></td>
56+
<td class="wide-fixed-width"><div class="content"></div></td>
57+
</tr>
58+
</table>
59+
</div>

0 commit comments

Comments
 (0)