.static) [18,18 210x210]
+ PaintableWithLines (BlockContainer
.absolute) [18,228 110x210]
+ PaintableWithLines (BlockContainer(anonymous)) [18,228 764x0]
diff --git a/Tests/LibWeb/Layout/input/abspos-box-with-block-level-sibling.html b/Tests/LibWeb/Layout/input/abspos-box-with-block-level-sibling.html
new file mode 100644
index 0000000000000000000000000000000000000000..e0dcd6035d4b92697a142052df1e225651e2132c
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/abspos-box-with-block-level-sibling.html
@@ -0,0 +1,16 @@
+
diff --git a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
index d24a2dc8d737b2e7f4f321eaad29aade43f850b8..3f7e7b6511a0bba1158af1e6f25d06fdd1a858fd 100644
--- a/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp
@@ -585,6 +585,7 @@ void BlockFormattingContext::layout_block_level_box(Box const& box, BlockContain
auto& box_state = m_state.get_mutable(box);
if (box.is_absolutely_positioned()) {
+ box_state.vertical_offset_of_parent_block_container = m_y_offset_of_current_block_container.value();
m_absolutely_positioned_boxes.append(box);
return;
}
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
index 61b775d6aa4bcf85ef81827dfd956b0104991689..da1a95e1dbf90e7ded1333e9c1b980e3d99cc270 100644
--- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
@@ -1204,9 +1204,10 @@ CSSPixelPoint FormattingContext::calculate_static_position(Box const& box) const
// Easy case: no previous sibling, we're at the top of the containing block.
}
} else {
- x = m_state.get(box).margin_left;
+ auto const& box_state = m_state.get(box);
+ x = box_state.margin_left;
// We're among block siblings, Y can be calculated easily.
- y = m_state.get(box).margin_top;
+ y = box_state.margin_top + box_state.vertical_offset_of_parent_block_container;
}
auto offset_to_static_parent = content_box_rect_in_static_position_ancestor_coordinate_space(box, *box.containing_block());
return offset_to_static_parent.location().translated(x, y);
diff --git a/Userland/Libraries/LibWeb/Layout/LayoutState.h b/Userland/Libraries/LibWeb/Layout/LayoutState.h
index 56c471caff21f39a8f4a7a6aebe5d63ec8abce23..19088e7d53e4e565ebd61717c61e5edb78c7e4a2 100644
--- a/Userland/Libraries/LibWeb/Layout/LayoutState.h
+++ b/Userland/Libraries/LibWeb/Layout/LayoutState.h
@@ -100,6 +100,9 @@ struct LayoutState {
CSSPixels inset_top { 0 };
CSSPixels inset_bottom { 0 };
+ // Used for calculating the static position of an abspos block-level box.
+ CSSPixels vertical_offset_of_parent_block_container { 0 };
+
Vector
line_boxes;
CSSPixels margin_box_left() const { return margin_left + border_left_collapsed() + padding_left; }