mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 15:45:25 +00:00
LibGfx: Add rounded_int_rect() function for Rects
We were seeing a problem in LibWeb, where layout elements would be 1px larger than they should be, due to layout positions using float values, and then converting using `enclosing_int_rect()`. `rounded_int_rect()` replaces that use, by maintaining the original rect's size.
This commit is contained in:
committed by
Andreas Kling
parent
8817ea83d6
commit
0b7eefd4e5
@@ -715,6 +715,11 @@ using FloatRect = Rect<float>;
|
||||
return Gfx::IntRect::from_two_points({ x1, y1 }, { x2, y2 });
|
||||
}
|
||||
|
||||
[[nodiscard]] ALWAYS_INLINE IntRect rounded_int_rect(FloatRect const& float_rect)
|
||||
{
|
||||
return IntRect { floorf(float_rect.x()), floorf(float_rect.y()), roundf(float_rect.width()), roundf(float_rect.height()) };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace AK {
|
||||
|
||||
Reference in New Issue
Block a user