From 08f29be87a9d329a3f70ae27584a2a2f91fa84fd Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 12 Jun 2020 15:25:37 +0200 Subject: [PATCH] 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. --- Libraries/LibWeb/Layout/LayoutBlock.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Libraries/LibWeb/Layout/LayoutBlock.cpp b/Libraries/LibWeb/Layout/LayoutBlock.cpp index fb5125a6c5..19318a9551 100644 --- a/Libraries/LibWeb/Layout/LayoutBlock.cpp +++ b/Libraries/LibWeb/Layout/LayoutBlock.cpp @@ -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(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) });