Skip to content

Commit 273c638

Browse files
Ahmad-S792Ahmad Saleem
authored andcommitted
Table layout: Fix min-width distribution for spanning cells across mixed percent/auto columns
https://[email protected]/show_bug.cgi?id=305042 rdar://167684748 Reviewed by Alan Baradlay. This patch undo some renering progressions from 305120@main where we shipped correct rendering but it broke distribution and caused tables to be wide in linked test case (in bugzilla - also converted to regression test case). i.e., table was ~770 pixel instead of 602 but with correct rendering. This patch will give us same rendering albeit incorrect as of shipping Safari, although it does not negate our 305120@main fully and we still progress a lot of test cases - which is right step to do. When a spanning cell covers columns with a mix of percentages, fixed widths, and auto widths, the distribution logic needs to account for fixed-width columns separately. The new code path for distributing min/max widths based on effective percentages should only apply when there are no fixed-width columns in the span. The fix adds a check for fixedWidth <= 0 to ensure the new distribution logic only runs when the span contains only percent and auto columns, allowing the existing else block to handle the mixed fixed+percent+auto case correctly. * Source/WebCore/rendering/AutoTableLayout.cpp: (WebCore::AutoTableLayout::calcEffectiveLogicalWidth): * LayoutTests/fast/table/table-colspan-mixed-percent-fixed-auto-expected.txt: Added. * LayoutTests/fast/table/table-colspan-mixed-percent-fixed-auto.html: Added. ^ So we don't regress it in future. It checks width (not rendering). Canonical link: https://commits.webkit.org/305215@main
1 parent a1f9951 commit 273c638

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
P
2+
A
3+
F
4+
F
5+
A
6+
P
7+
Lorem
8+
9+
PASS Table with mixed percent, fixed, and auto columns should respect width attribute
10+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Table layout with mixed percent, fixed, and auto columns with colspan</title>
5+
<script src="../../resources/testharness.js"></script>
6+
<script src="../../resources/testharnessreport.js"></script>
7+
<style>
8+
table {
9+
border: 1px solid black;
10+
border-collapse: collapse;
11+
}
12+
td {
13+
border: 1px solid black;
14+
padding: 0;
15+
}
16+
</style>
17+
</head>
18+
<body>
19+
<table id="testTable" border width="600" cellspacing="0" cellpadding="0">
20+
<tr>
21+
<td width="50%">
22+
<div style="width: 50px; background-color: violet;">P</div>
23+
</td>
24+
<td>
25+
<div style="width: 50px; background-color: orange;">A</div>
26+
</td>
27+
<td width="50px">
28+
<div style="background-color: green;">F</div>
29+
</td>
30+
<td width="50px">
31+
<div style="background-color: green;">F</div>
32+
</td>
33+
<td>
34+
<div style="width: 100px; background-color: orange;">A</div>
35+
</td>
36+
<td width="50%">
37+
<div style="width: 50px; background-color: violet;">P</div>
38+
</td>
39+
</tr>
40+
<tr>
41+
<td width="100%" colspan="6">
42+
<div style="width: 600px; background-color: lightblue;">Lorem</div>
43+
</td>
44+
</tr>
45+
</table>
46+
47+
<script>
48+
test(function() {
49+
var table = document.getElementById('testTable');
50+
var tableWidth = table.offsetWidth;
51+
assert_equals(tableWidth, 602, 'Table width should be 602px');
52+
}, 'Table with mixed percent, fixed, and auto columns should respect width attribute');
53+
</script>
54+
</body>
55+
</html>

Source/WebCore/rendering/AutoTableLayout.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ float AutoTableLayout::calcEffectiveLogicalWidth()
457457
ASSERT(allocatedMinLogicalWidth < cellMinLogicalWidth || WTF::areEssentiallyEqual(allocatedMinLogicalWidth, cellMinLogicalWidth));
458458
ASSERT(allocatedMaxLogicalWidth < cellMaxLogicalWidth || WTF::areEssentiallyEqual(allocatedMaxLogicalWidth, cellMaxLogicalWidth));
459459
cellMaxLogicalWidth -= allocatedMaxLogicalWidth;
460-
} else if (!allColsAreFixed && totalPercent > 0 && haveAuto) {
460+
} else if (!allColsAreFixed && fixedWidth <= 0 && totalPercent > 0 && haveAuto) {
461461
// By this point, the earlier code has converted auto columns to effectiveLogicalWidth percentages,
462462
// so we can use the same percentage-based distribution as the allColsArePercent case.
463463
#if ASSERT_ENABLED

0 commit comments

Comments
 (0)