mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-16 14:02:00 +00:00
LibWeb: Turn Window.scroll(0, 0) into a no-op when possible
For unscrolled viewports (already at 0, 0), we can short-circuit here and avoid doing a synchronous relayout of the page. This avoids a bunch of synchronous layouts on Speedometer3's NewsSite (Nuxt version) subtests.
This commit is contained in:
parent
1242b9152e
commit
9840a8c750
Notes:
github-actions[bot]
2025-04-22 10:10:50 +00:00
Author: https://github.com/awesomekling
Commit: 9840a8c750
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4424
Reviewed-by: https://github.com/gmta
1 changed files with 4 additions and 0 deletions
|
@ -1465,6 +1465,10 @@ void Window::scroll(ScrollToOptions const& options)
|
|||
x = HTML::normalize_non_finite_values(x);
|
||||
y = HTML::normalize_non_finite_values(y);
|
||||
|
||||
// OPTIMIZATION: If we're asked to scroll to (0, 0) and we're already there, do nothing.
|
||||
if (x == 0 && y == 0 && navigable->viewport_scroll_offset().is_zero())
|
||||
return;
|
||||
|
||||
// 5. Let viewport width be the width of the viewport excluding the width of the scroll bar, if any.
|
||||
auto viewport_width = viewport_rect.width();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue