LibWeb: Avoid division by zero when calculating scrollbar rect

This commit is contained in:
Tim Ledbetter 2024-03-17 07:15:29 +00:00 committed by Andreas Kling
commit a40c14462d
Notes: sideshowbarker 2024-07-17 10:31:19 +09:00
3 changed files with 16 additions and 0 deletions

View file

@ -276,6 +276,8 @@ Optional<CSSPixelRect> PaintableBox::scroll_thumb_rect(ScrollDirection direction
auto scroll_overflow_size = direction == ScrollDirection::Horizontal ? scrollable_overflow_rect.width() : scrollable_overflow_rect.height();
auto scrollport_size = direction == ScrollDirection::Horizontal ? padding_rect.width() : padding_rect.height();
auto scroll_offset = direction == ScrollDirection::Horizontal ? this->scroll_offset().x() : this->scroll_offset().y();
if (scroll_overflow_size == 0)
return {};
auto thumb_size = scrollport_size * (scrollport_size / scroll_overflow_size);
CSSPixels thumb_position = 0;