diff options
author | bptato <nincsnevem662@gmail.com> | 2025-03-11 18:03:02 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2025-03-11 18:07:22 +0100 |
commit | 57b8dc6ae606a0f1499349b591269d6430bb234d (patch) | |
tree | bebed0471208f91b155a4eebdfa170ff214c306e /src/css/layout.nim | |
parent | dbad124ac0a3245ccfdc17363b702a8e94440944 (diff) | |
download | chawan-57b8dc6ae606a0f1499349b591269d6430bb234d.tar.gz |
layout: shim grid as flow-root
Pros: basic display on pages that depend on grid being implemented to display anything at all. Cons: breaks pages that have a fallback layout for UAs that can't do grid. (In practice, such pages must be rare - CSS for layout is painful enough that nobody in their right mind will spend time on implementing a fallback layout for the same DOM.)
Diffstat (limited to 'src/css/layout.nim')
-rw-r--r-- | src/css/layout.nim | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/css/layout.nim b/src/css/layout.nim index ff31f2e7..b28aecc8 100644 --- a/src/css/layout.nim +++ b/src/css/layout.nim @@ -105,10 +105,13 @@ func isDefinite(sc: SizeConstraint): bool = # Note: this does not include display types that cannot appear as block # children. func establishesBFC(computed: CSSValues): bool = + const DisplayWithBFC = { + DisplayFlowRoot, DisplayTable, DisplayFlex, DisplayGrid + } return computed{"float"} != FloatNone or - computed{"display"} in {DisplayFlowRoot, DisplayTable, DisplayFlex} or + computed{"display"} in DisplayWithBFC or computed{"overflow-x"} notin {OverflowVisible, OverflowClip} - #TODO contain, grid, multicol, column-span + #TODO contain, multicol, column-span func canpx(l: CSSLength; sc: SizeConstraint): bool = return l.u != clAuto and (l.u != clPerc or sc.t == scStretch) @@ -370,6 +373,7 @@ type # Forward declarations proc layoutTable(bctx: BlockContext; box: BlockBox; sizes: ResolvedSizes) proc layoutFlex(bctx: var BlockContext; box: BlockBox; sizes: ResolvedSizes) +proc layoutGrid(bctx: var BlockContext; box: BlockBox; sizes: ResolvedSizes) proc layoutRootBlock(lctx: LayoutContext; box: BlockBox; offset: Offset; sizes: ResolvedSizes) proc layout(bctx: var BlockContext; box: BlockBox; sizes: ResolvedSizes; @@ -2624,6 +2628,8 @@ proc layout(bctx: var BlockContext; box: BlockBox; sizes: ResolvedSizes; bctx.layoutTable(box, sizes) of DisplayInnerFlex: bctx.layoutFlex(box, sizes) + of DisplayInnerGrid: + bctx.layoutGrid(box, sizes) else: assert false @@ -2871,6 +2877,10 @@ proc layoutFlex(bctx: var BlockContext; box: BlockBox; sizes: ResolvedSizes) = if box.computed{"position"} != PositionStatic: lctx.popPositioned(box, box.state.size) +proc layoutGrid(bctx: var BlockContext; box: BlockBox; sizes: ResolvedSizes) = + #TODO implement grid + bctx.layoutFlow(box, sizes, canClear = false) + # Inner layout for boxes that establish a new block formatting context. proc layoutRootBlock(lctx: LayoutContext; box: BlockBox; offset: Offset; sizes: ResolvedSizes) = |