From 2dfb617c5bf5557052a4fded2cc37ab8574a5e93 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 7 Mar 2022 22:27:09 +0100 Subject: [PATCH] LibWeb: Make InlineLevelIterator emit absolutely positioned items Note that we don't put absolutely positioned items on a line! This is just so that IFC can discover boxes and pass them along to BFC. This fixes an issue where only direct children of the IFC containing block were considered for absolute positioning. Now we pick up absolutely positioned children of nested inline nodes as well. --- .../LibWeb/Layout/InlineFormattingContext.cpp | 13 +++++-------- .../Libraries/LibWeb/Layout/InlineLevelIterator.cpp | 6 +++++- .../Libraries/LibWeb/Layout/InlineLevelIterator.h | 1 + 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp index 6fa30bbf02..228d3b3285 100644 --- a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp @@ -75,14 +75,6 @@ void InlineFormattingContext::run(Box const&, LayoutMode layout_mode) generate_line_boxes(layout_mode); - containing_block().for_each_child([&](auto& child) { - VERIFY(child.is_inline()); - if (is(child) && child.is_absolutely_positioned()) { - parent().add_absolutely_positioned_box(static_cast(child)); - return; - } - }); - float min_line_height = containing_block().line_height(); float max_line_width = 0; float content_height = 0; @@ -201,6 +193,11 @@ void InlineFormattingContext::generate_line_boxes(LayoutMode layout_mode) line_builder.append_box(box, item.border_start + item.padding_start, item.padding_end + item.border_end); break; } + case InlineLevelIterator::Item::Type::AbsolutelyPositionedElement: + if (is(*item.node)) + parent().add_absolutely_positioned_box(static_cast(*item.node)); + break; + case InlineLevelIterator::Item::Type::Text: { auto& text_node = verify_cast(*item.node); line_builder.break_if_needed(layout_mode, item.border_box_width(), item.should_force_break); diff --git a/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp b/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp index 51d022eea9..0088530355 100644 --- a/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp +++ b/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp @@ -155,8 +155,12 @@ Optional InlineLevelIterator::next(float available_wi } if (m_current_node->is_absolutely_positioned()) { + auto& node = *m_current_node; skip_to_next(); - return next(available_width); + return Item { + .type = Item::Type::AbsolutelyPositionedElement, + .node = &node, + }; } if (is(*m_current_node)) { diff --git a/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.h b/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.h index bfc29421c7..c4b6271293 100644 --- a/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.h +++ b/Userland/Libraries/LibWeb/Layout/InlineLevelIterator.h @@ -26,6 +26,7 @@ public: Text, Element, ForcedBreak, + AbsolutelyPositionedElement, }; Type type {}; Layout::Node const* node { nullptr };