LibGfx: Add Rect::unite()

The existing `::unite_horizontally()` and `::unite_vertically()` tests
did not properly test the edge cases where left/top in the Rect were
updated, so they get re-arranged a bit.
This commit is contained in:
Jelle Raaijmakers 2025-01-15 13:51:39 +01:00 committed by Jelle Raaijmakers
commit 7eb4f3da37
Notes: github-actions[bot] 2025-01-23 08:34:31 +00:00
7 changed files with 51 additions and 38 deletions

View file

@ -89,9 +89,8 @@ static CSSPixelRect measure_scrollable_overflow(Box const& box)
// - All line boxes directly contained by the scroll container.
if (is<Painting::PaintableWithLines>(box.first_paintable())) {
for (auto const& fragment : static_cast<Painting::PaintableWithLines const&>(*box.first_paintable()).fragments()) {
scrollable_overflow_rect = scrollable_overflow_rect.united(fragment.absolute_rect());
}
for (auto const& fragment : static_cast<Painting::PaintableWithLines const&>(*box.first_paintable()).fragments())
scrollable_overflow_rect.unite(fragment.absolute_rect());
}
auto content_overflow_rect = scrollable_overflow_rect;
@ -117,8 +116,8 @@ static CSSPixelRect measure_scrollable_overflow(Box const& box)
if (child_border_box.bottom() < 0 || child_border_box.right() < 0)
return TraversalDecision::Continue;
scrollable_overflow_rect = scrollable_overflow_rect.united(child_border_box);
content_overflow_rect = content_overflow_rect.united(child_border_box);
scrollable_overflow_rect.unite(child_border_box);
content_overflow_rect.unite(child_border_box);
// - The scrollable overflow areas of all of the above boxes
// (including zero-area boxes and accounting for transforms as described above),