) [18,117 200x150]
+ TextPaintable (TextNode<#text>)
+ TextPaintable (TextNode<#text>)
+ PaintableWithLines (BlockContainer
.abspos) [41.125,134 23.125x17]
+ TextPaintable (TextNode<#text>)
+ PaintableWithLines (BlockContainer(anonymous)) [8,532 784x0]
diff --git a/Tests/LibWeb/Layout/input/grid/inline-abspos-item.html b/Tests/LibWeb/Layout/input/grid/inline-abspos-item.html
new file mode 100644
index 00000000000..31fd1b155dc
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/grid/inline-abspos-item.html
@@ -0,0 +1,25 @@
+
+
+
+
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
index 16e30d0856f..84ac85beff8 100644
--- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
@@ -1204,6 +1204,7 @@ StaticPositionRect FormattingContext::calculate_static_position_rect(Box const&
}
}
if (last_fragment) {
+ x = last_fragment->offset().x() + last_fragment->width();
y = last_fragment->offset().y() + last_fragment->height();
}
} else {
diff --git a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
index b4c25743ecf..374954ee5bc 100644
--- a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp
@@ -260,6 +260,8 @@ void InlineFormattingContext::generate_line_boxes()
// axis, so that we can add it to the first non-whitespace chunk.
CSSPixels leading_margin_from_collapsible_whitespace = 0;
+ Vector
absolute_boxes;
+
for (;;) {
auto item_opt = iterator.next();
if (!item_opt.has_value())
@@ -307,8 +309,8 @@ void InlineFormattingContext::generate_line_boxes()
case InlineLevelIterator::Item::Type::AbsolutelyPositionedElement:
if (is(*item.node)) {
auto const& box = static_cast(*item.node);
- auto& box_state = m_state.get_mutable(box);
- box_state.set_static_position_rect(calculate_static_position_rect(box));
+ // Calculation of static position for absolute boxes is delayed until trailing whitespaces are removed.
+ absolute_boxes.append(&box);
}
break;
@@ -410,6 +412,11 @@ void InlineFormattingContext::generate_line_boxes()
apply_justification_to_fragments(text_justify, line_box, is_last_line);
}
}
+
+ for (auto* box : absolute_boxes) {
+ auto& box_state = m_state.get_mutable(*box);
+ box_state.set_static_position_rect(calculate_static_position_rect(*box));
+ }
}
bool InlineFormattingContext::any_floats_intrude_at_y(CSSPixels y) const