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.
This commit is contained in:
Andreas Kling 2022-03-07 22:27:09 +01:00
commit 2dfb617c5b
Notes: sideshowbarker 2024-07-17 17:48:58 +09:00
3 changed files with 11 additions and 9 deletions

View file

@ -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<Box>(child) && child.is_absolutely_positioned()) {
parent().add_absolutely_positioned_box(static_cast<Box&>(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<Box>(*item.node))
parent().add_absolutely_positioned_box(static_cast<Layout::Box const&>(*item.node));
break;
case InlineLevelIterator::Item::Type::Text: {
auto& text_node = verify_cast<Layout::TextNode>(*item.node);
line_builder.break_if_needed(layout_mode, item.border_box_width(), item.should_force_break);

View file

@ -155,8 +155,12 @@ Optional<InlineLevelIterator::Item> 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<Layout::BreakNode>(*m_current_node)) {

View file

@ -26,6 +26,7 @@ public:
Text,
Element,
ForcedBreak,
AbsolutelyPositionedElement,
};
Type type {};
Layout::Node const* node { nullptr };