diff options
author | bptato <nincsnevem662@gmail.com> | 2025-03-03 22:07:20 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2025-03-03 22:42:17 +0100 |
commit | bd5ef49b64991607bde95e0c0a487b636d59ae42 (patch) | |
tree | f5a5c71fd0323db131eaffb2b63e349bd3383f97 /src/css/layout.nim | |
parent | a0b345318e08d73eaedfc9b1caeec5b78fc270e3 (diff) | |
download | chawan-bd5ef49b64991607bde95e0c0a487b636d59ae42.tar.gz |
layout: adjust table cell height to fill rows
Achieved by generating an anonymous flow root child for the contents and positioning that. (Not the cell contents directly - that wouldn't work because of inline child boxes.)
Diffstat (limited to 'src/css/layout.nim')
-rw-r--r-- | src/css/layout.nim | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/css/layout.nim b/src/css/layout.nim index 7d94c138..f943d55e 100644 --- a/src/css/layout.nim +++ b/src/css/layout.nim @@ -2322,15 +2322,14 @@ proc preLayoutTableRow(pctx: var TableContext; row, parent: BlockBox; return ctx proc alignTableCell(cell: BlockBox; availableHeight, baseline: LUnit) = - case cell.computed{"vertical-align"}.keyword - of VerticalAlignTop: - cell.state.offset.y = 0 - of VerticalAlignMiddle: - cell.state.offset.y = availableHeight div 2 - cell.state.size.h div 2 - of VerticalAlignBottom: - cell.state.offset.y = availableHeight - cell.state.size.h - else: - cell.state.offset.y = baseline - cell.state.firstBaseline + let firstChild = BlockBox(cell.firstChild) + if firstChild != nil: + firstChild.state.offset.y = case cell.computed{"vertical-align"}.keyword + of VerticalAlignTop: 0.toLUnit() + of VerticalAlignMiddle: availableHeight div 2 - cell.state.size.h div 2 + of VerticalAlignBottom: availableHeight - cell.state.size.h + else: baseline - cell.state.firstBaseline + cell.state.size.h = availableHeight proc layoutTableRow(tctx: TableContext; ctx: RowContext; parent, row: BlockBox) = |