1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 08:58:11 +00:00

LibWeb: Move absolute positioning up to FormattingContext

It seems like both BFC and IFC can have absolutely positioned children.
It's a bit strange, but consider the following HTML:

<html><body>foobar<img style="position: absolute"></body></html>

In such a document, the <img> element is an absolutely positioned child
of a block-level element (<body>) with no block-level children.
An IFC is established for <body>, and needs to handle layout for <img>.
This commit is contained in:
Andreas Kling 2021-01-06 18:18:46 +01:00
parent 4c98d00bef
commit 0ecefbff57
5 changed files with 281 additions and 215 deletions

View file

@ -95,8 +95,10 @@ void InlineFormattingContext::run(Box&, LayoutMode layout_mode)
containing_block().line_boxes().clear();
containing_block().for_each_child([&](auto& child) {
ASSERT(child.is_inline());
if (child.is_absolutely_positioned())
if (is<Box>(child) && child.is_absolutely_positioned()) {
layout_absolutely_positioned_element(downcast<Box>(child));
return;
}
child.split_into_lines(*this, layout_mode);
});