LibWeb: Only apply box offset if the box is not already the ancestor

When determining the content/margin box rects within their ancestor's
coordinate space, we were returning early if the passed in values
already belonged to the requested ancestor. Unfortunately, we had
already applied the used values' offset to the rect, which is the offset
to the ancestor's ancestor.

This simplifies the logic to always apply the rect offset after checking
if we've reached the ancestor. Fixes determining float intrusions inside
block elements with `margin: auto` set.

Fixes #4083.
This commit is contained in:
Jelle Raaijmakers 2025-04-04 11:28:03 +02:00
commit 99df80f81e
Notes: github-actions[bot] 2025-04-04 13:36:19 +00:00
5 changed files with 57 additions and 16 deletions

View file

@ -82,7 +82,6 @@ public:
[[nodiscard]] CSSPixelRect absolute_content_rect(Box const&) const;
[[nodiscard]] CSSPixelRect margin_box_rect_in_ancestor_coordinate_space(Box const&, Box const& ancestor_box) const;
[[nodiscard]] CSSPixelRect margin_box_rect(LayoutState::UsedValues const&) const;
[[nodiscard]] CSSPixelRect margin_box_rect_in_ancestor_coordinate_space(LayoutState::UsedValues const&, Box const& ancestor_box) const;
[[nodiscard]] CSSPixelRect content_box_rect(Box const&) const;
[[nodiscard]] CSSPixelRect content_box_rect(LayoutState::UsedValues const&) const;