about summary refs log tree commit diff stats
path: root/src/css/layout.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-02-09 16:51:10 +0100
committerbptato <nincsnevem662@gmail.com>2025-02-09 17:04:40 +0100
commit918c28d030ccf6e1671cd87d940e4f93f222c656 (patch)
tree1646c7cf90b0f6e980db25ed815f1fd5f6f81b92 /src/css/layout.nim
parent9ba5bca754357a033c165abfc7df421e2e947015 (diff)
downloadchawan-918c28d030ccf6e1671cd87d940e4f93f222c656.tar.gz
layout: respect intrinsic minimum width of table cells
Diffstat (limited to 'src/css/layout.nim')
-rw-r--r--src/css/layout.nim5
1 files changed, 4 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