diff options
| author | bptato <nincsnevem662@gmail.com> | 2025-02-09 16:51:10 +0100 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2025-02-09 17:04:40 +0100 |
| commit | 918c28d030ccf6e1671cd87d940e4f93f222c656 (patch) | |
| tree | 1646c7cf90b0f6e980db25ed815f1fd5f6f81b92 | |
| parent | 9ba5bca754357a033c165abfc7df421e2e947015 (diff) | |
| download | chawan-918c28d030ccf6e1671cd87d940e4f93f222c656.tar.gz | |
layout: respect intrinsic minimum width of table cells
| -rw-r--r-- | src/css/layout.nim | 5 | ||||
| -rw-r--r-- | test/layout/nested-table-intrinsic-min-width-respected.expected | 1 | ||||
| -rw-r--r-- | test/layout/nested-table-intrinsic-min-width-respected.html | 11 |
3 files changed, 16 insertions, 1 deletions
diff --git a/src/css/layout.nim b/src/css/layout.nim index 85d752fb..eddffced 100644 --- a/src/css/layout.nim +++ b/src/css/layout.nim @@ -2347,12 +2347,14 @@ proc layoutTableRow(tctx: TableContext; ctx: RowContext; let space = availableSpace(w = stretch(w), h = maxContent()) tctx.lctx.layoutTableCell(cellw.box, space) w = max(w, cellw.box.state.size.w) + row.state.intr.w += cellw.box.state.intr.w let cell = cellw.box x += tctx.inlineSpacing if cell != nil: cell.state.offset.x += x x += tctx.inlineSpacing x += w + row.state.intr.w += tctx.inlineSpacing * 2 n += cellw.colspan const HasNoBaseline = { VerticalAlignTop, VerticalAlignMiddle, VerticalAlignBottom @@ -2466,7 +2468,7 @@ func needsRedistribution(tctx: TableContext; computed: CSSValues): proc redistributeWidth(tctx: var TableContext) = # Remove inline spacing from distributable width. - var W = tctx.space.w.u - tctx.cols.len * tctx.inlineSpacing * 2 + var W = max(tctx.space.w.u - tctx.cols.len * tctx.inlineSpacing * 2, 0) var weight = 0f32 var avail = tctx.calcUnspecifiedColIndices(W, weight) var redo = true @@ -2520,6 +2522,7 @@ proc layoutTableRows(tctx: TableContext; table: BlockBox; y += tctx.blockSpacing y += row.state.size.h table.state.size.w = max(row.state.size.w, table.state.size.w) + table.state.intr.w = max(row.state.intr.w, table.state.intr.w) # Note: we can't use applySizeConstraint here; in CSS, "height" on tables just # sets the minimum height. case tctx.space.h.t diff --git a/test/layout/nested-table-intrinsic-min-width-respected.expected b/test/layout/nested-table-intrinsic-min-width-respected.expected new file mode 100644 index 00000000..604ea1b3 --- /dev/null +++ b/test/layout/nested-table-intrinsic-min-width-respected.expected @@ -0,0 +1 @@ + asdfasdfasdfasdf test test test diff --git a/test/layout/nested-table-intrinsic-min-width-respected.html b/test/layout/nested-table-intrinsic-min-width-respected.html new file mode 100644 index 00000000..87f8a2b5 --- /dev/null +++ b/test/layout/nested-table-intrinsic-min-width-respected.html @@ -0,0 +1,11 @@ +<table> +<tr> +<td> +<table width="100%"> +<tr> +<td width="100%"> +asdfasdfasdfasdf +</table> +<td width="100%"> +test test test +</td> |