diff options
| -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> |