LibWeb: Subtract left inset from size_available_for_margins for abspos

Fixes https://github.com/LadybirdBrowser/ladybird/issues/712
This commit is contained in:
Aliaksandr Kalenik 2024-07-19 13:58:59 +02:00 committed by Sam Atkins
commit 0be57df54d
Notes: sideshowbarker 2024-07-19 21:35:25 +09:00
3 changed files with 34 additions and 1 deletions

View file

@ -726,7 +726,7 @@ void FormattingContext::compute_width_for_absolutely_positioned_non_replaced_ele
// If both margin-left and margin-right are auto,
// solve the equation under the extra constraint that the two margins get equal values
// FIXME: unless this would make them negative, in which case when direction of the containing block is ltr (rtl), set margin-left (margin-right) to 0 and solve for margin-right (margin-left).
auto size_available_for_margins = width_of_containing_block - border_left - padding_left - width.to_px(box) - padding_right - border_right - right;
auto size_available_for_margins = width_of_containing_block - border_left - padding_left - width.to_px(box) - padding_right - border_right - left - right;
if (margin_left.is_auto() && margin_right.is_auto()) {
margin_left = CSS::Length::make_px(size_available_for_margins / 2);
margin_right = CSS::Length::make_px(size_available_for_margins / 2);