1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:07:36 +00:00

LibWeb: Properly round CSSPixels values in device_to_css_rect

Ceiling width or height of a chrome viewport (this function is only used
when a chrome notifies LibWeb about a new viewport size) is never
correct. If we do that, PageClient::page_did_layout will set content
size to be 1 larger than an actual physical width or height respectively
(it always ceils) and thus a spurious scrollbar will appear.

This prevents occasional scrollbar flickering in Ladybird/Qt on Wayland
with fractional scaling enabled on compositors supporting
wp-fractional-scale-v1.
This commit is contained in:
Dan Klishch 2024-02-07 22:46:39 -05:00 committed by Alexander Kalenik
parent 7bee1c9897
commit 56d355a15e
2 changed files with 13 additions and 4 deletions

View file

@ -98,6 +98,15 @@ public:
return from_raw(raw_value);
}
template<FloatingPoint F>
static CSSPixels floored_value_for(F value)
{
i32 raw_value = 0;
if (!isnan(value))
raw_value = AK::clamp_to<int>(floor(value * fixed_point_denominator));
return from_raw(raw_value);
}
template<Unsigned U>
constexpr CSSPixels(U value)
{