mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 12:20:00 +01: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
|
|
@ -1465,6 +1465,10 @@ void Window::scroll(ScrollToOptions const& options)
|
||||||
x = HTML::normalize_non_finite_values(x);
|
x = HTML::normalize_non_finite_values(x);
|
||||||
y = HTML::normalize_non_finite_values(y);
|
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.
|
// 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();
|
auto viewport_width = viewport_rect.width();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user