LibWeb: Avoid division by zero when calculating scrollbar rect
This commit is contained in:
parent
0afbd827e0
commit
a40c14462d
Notes:
sideshowbarker
2024-07-17 10:31:19 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/a40c14462d Pull-request: https://github.com/SerenityOS/serenity/pull/23616
3 changed files with 16 additions and 0 deletions
|
@ -0,0 +1 @@
|
|||
PASS (didn't crash)
|
13
Tests/LibWeb/Text/input/overflow-with-zero-sized-box.html
Normal file
13
Tests/LibWeb/Text/input/overflow-with-zero-sized-box.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const parent = document.createElement("div");
|
||||
parent.style.width = 0;
|
||||
parent.style.overflow = 'scroll'
|
||||
const child = document.createElement("div");
|
||||
child.style.width = 0;
|
||||
document.body.appendChild(parent);
|
||||
println("PASS (didn't crash)");
|
||||
});
|
||||
</script>
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue