1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 11:28:11 +00:00

LibWeb: Remove absolutely positioned elements from the normal flow

Skip over absolutely positioned children when laying out the inline
children of a block. This takes them out of the flow and allows them
to be positioned correctly relative to the (absolute) containing block.
This commit is contained in:
Andreas Kling 2020-06-12 15:25:37 +02:00
parent f3ea8d49a9
commit 08f29be87a

View file

@ -170,6 +170,10 @@ void LayoutBlock::layout_inline_children(LayoutMode layout_mode)
m_line_boxes.clear();
for_each_child([&](auto& child) {
ASSERT(child.is_inline());
if (child.is_box() && child.is_absolutely_positioned()) {
const_cast<LayoutBlock*>(child.containing_block())->add_absolutely_positioned_descendant((LayoutBox&)child);
return;
}
child.split_into_lines(*this, layout_mode);
});
@ -233,9 +237,6 @@ void LayoutBlock::layout_inline_children(LayoutMode layout_mode)
for (size_t i = 0; i < line_box.fragments().size(); ++i) {
auto& fragment = line_box.fragments()[i];
if (fragment.layout_node().is_absolutely_positioned())
continue;
// Vertically align everyone's bottom to the line.
// FIXME: Support other kinds of vertical alignment.
fragment.set_offset({ roundf(x_offset + fragment.offset().x()), content_height + (max_height - fragment.height()) - (line_spacing / 2) });