mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 21:58:12 +00:00
LibWeb: Do not compensate padding for abspos boxes with static position
When a box does not have a top, left, bottom, or right, there is no need to adjust the offset for positioning relative to the padding edge, because the box remains in the normal flow.
This commit is contained in:
parent
2c1bbf5a99
commit
4164af2ca4
9 changed files with 128 additions and 1 deletions
|
@ -1123,7 +1123,12 @@ void FormattingContext::layout_absolutely_positioned_element(Box const& box, Ava
|
|||
used_offset.set_x(box_state.inset_left + box_state.margin_box_left());
|
||||
used_offset.set_y(box_state.inset_top + box_state.margin_box_top());
|
||||
// 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);
|
||||
// Padding offset only need to be compensated when top/left/bottom/right is not auto because otherwise
|
||||
// the box is positioned at the static position of the containing block.
|
||||
if (!box.computed_values().inset().top().is_auto() || !box.computed_values().inset().bottom().is_auto())
|
||||
used_offset.translate_by(0, -containing_block_state.padding_top);
|
||||
if (!box.computed_values().inset().left().is_auto() || !box.computed_values().inset().right().is_auto())
|
||||
used_offset.translate_by(-containing_block_state.padding_left, 0);
|
||||
box_state.set_content_offset(used_offset);
|
||||
|
||||
if (independent_formatting_context)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue