LibWeb: Limit the minimum scrollbar size to the overflown box's size

A hard-coded value of 50px is too large for text boxes with a size that
is less than 50px. Reduce this to 24px, and further limit it by the size
of the overflown box.
This commit is contained in:
Timothy Flynn 2024-09-05 16:28:27 -04:00 committed by Alexander Kalenik
commit 60f30aad72
Notes: github-actions[bot] 2024-09-05 23:35:32 +00:00

View file

@ -286,8 +286,10 @@ Optional<PaintableBox::ScrollbarData> PaintableBox::compute_scrollbar_data(Scrol
auto scrollport_size = direction == ScrollDirection::Horizontal ? padding_rect.width() : padding_rect.height();
if (scroll_overflow_size == 0)
return {};
auto const min_thumb_length = 50;
auto min_thumb_length = min(scrollport_size, 24);
auto thumb_length = max(scrollport_size * (scrollport_size / scroll_overflow_size), min_thumb_length);
CSSPixelFraction scroll_size = 0;
if (scroll_overflow_size > scrollport_size)
scroll_size = (scrollport_size - thumb_length) / (scroll_overflow_size - scrollport_size);