diff options
| author | bptato <nincsnevem662@gmail.com> | 2024-10-28 19:35:36 +0100 |
|---|---|---|
| committer | bptato <nincsnevem662@gmail.com> | 2024-10-28 19:35:36 +0100 |
| commit | 95e392b650643ba0638e49999f4cd6b7d9d3a23d (patch) | |
| tree | 0958b7661e7bf7b7db30aa1b5f667491fee4544d /src | |
| parent | 78658133f2baf8e4af241592fa7da21948cd62b1 (diff) | |
| download | chawan-95e392b650643ba0638e49999f4cd6b7d9d3a23d.tar.gz | |
layout: fix margin resolution for absolutely positioned boxes
Diffstat (limited to 'src')
| -rw-r--r-- | src/layout/engine.nim | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim index 6ced24bb..b3500e9a 100644 --- a/src/layout/engine.nim +++ b/src/layout/engine.nim @@ -2569,12 +2569,16 @@ proc layoutBlockChildren(state: var BlockState; bctx: var BlockContext; # Delay this block's layout until its parent's dimensions are # actually known. var offset = state.offset - # I *think* this is right, because we want to freeze the box at - # the layout's current position. So even if a next child increased - # the margin todo, that should not change the absolute block's - # position. - #TODO but I'm not sure if this is really what the standard says... - offset.y += bctx.marginTodo.sum() + # We want to get the child to a Y position where it would have + # been placed had it not been absolutely positioned. + # + # Like with floats, we must consider both the case where the + # parent's position is resolved, and the case where it isn't. + # Here our job is much easier in the unresolved case, because + # subsequent children's layout doesn't depend on our position; + # so we can just defer margin resolution to the parent. + if bctx.marginTarget != state.initialMarginTarget: + offset.y += bctx.marginTodo.sum() bctx.lctx.queueAbsolute(child, offset) continue if child.computed.establishesBFC(): |