瀏覽代碼

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.
Andreas Kling 2 年之前
父節點
當前提交
35a9a2fbb2
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      Userland/Libraries/LibWeb/Layout/FormattingContext.cpp

+ 3 - 0
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)