aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-12-10 16:39:46 +0100
committerbptato <nincsnevem662@gmail.com>2024-12-10 16:39:46 +0100
commit8159cf5e126c1dcac56625aa02a4f463c1262b42 (patch)
tree340e69136ca90f9994761819d4d1671e09b699a2
parent5f3158ea5ec059d8bfeffb7e4423126cf4e37ead (diff)
downloadchawan-8159cf5e126c1dcac56625aa02a4f463c1262b42.tar.gz
layout: override table cell width if its min width is greater
We can do this now that xminwidth is more accurate.
-rw-r--r--src/css/layout.nim2
-rw-r--r--test/layout/table-cell-intrinsic-min-width-overrides-specified-width.expected4
-rw-r--r--test/layout/table-cell-intrinsic-min-width-overrides-specified-width.html11
3 files changed, 17 insertions, 0 deletions
diff --git a/src/css/layout.nim b/src/css/layout.nim
index 8e2906d3..a3869662 100644
--- a/src/css/layout.nim
+++ b/src/css/layout.nim
@@ -1812,6 +1812,8 @@ proc layoutTableCell(lctx: LayoutContext; box: BlockBox;
# If the highest float edge is higher than the box itself, set that as
# the box height.
box.state.size.h = max(box.state.size.h, bctx.maxFloatHeight)
+ # A table cell's minimum width overrides its width.
+ box.state.size.w = max(box.state.size.w, box.state.xminwidth)
# Sort growing cells, and filter out cells that have grown to their intended
# rowspan.
diff --git a/test/layout/table-cell-intrinsic-min-width-overrides-specified-width.expected b/test/layout/table-cell-intrinsic-min-width-overrides-specified-width.expected
new file mode 100644
index 00000000..f4ee0fc3
--- /dev/null
+++ b/test/layout/table-cell-intrinsic-min-width-overrides-specified-width.expected
@@ -0,0 +1,4 @@
+
+ test test test test
+ 2
+ test
diff --git a/test/layout/table-cell-intrinsic-min-width-overrides-specified-width.html b/test/layout/table-cell-intrinsic-min-width-overrides-specified-width.html
new file mode 100644
index 00000000..0d798c31
--- /dev/null
+++ b/test/layout/table-cell-intrinsic-min-width-overrides-specified-width.html
@@ -0,0 +1,11 @@
+<table style="width: 5ch">
+<td width=1%>
+<pre>
+test test test
+</pre>
+<div>
+test
+</div>
+</td>
+<td>
+test 2