diff options
| author | bptato <nincsnevem662@gmail.com> | 2024-12-15 19:09:46 +0100 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2024-12-15 19:09:46 +0100 |
| commit | 167f8f764974bfabbbf68a013218c90c9cdfac0b (patch) | |
| tree | 284c56eb1f77b77a93ad6b99332bd3151bbc57f7 | |
| parent | 14bdce675c0169e3643f5cf4f708c3721a9d29e2 (diff) | |
| download | chawan-167f8f764974bfabbbf68a013218c90c9cdfac0b.tar.gz | |
layout: do not trust specified table cell height
If the contents are larger than the specified cell height, then it is
simply ignored.
| -rw-r--r-- | src/css/layout.nim | 7 | ||||
| -rw-r--r-- | test/layout/table-intrinsic-height-overrides-specified-height.expected | 2 | ||||
| -rw-r--r-- | test/layout/table-intrinsic-height-overrides-specified-height.html | 8 |
3 files changed, 14 insertions, 3 deletions
diff --git a/src/css/layout.nim b/src/css/layout.nim index f32cba2c..3372d9da 100644 --- a/src/css/layout.nim +++ b/src/css/layout.nim @@ -1796,13 +1796,11 @@ proc layoutTableCell(lctx: LayoutContext; box: BlockBox; space: AvailableSpace) = var sizes = ResolvedSizes( padding: lctx.resolvePadding(space.w, box.computed), - space: space, + space: availableSpace(w = space.w, h = maxContent()), bounds: DefaultBounds ) if sizes.space.w.isDefinite(): sizes.space.w.u -= sizes.padding[dtHorizontal].sum() - if sizes.space.h.isDefinite(): - sizes.space.h.u -= sizes.padding[dtVertical].sum() box.state = BoxLayoutState() var bctx = BlockContext(lctx: lctx) bctx.layoutFlow(box, sizes) @@ -1812,6 +1810,9 @@ 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) + if space.h.t == scStretch: + box.state.size.h = max(box.state.size.h, space.h.u - + sizes.padding[dtVertical].sum()) # A table cell's minimum width overrides its width. box.state.size.w = max(box.state.size.w, box.state.xminwidth) diff --git a/test/layout/table-intrinsic-height-overrides-specified-height.expected b/test/layout/table-intrinsic-height-overrides-specified-height.expected new file mode 100644 index 00000000..b6a17be1 --- /dev/null +++ b/test/layout/table-intrinsic-height-overrides-specified-height.expected @@ -0,0 +1,2 @@ + test + test diff --git a/test/layout/table-intrinsic-height-overrides-specified-height.html b/test/layout/table-intrinsic-height-overrides-specified-height.html new file mode 100644 index 00000000..24992c6a --- /dev/null +++ b/test/layout/table-intrinsic-height-overrides-specified-height.html @@ -0,0 +1,8 @@ +<table> +<tr> +<td height=1> +test +</tr> +<tr> +<td> +test |