Truly independent web browser
LibWeb: Leave a lane's frame to the host on whole-document damage
Aliaksandr Kalenika1b664f127e2
diff --git a/Libraries/LibWeb/Rust/src/render_state/clock.rs b/Libraries/LibWeb/Rust/src/render_state/clock.rsindex 29fbda77d88..612baa32dc8 100644--- a/Libraries/LibWeb/Rust/src/render_state/clock.rs+++ b/Libraries/LibWeb/Rust/src/render_state/clock.rs@@ -1803,6 +1803,13 @@ fn freeze_tick_frame(return Err(Park("a trace reads the recording"));}let visual_contexts = prepare_for_clock_tick(arena, viewport)?;+ // A tick's frame copies from the lane's own, and its damage stays: the whole document would record again on every tick.+ if arena.paint_damage_covers_everything()+ || arena.scroll_metadata_damaged_everywhere()+ || recorder.published_recording.is_none()+ {+ return Err(Park("the whole document records again"));+ }let inputs = recorder.published_inputs.take()diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/clock-tick-leaves-whole-document-damage-to-the-host.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/clock-tick-leaves-whole-document-damage-to-the-host.txtnew file mode 100644index 00000000000..56e8cba4ec8--- /dev/null+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/clock-tick-leaves-whole-document-damage-to-the-host.txt@@ -0,0 +1,2 @@+before the box scrolls: presented height 60, ticking, presented by clock+as the box starts to scroll: presented height 60, parkeddiff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/clock-tick-leaves-whole-document-damage-to-the-host.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/clock-tick-leaves-whole-document-damage-to-the-host.htmlnew file mode 100644index 00000000000..fdc2c8ab9ab--- /dev/null+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/clock-tick-leaves-whole-document-damage-to-the-host.html@@ -0,0 +1,32 @@+<!DOCTYPE html>+<script src="../../include.js"></script>+<script src="frame-in-flight.js"></script>+<style>+ body { margin: 0; }+ #scroller { position: absolute; left: 0; top: 0; width: 100px; height: 100px; overflow: auto; }+ #content { width: 50px; height: 10px; }+ #content.active { animation: grow 10s linear infinite; }+ @keyframes grow { from { height: 10px; } to { height: 1010px; } }+</style>+<div id="scroller"><div id="content"></div></div>+<script>+ // Every tick of a lane records from the lane's own frame, and so goes on seeing all the damage since. A box starting+ // to scroll, the first in the document to, has the scroll metadata of every box record again: that frame and every+ // one after it would record the whole document, so the frame is left to the host.+ asyncTest(async done => {+ const result = await whileLaneAnimates(() => {+ content.classList.add("active");+ return content.getAnimations()[0];+ }, (frameTime, animation, startTime) => {+ const lines = [];+ internals.injectClockTick(startTime + 500);+ lines.push(`before the box scrolls: presented height ${internals.presentedBorderBox(content)?.height}, ${internals.clockLaneState(document)}, presented by ${internals.lastFramePresentedBy(document)}`);+ internals.injectClockTick(startTime + 2000);+ lines.push(`as the box starts to scroll: presented height ${internals.presentedBorderBox(content)?.height}, ${internals.clockLaneState(document)}`);+ return lines;+ });+ for (const line of result)+ println(line);+ done();+ });+</script>