Parcourir la source

LibWeb: Fix upper limit of span when computing column measures

The maximum span limit has to be inclusive, not exclusive.
Andi Gallo il y a 2 ans
Parent
commit
50df78d2a2

+ 45 - 0
Tests/LibWeb/Layout/expected/table/colspan-width-distribution.txt

@@ -0,0 +1,45 @@
+Viewport <#document> at (0,0) content-size 800x600 children: not-inline
+  BlockContainer <html> at (0,0) content-size 800x60.9375 [BFC] children: not-inline
+    BlockContainer <(anonymous)> at (0,0) content-size 800x0 children: inline
+      TextNode <#text>
+    BlockContainer <body> at (8,8) content-size 784x44.9375 children: not-inline
+      BlockContainer <(anonymous)> at (8,8) content-size 784x0 children: inline
+        TextNode <#text>
+      TableWrapper <(anonymous)> at (8,8) content-size 32.904952x44.9375 [BFC] children: not-inline
+        Box <table> at (9,9) content-size 32.904952x42.9375 table-box [TFC] children: not-inline
+          BlockContainer <(anonymous)> (not painted) children: inline
+            TextNode <#text>
+          Box <tbody> at (9,9) content-size 34.904952x42.9375 table-row-group children: not-inline
+            Box <tr> at (9,9) content-size 34.904952x21.46875 table-row children: not-inline
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (11,11) content-size 17.561202x17.46875 table-cell [BFC] children: inline
+                line 0 width: 14.265625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 1, rect: [13,11 14.265625x17.46875]
+                    "A"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (32.561202,11) content-size 9.34375x17.46875 table-cell [BFC] children: inline
+                line 0 width: 9.34375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 1, rect: [32.561202,11 9.34375x17.46875]
+                    "B"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+            BlockContainer <(anonymous)> (not painted) children: inline
+              TextNode <#text>
+            Box <tr> at (9,30.46875) content-size 34.904952x21.46875 table-row children: not-inline
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+              BlockContainer <td> at (11,32.46875) content-size 30.904952x17.46875 table-cell [BFC] children: inline
+                line 0 width: 33.3125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
+                  frag 0 from TextNode start: 0, length: 3, rect: [11,32.46875 33.3125x17.46875]
+                    "CDE"
+                TextNode <#text>
+              BlockContainer <(anonymous)> (not painted) children: inline
+                TextNode <#text>
+            BlockContainer <(anonymous)> (not painted) children: inline
+              TextNode <#text>
+      BlockContainer <(anonymous)> at (8,52.9375) content-size 784x0 children: inline
+        TextNode <#text>

+ 27 - 0
Tests/LibWeb/Layout/input/table/colspan-width-distribution.html

@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <title>Computing column measures</title>
+    <style>
+        table, td {
+            border: 1px solid black;
+            border-spacing: 0px;
+            text-align: center;
+        }
+    </style>
+</head>
+
+<body>
+    <table>
+        <tr>
+            <td>A</td>
+            <td>B</td>
+        </tr>
+        <tr>
+            <td colspan="2">CDE</td>
+        </tr>
+    </table>
+</body>
+
+</html>

+ 1 - 1
Userland/Libraries/LibWeb/Layout/TableFormattingContext.cpp

@@ -201,7 +201,7 @@ void TableFormattingContext::compute_table_measures()
         }
     }
 
-    for (size_t current_column_span = 2; current_column_span < max_cell_column_span; current_column_span++) {
+    for (size_t current_column_span = 2; current_column_span <= max_cell_column_span; current_column_span++) {
         // https://www.w3.org/TR/css-tables-3/#min-content-width-of-a-column-based-on-cells-of-span-up-to-n-n--1
         Vector<Vector<CSSPixels>> cell_min_contributions_by_column_index;
         cell_min_contributions_by_column_index.resize(m_columns.size());