Skip to content

Commit 3cad02c

Browse files
Ahmad-S792Ahmad Saleem
authored andcommitted
Col elements with span > 1 don't apply width to spanned columns
https://bugs.webkit.org/show_bug.cgi?id=304719 rdar://167225435 Reviewed by Alan Baradlay. This patch aligns WebKit with Gecko / Firefox and Blink / Chromium. When a <col> element has span > 1, its width (or inherited colgroup width) should apply to all columns it spans. Previously, only cols with span=1 had their widths applied, causing cols with larger spans to be ignored during table layout width calculation. * Source/WebCore/rendering/AutoTableLayout.cpp: (WebCore::AutoTableLayout::fullRecalc): > Progression: * LayoutTests/imported/w3c/web-platform-tests/css/css-tables/tentative/colgroup-col-expected.txt: Progression * LayoutTests/platform/mac/tables/mozilla_expected_failures/core/cols1-expected.txt: Now matches other browser engines * LayoutTests/platform/ios/tables/mozilla_expected_failures/core/cols1-expected.txt: Ditto * LayoutTests/platform/glib/tables/mozilla_expected_failures/core/cols1-expected.txt: Ditto > Rebaseline: * LayoutTests/imported/w3c/web-platform-tests/css/css-tables/column-track-merging-expected.txt: Seems more closer to expected now. Canonical link: https://commits.webkit.org/305113@main
1 parent 1a6089e commit 3cad02c

File tree

6 files changed

+29
-39
lines changed

6 files changed

+29
-39
lines changed

LayoutTests/imported/w3c/web-platform-tests/css/css-tables/column-track-merging-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,6 @@ FAIL main table 12 assert_equals:
145145
<td></td>
146146
</tr>
147147
</tbody></table>
148-
width expected 640 but got 180
148+
width expected 640 but got 580
149149
PASS main table 13
150150

LayoutTests/imported/w3c/web-platform-tests/css/css-tables/tentative/colgroup-col-expected.txt

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,7 @@ cg1 col1 col1 cg2 cg2 50px
2020
PASS table 1
2121
PASS table 2
2222
PASS table 3
23-
FAIL table 4 assert_equals:
24-
<table>
25-
<colgroup span="3" style="width:100px">
26-
<col>
27-
<col style="width:50px" span="2">
28-
</colgroup>
29-
<colgroup style="width:66px">
30-
<col span="2">
31-
</colgroup>
32-
<tbody><tr><td data-expected-width="100">cg1</td>
33-
<td data-expected-width="50">col1</td>
34-
<td data-expected-width="50">col1</td>
35-
<td data-expected-width="66">cg2</td>
36-
<td data-expected-width="66">cg2</td>
37-
<td data-expected-width="75"><div style="width:75px">50px</div></td>
38-
</tr></tbody></table>
39-
width expected 66 but got 23
23+
PASS table 4
4024
PASS table 5
4125
PASS table 6
4226

LayoutTests/platform/glib/tables/mozilla_expected_failures/core/cols1-expected.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ layer at (0,0) size 800x600
2020
RenderBR {BR} at (0,0) size 0x17
2121
RenderText {#text} at (0,18) size 197x17
2222
text run at (0,18) width 197: "Both columns should be 200px"
23-
RenderTable {TABLE} at (0,82) size 62x28 [bgcolor=#FFA500] [border: (1px outset #000000)]
23+
RenderTable {TABLE} at (0,82) size 408x28 [bgcolor=#FFA500] [border: (1px outset #000000)]
2424
RenderTableCol {COLGROUP} at (0,0) size 0x0
2525
RenderTableCol {COL} at (0,0) size 0x0
26-
RenderTableSection {TBODY} at (1,1) size 60x26
27-
RenderTableRow {TR} at (0,2) size 60x22
28-
RenderTableCell {TD} at (2,2) size 27x22 [border: (1px inset #000000)] [r=0 c=0 rs=1 cs=1]
26+
RenderTableSection {TBODY} at (1,1) size 406x26
27+
RenderTableRow {TR} at (0,2) size 406x22
28+
RenderTableCell {TD} at (2,2) size 200x22 [border: (1px inset #000000)] [r=0 c=0 rs=1 cs=1]
2929
RenderText {#text} at (2,2) size 23x17
3030
text run at (2,2) width 23: "c11"
31-
RenderTableCell {TD} at (30,2) size 28x22 [border: (1px inset #000000)] [r=0 c=1 rs=1 cs=1]
31+
RenderTableCell {TD} at (204,2) size 200x22 [border: (1px inset #000000)] [r=0 c=1 rs=1 cs=1]
3232
RenderText {#text} at (2,2) size 23x17
3333
text run at (2,2) width 23: "c12"
3434
RenderBlock (anonymous) at (0,110) size 784x36

LayoutTests/platform/ios/tables/mozilla_expected_failures/core/cols1-expected.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ layer at (0,0) size 800x600
2020
RenderBR {BR} at (0,0) size 0x19
2121
RenderText {#text} at (0,20) size 200x19
2222
text run at (0,20) width 200: "Both columns should be 200px"
23-
RenderTable {TABLE} at (0,90) size 62x30 [bgcolor=#FFA500] [border: (1px outset #000000)]
23+
RenderTable {TABLE} at (0,90) size 408x30 [bgcolor=#FFA500] [border: (1px outset #000000)]
2424
RenderTableCol {COLGROUP} at (0,0) size 0x0
2525
RenderTableCol {COL} at (0,0) size 0x0
26-
RenderTableSection {TBODY} at (1,1) size 60x28
27-
RenderTableRow {TR} at (0,2) size 60x24
28-
RenderTableCell {TD} at (2,2) size 27x24 [border: (1px inset #000000)] [r=0 c=0 rs=1 cs=1]
26+
RenderTableSection {TBODY} at (1,1) size 406x28
27+
RenderTableRow {TR} at (0,2) size 406x24
28+
RenderTableCell {TD} at (2,2) size 200x24 [border: (1px inset #000000)] [r=0 c=0 rs=1 cs=1]
2929
RenderText {#text} at (2,2) size 23x19
3030
text run at (2,2) width 23: "c11"
31-
RenderTableCell {TD} at (30,2) size 28x24 [border: (1px inset #000000)] [r=0 c=1 rs=1 cs=1]
31+
RenderTableCell {TD} at (204,2) size 200x24 [border: (1px inset #000000)] [r=0 c=1 rs=1 cs=1]
3232
RenderText {#text} at (2,2) size 24x19
3333
text run at (2,2) width 24: "c12"
3434
RenderBlock (anonymous) at (0,120) size 784x40

LayoutTests/platform/mac/tables/mozilla_expected_failures/core/cols1-expected.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ layer at (0,0) size 800x600
2020
RenderBR {BR} at (0,0) size 0x18
2121
RenderText {#text} at (0,18) size 200x18
2222
text run at (0,18) width 200: "Both columns should be 200px"
23-
RenderTable {TABLE} at (0,82) size 62x28 [bgcolor=#FFA500] [border: (1px outset #000000)]
23+
RenderTable {TABLE} at (0,82) size 408x28 [bgcolor=#FFA500] [border: (1px outset #000000)]
2424
RenderTableCol {COLGROUP} at (0,0) size 0x0
2525
RenderTableCol {COL} at (0,0) size 0x0
26-
RenderTableSection {TBODY} at (1,1) size 60x26
27-
RenderTableRow {TR} at (0,2) size 60x22
28-
RenderTableCell {TD} at (2,2) size 27x22 [border: (1px inset #000000)] [r=0 c=0 rs=1 cs=1]
26+
RenderTableSection {TBODY} at (1,1) size 406x26
27+
RenderTableRow {TR} at (0,2) size 406x22
28+
RenderTableCell {TD} at (2,2) size 200x22 [border: (1px inset #000000)] [r=0 c=0 rs=1 cs=1]
2929
RenderText {#text} at (2,2) size 23x18
3030
text run at (2,2) width 23: "c11"
31-
RenderTableCell {TD} at (30,2) size 28x22 [border: (1px inset #000000)] [r=0 c=1 rs=1 cs=1]
31+
RenderTableCell {TD} at (204,2) size 200x22 [border: (1px inset #000000)] [r=0 c=1 rs=1 cs=1]
3232
RenderText {#text} at (2,2) size 24x18
3333
text run at (2,2) width 24: "c12"
3434
RenderBlock (anonymous) at (0,110) size 784x36

Source/WebCore/rendering/AutoTableLayout.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,19 @@ void AutoTableLayout::fullRecalc()
169169
colLogicalWidth = groupLogicalWidth;
170170
if (colLogicalWidth.isSpecified() && colLogicalWidth.isKnownZero())
171171
colLogicalWidth = CSS::Keyword::Auto { };
172-
unsigned effCol = m_table->colToEffCol(currentColumn);
173172
unsigned span = column->span();
174-
if (!colLogicalWidth.isAuto() && span == 1 && effCol < nEffCols && m_table->spanOfEffCol(effCol) == 1) {
175-
m_layoutStruct[effCol].usedZoom = column->style().usedZoom();
176-
m_layoutStruct[effCol].logicalWidth = colLogicalWidth;
177-
if (auto fixedColLogicalWidth = colLogicalWidth.tryFixed(); fixedColLogicalWidth && m_layoutStruct[effCol].maxLogicalWidth < fixedColLogicalWidth->resolveZoom(column->style().usedZoomForLength()))
178-
m_layoutStruct[effCol].maxLogicalWidth = fixedColLogicalWidth->resolveZoom(column->style().usedZoomForLength());
173+
174+
// Apply width to all columns covered by this col element.
175+
if (!colLogicalWidth.isAuto()) {
176+
for (unsigned spanOffset = 0; spanOffset < span; ++spanOffset) {
177+
unsigned effCol = m_table->colToEffCol(currentColumn + spanOffset);
178+
if (effCol < nEffCols && m_table->spanOfEffCol(effCol) == 1) {
179+
m_layoutStruct[effCol].usedZoom = column->style().usedZoom();
180+
m_layoutStruct[effCol].logicalWidth = colLogicalWidth;
181+
if (auto fixedColLogicalWidth = colLogicalWidth.tryFixed(); fixedColLogicalWidth && m_layoutStruct[effCol].maxLogicalWidth < fixedColLogicalWidth->resolveZoom(column->style().usedZoomForLength()))
182+
m_layoutStruct[effCol].maxLogicalWidth = fixedColLogicalWidth->resolveZoom(column->style().usedZoomForLength());
183+
}
184+
}
179185
}
180186
currentColumn += span;
181187
}

0 commit comments

Comments
 (0)