aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-11-17 19:41:40 +0100
committerbptato <nincsnevem662@gmail.com>2024-11-17 19:41:40 +0100
commit3f1d74582e1511080096dee6e48311e41ad68a65 (patch)
tree4a29a3ff38e0915bf7fdd850df2849cd440802ef
parent07aa685c8012b1700097f3b25369efd329cfe756 (diff)
downloadchawan-3f1d74582e1511080096dee6e48311e41ad68a65.tar.gz
layout: fix crash on overlapping rowspan/colspan
The rowspan filler must get a smaller colspan if its first cells are occupied by another cell with a colspan > 1.
-rw-r--r--src/css/layout.nim5
-rw-r--r--test/layout/table-overlapping-rowspan-and-colspan.expected3
-rw-r--r--test/layout/table-overlapping-rowspan-and-colspan.html20
3 files changed, 26 insertions, 2 deletions
diff --git a/src/css/layout.nim b/src/css/layout.nim
index 7033b636..411fb38a 100644
--- a/src/css/layout.nim
+++ b/src/css/layout.nim
@@ -1788,8 +1788,9 @@ proc growRowspan(pctx: var TableContext; ctx: var RowContext;
if cellw.coli > n:
break
dec cellw.grown
+ let colspan = cellw.colspan - (n - cellw.coli)
let rowspanFiller = CellWrapper(
- colspan: cellw.colspan,
+ colspan: colspan,
rowspan: cellw.rowspan,
coli: n,
real: cellw,
@@ -1797,7 +1798,7 @@ proc growRowspan(pctx: var TableContext; ctx: var RowContext;
)
ctx.cells.add(nil)
ctx.cells[i] = rowspanFiller
- for i in n ..< n + cellw.colspan:
+ for i in n ..< n + colspan:
ctx.width += pctx.cols[i].width
ctx.width += pctx.inlineSpacing * 2
n += cellw.colspan
diff --git a/test/layout/table-overlapping-rowspan-and-colspan.expected b/test/layout/table-overlapping-rowspan-and-colspan.expected
new file mode 100644
index 00000000..442b1372
--- /dev/null
+++ b/test/layout/table-overlapping-rowspan-and-colspan.expected
@@ -0,0 +1,3 @@
+ test test
+ col2 test col4
+
diff --git a/test/layout/table-overlapping-rowspan-and-colspan.html b/test/layout/table-overlapping-rowspan-and-colspan.html
new file mode 100644
index 00000000..9f4d7353
--- /dev/null
+++ b/test/layout/table-overlapping-rowspan-and-colspan.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<table>
+<tr>
+<td>
+test
+</td>
+<td rowspan=2 bgcolor=blue>
+test<br>
+test
+</td>
+</tr>
+<tr>
+<td colspan=2>
+col2
+</td>
+<td>
+col4
+</td>
+</tr>
+</table>