summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-03-07 22:27:09 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-08 00:19:49 +0100
commit2dfb617c5bf5557052a4fded2cc37ab8574a5e93 (patch)
tree0684b95d14bb66d470c136a84b2cf4cb8f9b93e8
parent6354a9a0303af2f8ece388c72907bbeb89196723 (diff)
downloadserenity-2dfb617c5bf5557052a4fded2cc37ab8574a5e93.zip
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.
-rw-r--r--Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp13
-rw-r--r--Userland/Libraries/LibWeb/Layout/InlineLevelIterator.cpp6
-rw-r--r--Userland/Libraries/LibWeb/Layout/InlineLevelIterator.h1
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<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);
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::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)) {
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 };