Skip to content

Truly independent web browser

LibWeb: Stop render clock lanes when the viewport changes

Andreas Kling00a9c1505551
diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp
index d6612253fca..1ceea6ff576 100644
--- a/Libraries/LibWeb/DOM/Document.cpp
+++ b/Libraries/LibWeb/DOM/Document.cpp
@@ -2807,6 +2807,12 @@ void Document::invalidate_style_for_viewport_change(CSSPixelSize previous_viewpo
Layout::ForcedReadScope read { *this };
auto& style_engine = style_computer().style_engine();
+ // NB: The render clock's lanes tick the document's animations in the layout of the last rendering update, which
+ // was made for the previous viewport. Frames of that size are of no use any more, and animated values that
+ // depend on the viewport no longer stand, so the lanes stop until the next rendering update plans them again.
+ if (auto* arena = layout_node_arena_if_created())
+ Layout::RustFFI::document_host_note_animation_change(arena->host());
+
if (any_registration_read_viewport) {
// The custom-property registry holds the initial values just dropped, so the next style
// update has to publish the recomputed ones before it reads them. A registered initial value
diff --git a/Libraries/LibWeb/Rust/src/render_state/clock.rs b/Libraries/LibWeb/Rust/src/render_state/clock.rs
index 09918a2cc7d..9f798b3571b 100644
--- a/Libraries/LibWeb/Rust/src/render_state/clock.rs
+++ b/Libraries/LibWeb/Rust/src/render_state/clock.rs
@@ -1930,8 +1930,8 @@ pub extern "C" fn document_host_drop_clock_plan(host: &DocumentHost, update: u64
host.seal_clock_plan(None, update);
}
-/// Notes that script changed an animation of `host`'s document: the animations of the plans sealed before no longer
-/// stand, and the lanes' hover goes on.
+/// Notes that script changed an animation of `host`'s document, or that its viewport changed: the animations of the
+/// plans sealed before no longer stand, and the lanes' hover goes on.
#[unsafe(no_mangle)]
pub extern "C" fn document_host_note_animation_change(host: &DocumentHost) {
host.note_animation_change();