mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb: Stop calling Window::scroll_by() during layout
Replace the Window::scroll_by(0, 0) call at the end of Document::update_layout() with a dedicated Navigable::clamp_viewport_scroll_offset() that directly clamps the viewport scroll offset to valid bounds. The old approach re-entered layout from within layout, since scroll_by() would trigger another layout update. The new approach is called from the event loop's rendering steps, after layout is complete.
This commit is contained in:
committed by
Andreas Kling
parent
74109d2f6b
commit
787a83b50a
Notes:
github-actions[bot]
2026-02-26 20:11:24 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/787a83b50ab Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8182
@@ -449,6 +449,11 @@ void EventLoop::update_the_rendering()
|
||||
// NOTE: Recalculation of styles is handled by update_layout()
|
||||
document->update_layout(DOM::UpdateLayoutReason::HTMLEventLoopRenderingUpdate);
|
||||
|
||||
// Clamp viewport scroll offset to valid range after layout, in case the
|
||||
// scrollable overflow area has shrunk (e.g. after a viewport size change).
|
||||
if (auto navigable = document->navigable())
|
||||
navigable->clamp_viewport_scroll_offset();
|
||||
|
||||
// 2. Let hadInitialVisibleContentVisibilityDetermination be false.
|
||||
bool had_initial_visible_content_visibility_determination = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user