mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibWeb: Turn Element.scroll(0, 0) into a no-op when possible
For unscrolled elements (already at 0, 0) that aren't eligible to be the Document.scrollingElement, 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 subtests.
This commit is contained in:
parent
c394344e7d
commit
1242b9152e
|
|
@ -2813,6 +2813,16 @@ void Element::scroll(double x, double y)
|
|||
if (document.document_element() == this && document.in_quirks_mode())
|
||||
return;
|
||||
|
||||
// OPTIMIZATION: Scrolling an unscrolled element to (0, 0) is a no-op as long
|
||||
// as the element is not eligible to be the Document.scrollingElement.
|
||||
if (x == 0
|
||||
&& y == 0
|
||||
&& scroll_offset(ScrollOffsetFor::Self).is_zero()
|
||||
&& this != document.body()
|
||||
&& this != document.document_element()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// NOTE: Ensure that layout is up-to-date before looking at metrics.
|
||||
document.update_layout(UpdateLayoutReason::ElementScroll);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user