LibWeb: Update layout before looking at overflow in window.scroll()

Fixes a crash seen on https://www.ekioh.com/
This commit is contained in:
Andreas Kling 2024-01-18 20:58:53 +01:00
parent 0d8a013ee1
commit 9f6841a65c
Notes: sideshowbarker 2024-07-17 00:57:24 +09:00
3 changed files with 12 additions and 0 deletions

View file

@ -0,0 +1 @@
PASS (didn't crash)

View file

@ -0,0 +1,5 @@
<body><script>
window.scrollTo(200, 200);
if (window.internals !== undefined)
window.internals.signalTextTestIsDone();
</script>PASS (didn't crash)

View file

@ -1273,6 +1273,12 @@ void Window::scroll(ScrollToOptions const& options)
auto viewport_height = viewport_rect.height();
auto const document = top_level_traversable->active_document();
VERIFY(document);
// Make sure layout is up-to-date before looking at scrollable overflow metrics.
document->update_layout();
VERIFY(document->paintable_box());
auto scrolling_area = document->paintable_box()->scrollable_overflow_rect()->to_type<float>();
// 7. FIXME: For now we always assume overflow direction is rightward