From c20166207867f536201ae7148608b9db202a2739 Mon Sep 17 00:00:00 2001 From: bptato Date: Wed, 16 Oct 2024 22:13:53 +0200 Subject: layout: fix inline float + position: absolute bug As per standard, float "only applies to elements that [...] are not absolutely positioned." --- src/layout/engine.nim | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/layout/engine.nim b/src/layout/engine.nim index adf5b3ce..c6dc5387 100644 --- a/src/layout/engine.nim +++ b/src/layout/engine.nim @@ -1514,14 +1514,15 @@ proc addInlineBlock(ictx: var InlineContext; state: var InlineState; proc addBox(ictx: var InlineContext; state: var InlineState; box: BlockBox) = - if box.computed{"float"} != FloatNone: - # This will trigger a re-layout for this inline root. - if not ictx.secondPass: - ictx.addInlineFloat(state, box) - elif box.computed{"position"} == PositionAbsolute: + if box.computed{"position"} == PositionAbsolute: # This doesn't really have to be an inline block. I just want to # handle its positioning here. ictx.addInlineAbsolute(state, box) + elif box.computed{"float"} != FloatNone: + # (Must check after `position: absolute', as that has higher precedence.) + # This will trigger a re-layout for this inline root. + if not ictx.secondPass: + ictx.addInlineFloat(state, box) else: # This is an inline block. assert box.computed{"display"} in DisplayOuterInline -- cgit