From 35a9a2fbb23b8847546731220e4894796a74c7a6 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 14 Sep 2022 14:38:55 +0200 Subject: [PATCH] LibWeb: Account for containing block padding when placing abspos boxes Unlike the other positioning schemes, absolute positioning is relative to the *padding* edge of the containing block. --- Userland/Libraries/LibWeb/Layout/FormattingContext.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index 73b457da7a..554d331e7c 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -802,6 +802,9 @@ void FormattingContext::layout_absolutely_positioned_element(Box const& box) used_offset.set_y(y_offset); } + // NOTE: Absolutely positioned boxes are relative to the *padding edge* of the containing block. + used_offset.translate_by(-containing_block_state.padding_left, -containing_block_state.padding_top); + box_state.offset = used_offset; if (independent_formatting_context)