LibWeb: Floating boxes follow normal containing block rules

I had guessed that floating boxes should somehow be hoisted up to the
nearest block ancestor that creates a block formatting context, but
that's just wrong. They move up to the nearest block ancestor like any
other box that's not absolutely (or fixed) positioned. :^)
This commit is contained in:
Andreas Kling 2020-12-05 23:11:31 +01:00
parent 2f38d94c70
commit 65e430eee5
Notes: sideshowbarker 2024-07-19 01:02:51 +09:00

View File

@ -66,13 +66,6 @@ const BlockBox* Node::containing_block() const
return downcast<BlockBox>(ancestor);
};
auto nearest_block_ancestor_that_creates_a_block_formatting_context = [this] {
auto* ancestor = parent();
while (ancestor && (!is<Box>(*ancestor) || !FormattingContext::creates_block_formatting_context(downcast<Box>(*ancestor))))
ancestor = ancestor->parent();
return downcast<BlockBox>(ancestor);
};
if (is_text())
return nearest_block_ancestor();
@ -90,9 +83,6 @@ const BlockBox* Node::containing_block() const
if (position == CSS::Position::Fixed)
return &root();
if (is_floating())
return nearest_block_ancestor_that_creates_a_block_formatting_context();
return nearest_block_ancestor();
}