From b4cbdb8e1eb8af2a55d6a5b22316d59c87612578 Mon Sep 17 00:00:00 2001 From: bptato Date: Thu, 30 May 2024 17:33:45 +0200 Subject: layout: fix clear on blocks establishing new BFCs As per standard: > Adjoining vertical margins collapse, except: > [...] > If the top and bottom margins of an element with clearance are > adjoining, its margins collapse with the adjoining margins of > following siblings but that resulting margin does not collapse with > the bottom margin of the parent block. --- src/layout/engine.nim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/layout/engine.nim b/src/layout/engine.nim index 5cc32dd1..e91fd0d8 100644 --- a/src/layout/engine.nim +++ b/src/layout/engine.nim @@ -1230,7 +1230,8 @@ func canFlushMargins(box: BlockBox; sizes: ResolvedSizes): bool = if box.computed{"position"} == PositionAbsolute: return false return sizes.padding.top != 0 or sizes.padding.bottom != 0 or - box.inline != nil or box.computed{"display"} notin DisplayBlockLike + box.inline != nil or box.computed{"display"} notin DisplayBlockLike or + box.computed{"clear"} != ClearNone proc flushMargins(bctx: var BlockContext; box: BlockBox) = # Apply uncommitted margins. @@ -2321,6 +2322,8 @@ proc layoutBlockChildBFC(state: var BlockState; bctx: var BlockContext; bctx.flushMargins(child) bctx.positionFloats() bctx.marginTodo.append(child.state.margin.bottom) + if child.computed{"clear"} != ClearNone: + state.offset.clearFloats(bctx, child.computed{"clear"}) if bctx.exclusions.len > 0: # Consulting the standard for an important edge case... (abridged) # -- cgit 1.4.1-2-gfad0