Truly independent web browser
LibWeb+Compositor: Hover in the lane as an animation moves content
Zaggy10244583640a4246
diff --git a/Libraries/LibWeb/Compositor/RenderClock.cpp b/Libraries/LibWeb/Compositor/RenderClock.cppindex 814fbda5cb2..becfa3d342f 100644--- a/Libraries/LibWeb/Compositor/RenderClock.cpp+++ b/Libraries/LibWeb/Compositor/RenderClock.cpp@@ -55,6 +55,12 @@ private:m_clock.did_receive_pointer_move(context_id, {}, 0, false, input_event_id);}+ virtual void pointer_rests_on_moving_content(Web::CompositorContextId context_id) override+ {+ if (!m_detached)+ m_clock.did_receive_pointer_rest(context_id);+ }+RenderClock& m_clock;bool m_detached { false };};@@ -83,6 +89,11 @@ PointerAnswer ClockTicksHandle::pointer_moved(Optional<Gfx::FloatPoint> device_preturn static_cast<PointerAnswer>(Layout::RustFFI::clock_ticks_pointer_moved(m_ticks, device_position.has_value(), position.x(), position.y(), buttons, scrolled_since_frame, input_event_id));}+PointerAnswer ClockTicksHandle::pointer_rests_on_moving_content() const+{+ return static_cast<PointerAnswer>(Layout::RustFFI::clock_ticks_pointer_rests_on_moving_content(m_ticks));+}+RenderClock& RenderClock::the(){// The clock lives as long as the process, which ends with its thread still waiting for ticks.@@ -251,7 +262,20 @@ void RenderClock::did_receive_pointer_move(Web::CompositorContextId context_id,auto it = m_pointer_lanes.find(context_id);if (it == m_pointer_lanes.end())return;- switch (it->value.ticks->pointer_moved(device_position, buttons, scrolled_since_frame, input_event_id)) {+ arm_lane_for_pointer_answer(context_id, it->value, it->value.ticks->pointer_moved(device_position, buttons, scrolled_since_frame, input_event_id));+}++void RenderClock::did_receive_pointer_rest(Web::CompositorContextId context_id)+{+ auto it = m_pointer_lanes.find(context_id);+ if (it == m_pointer_lanes.end())+ return;+ arm_lane_for_pointer_answer(context_id, it->value, it->value.ticks->pointer_rests_on_moving_content());+}++void RenderClock::arm_lane_for_pointer_answer(Web::CompositorContextId context_id, PointerLane const& lane, PointerAnswer answer)+{+ switch (answer) {case PointerAnswer::Moves:return;case PointerAnswer::Ticks:@@ -263,9 +287,8 @@ void RenderClock::did_receive_pointer_move(Web::CompositorContextId context_id,// A context armed for ticks already asked for the next one.if (m_armed_contexts.contains(context_id))return;- auto maximum_frames_per_second = it->value.maximum_frames_per_second;- m_armed_contexts.set(context_id, ArmedContext { maximum_frames_per_second, it->value.ticks });- request_clock_tick(context_id, maximum_frames_per_second);+ m_armed_contexts.set(context_id, ArmedContext { lane.maximum_frames_per_second, lane.ticks });+ request_clock_tick(context_id, lane.maximum_frames_per_second);}void RenderClock::request_clock_tick(Web::CompositorContextId context_id, double maximum_frames_per_second)diff --git a/Libraries/LibWeb/Compositor/RenderClock.h b/Libraries/LibWeb/Compositor/RenderClock.hindex deac1eab192..610c9216c74 100644--- a/Libraries/LibWeb/Compositor/RenderClock.h+++ b/Libraries/LibWeb/Compositor/RenderClock.h@@ -60,6 +60,10 @@ public:// takes beside it, and answers what the lanes want next.PointerAnswer pointer_moved(Optional<Gfx::FloatPoint> device_position, u32 buttons, bool scrolled_since_frame, u64 input_event_id) const;+ // Hands the lane that the pointer rests where the Compositor's animations move what is under it, which the next+ // tick hovers again, and answers what the lanes want next.+ PointerAnswer pointer_rests_on_moving_content() const;+bool hands_on_to(ClockTicksHandle const& other) const { return m_ticks == other.m_ticks; }private:@@ -128,6 +132,7 @@ private:void request_clock_tick(Web::CompositorContextId, double maximum_frames_per_second);void did_receive_clock_tick(Web::CompositorContextId, i64 frame_time_nanoseconds, ReadonlySpan<Web::CompositorScrollOffset>);void did_receive_pointer_move(Web::CompositorContextId, Optional<Gfx::FloatPoint> device_position, u32 buttons, bool scrolled_since_frame, u64 input_event_id);+ void did_receive_pointer_rest(Web::CompositorContextId);void did_lose_channel();NonnullRefPtr<Threading::Thread> m_thread;@@ -146,6 +151,7 @@ private:NonnullRefPtr<ClockTicksHandle> ticks;};HashMap<Web::CompositorContextId, PointerLane> m_pointer_lanes;+ void arm_lane_for_pointer_answer(Web::CompositorContextId, PointerLane const&, PointerAnswer);};}diff --git a/Libraries/LibWeb/Internals/Internals.cpp b/Libraries/LibWeb/Internals/Internals.cppindex 1f276f7ee31..ef8f0cfc9a1 100644--- a/Libraries/LibWeb/Internals/Internals.cpp+++ b/Libraries/LibWeb/Internals/Internals.cpp@@ -2441,6 +2441,13 @@ void Internals::note_animated_content_moved_under_pointer(double frame_time_ms)navigable->event_handler().note_animated_content_moved_under_pointer(static_cast<i64>(frame_time * 1'000'000.0));}+void Internals::inject_pointer_rests_on_moving_content(double frame_time_ms)+{+ auto& document = window().associated_document();+ auto frame_time = document.relevant_settings_object().time_origin() + frame_time_ms;+ Layout::RustFFI::document_host_inject_pointer_rest(document.layout_node_arena().host(), static_cast<i64>(frame_time * 1'000'000.0));+}+u64 Internals::queue_mouse_move(double x, double y, u32 buttons){// NB: Above every id a UI process hands out in a test.diff --git a/Libraries/LibWeb/Internals/Internals.h b/Libraries/LibWeb/Internals/Internals.hindex dd64a3698fd..17533b7392a 100644--- a/Libraries/LibWeb/Internals/Internals.h+++ b/Libraries/LibWeb/Internals/Internals.h@@ -294,6 +294,7 @@ public:void inject_clock_tick_scrolling_element(double frame_time_ms, DOM::Element& scroller, double x, double y);void inject_hover_pointer(double x, double y, Optional<double> frame_time_ms, Optional<u64> input_event_id);void note_animated_content_moved_under_pointer(double frame_time_ms);+ void inject_pointer_rests_on_moving_content(double frame_time_ms);u64 queue_mouse_move(double x, double y, u32 buttons);void move_hover_pointer(double x, double y, Optional<u64> input_event_id);Utf16String clock_lane_state(DOM::Document&);diff --git a/Libraries/LibWeb/Internals/Internals.idl b/Libraries/LibWeb/Internals/Internals.idlindex 6feab6a3f63..c3dded58dbb 100644--- a/Libraries/LibWeb/Internals/Internals.idl+++ b/Libraries/LibWeb/Internals/Internals.idl@@ -315,6 +315,7 @@ interface Internals {// Reports to the current document's navigable, as the compositor would, that a frame of a transform animation it// runs moved content under the pointer at rest, or away from it, as of the given frame time.undefined noteAnimatedContentMovedUnderPointer(double frameTimeMs);+ undefined injectPointerRestsOnMovingContent(double frameTimeMs);// Queues a mouse move to the given point in CSS pixels, with the given mouse buttons held, as the UI process would// send it, which the next rendering update handles, and answers its input event id.unsigned long long queueMouseMove(double x, double y, optional unsigned long buttons = 0);diff --git a/Libraries/LibWeb/Rust/src/render_state/clock.rs b/Libraries/LibWeb/Rust/src/render_state/clock.rsindex 1f95d233fad..fcb5084a91e 100644--- a/Libraries/LibWeb/Rust/src/render_state/clock.rs+++ b/Libraries/LibWeb/Rust/src/render_state/clock.rs@@ -413,10 +413,12 @@ impl LaneState {}}-/// What a tick of a lane did: the pointer move its hover took, if it took one, and whether it presented a frame.+/// What a tick of a lane did: the pointer move its hover took, if it took one, whether it presented a frame, and+/// whether the samples of animations or transitions it showed in that frame moved boxes.struct Ticked {hover_move: Option<LaneMove>,presented: bool,+ sampled: bool,}/// A pointer move a tick of a lane took, which the host takes in.@@ -800,6 +802,13 @@ impl ClockTicks {self.pointer_state().moved(pointer, follows)}+ /// Hands the lane that the pointer rests where an animation moves what is under it, which the next tick hovers+ /// again, and answers what the lane wants next.+ pub(super) fn pointer_rests_on_moving_content(&self) -> hover::PointerAnswer {+ let follows = self.published().follows_pointer;+ self.pointer_state().rests_on_moving_content(follows)+ }+/// Where the compositor said the pointer went last, beside the mouse event the host takes, if it said so.pub(super) fn newest_pointer(&self) -> Option<PendingPointer> {self.pointer_state().last()@@ -839,6 +848,11 @@ impl ClockTicks {self.tick(frame_time_nanoseconds, &[]);}+ pub(super) fn inject_pointer_rest(self: &Arc<Self>, frame_time_nanoseconds: i64) {+ let _ = self.pointer_rests_on_moving_content();+ self.tick(frame_time_nanoseconds, &[]);+ }+fn pointer_state(&self) -> std::sync::MutexGuard<'_, hover::PointerState> {self.pointer.lock().unwrap_or_else(std::sync::PoisonError::into_inner)}@@ -1379,6 +1393,7 @@ impl Lane {let mut ticked = Ticked {hover_move: None,presented: false,+ sampled: false,};if self.frame_left_to_host || (!samples_animations && hovers.is_none() && !transitions) {return ticked;@@ -1396,12 +1411,14 @@ impl Lane {state.engine_mut().lend_tick_shown(std::mem::take(&mut self.shown));self.refresh_host_effect_timings(state);let mut moved = false;+ let mut sampled = false;if transitions {// NB: Transitions a tick left to the host keep what their boxes showed, beside what the others moved.- moved |= self.sample_started_transitions(state, sampled_at.0).unwrap_or(true);+ sampled |= self.sample_started_transitions(state, sampled_at.0).unwrap_or(true);+ moved |= sampled;}if let Some(pointer) = hovers {- let hovered = self.hover(state, pointer, sampled_at.0);+ let hovered = self.hover(state, pointer, sampled_at.0, frame_time_nanoseconds);ticked.hover_move = Some(LaneMove {input_event_id: pointer.input_event_id,target: match hovered {@@ -1424,7 +1441,10 @@ impl Lane {false => Ok(false),});match shown {- Ok(sampled) => moved |= sampled,+ Ok(transitions_moved) => {+ moved |= transitions_moved;+ sampled |= transitions_moved;+ }Err(Park(reason)) => {if hover::logs_hover() {eprintln!("{} hover lane: frame left to the host: {reason}", hover::log_time());@@ -1448,6 +1468,7 @@ impl Lane {match self.sample_host_animations(state, samples) {Ok(()) => {moved = true;+ sampled = true;self.shown_at = sampled_at.0;self.shown_scroll_progress = progress;}@@ -1470,6 +1491,7 @@ impl Lane {);}ticked.presented = true;+ ticked.sampled = sampled;}Err(Park(reason)) => {if hover::logs_hover() {diff --git a/Libraries/LibWeb/Rust/src/render_state/clock/hover.rs b/Libraries/LibWeb/Rust/src/render_state/clock/hover.rsindex de33495a383..9dbff4edb68 100644--- a/Libraries/LibWeb/Rust/src/render_state/clock/hover.rs+++ b/Libraries/LibWeb/Rust/src/render_state/clock/hover.rs@@ -318,6 +318,20 @@ impl PointerState {self.last}+ /// Has the next tick hover where the pointer rests, as an animation moves what is under it, where a lane `follows`+ /// the pointer, and answers what the lanes want next. A rest the host handled a newer move than is nobody's to+ /// hover, as such a move is.+ pub(super) fn rests_on_moving_content(&mut self, follows: bool) -> PointerAnswer {+ let Some(last) = self.last.filter(|last| last.position.is_some()) else {+ return PointerAnswer::Moves;+ };+ if !follows || self.is_older_than_handled(last) {+ return PointerAnswer::Moves;+ }+ self.pending = Some(last);+ PointerAnswer::Ticks+ }+/// Takes the move that waits for a tick to hover it.pub(super) fn take(&mut self) -> Option<PendingPointer> {self.pending.take()@@ -551,8 +565,15 @@ impl Lane {}}- /// Hovers the element under `pointer`, and answers whether that moved anything to lay out and present.- pub(super) fn hover(&mut self, state: &mut RenderState, pointer: PendingPointer, timestamp: f64) -> Hovered {+ /// Hovers the element under `pointer`, in the frame as the screen shows it at `frame_time_nanoseconds`, and answers+ /// whether that moved anything to lay out and present.+ pub(super) fn hover(+ &mut self,+ state: &mut RenderState,+ pointer: PendingPointer,+ timestamp: f64,+ frame_time_nanoseconds: i64,+ ) -> Hovered {// A scroll the host has not laid out moved what is under the pointer, and a held button drags or selects,// which only the host follows.let Some(plan) = self.plan.hover.take() else {@@ -567,7 +588,14 @@ impl Lane {} else if pointer.buttons != 0 {Err(HoverDeclined::Unmoved("buttons held"))} else {- let hovered = self.hover_with(state, &plan, pointer, timestamp, &mut cursor_hit);+ let hovered = self.hover_with(+ state,+ &plan,+ pointer,+ timestamp,+ frame_time_nanoseconds,+ &mut cursor_hit,+ );// The iframe the hover handed the pointer to before hears that it left, wherever else in the document the// move went.if !matches!(hovered, Err(HoverDeclined::Handed(_) | HoverDeclined::Unplaced(_))) {@@ -636,10 +664,11 @@ impl Lane {plan: &HoverPlan,pointer: PendingPointer,timestamp: f64,+ frame_time_nanoseconds: i64,cursor_hit: &mut Option<CursorHit>,) -> Result<(), HoverDeclined> {let target = match pointer.position {- Some(position) => match self.hit_test(state, plan, position)? {+ Some(position) => match self.hit_test(state, plan, position, frame_time_nanoseconds)? {HoverTarget::Element(hit) => {*cursor_hit = Some(hit);Some(hit.element)@@ -1065,7 +1094,7 @@ impl Lane {}/// Hit tests the preserved frame without copying mutable style and layout state.- pub(super) fn hover_read_only(&mut self, pointer: PendingPointer) -> super::LaneMove {+ pub(super) fn hover_read_only(&mut self, pointer: PendingPointer, frame_time_nanoseconds: i64) -> super::LaneMove {use crate::painting::paint_read::{GeometryRead, PaintSource};if pointer.buttons != 0 {return super::LaneMove {@@ -1092,6 +1121,15 @@ impl Lane {if published.structural_epoch != tree.structural_epoch {return None;}+ // The screen shows the compositor's animations sampled at the frame's time, where the hit test finds them.+ let sampled;+ let tree = match tree.has_visual_animations() {+ true => {+ sampled = tree.with_visual_animation_samples(frame_time_nanoseconds);+ &sampled+ }+ false => tree,+ };let absolute_rects = std::cell::RefCell::default();let source = PaintSource::over_rows(&frame.rows, &absolute_rects);let mut list = HitTestList {@@ -1200,6 +1238,7 @@ impl Lane {state: &mut RenderState,plan: &HoverPlan,position: FloatPoint,+ frame_time_nanoseconds: i64,) -> Result<HoverTarget, HoverDeclined> {// The hit-test list is the one of the frame the lane presented last, which comes back with its recording.let recorder = self.recording.0.take(WaitsForTickRecording(()));@@ -1218,6 +1257,11 @@ impl Lane {if published.structural_epoch != tree.structural_epoch {return Err(HoverDeclined::Unplaced("visual contexts the frame does not show"));}+ // The screen shows the compositor's animations sampled at the frame's time, where the hit test finds them.+ let tree = match tree.has_visual_animations() {+ true => Arc::new(tree.with_visual_animation_samples(frame_time_nanoseconds)),+ false => tree,+ };let mut list = HitTestList {items: std::sync::Arc::clone(&published.items),..HitTestList::default()@@ -1446,6 +1490,26 @@ pub extern "C" fn clock_ticks_pointer_moved(}) as u8}+/// Hands the clock lane `ticks` belong to that the pointer rests where the compositor's animations move what is under+/// it, which the next tick hovers again in the frame as the screen shows it, and answers what the lane wants next, as a+/// `PointerAnswer`.+#[unsafe(no_mangle)]+pub extern "C" fn clock_ticks_pointer_rests_on_moving_content(ticks: &super::ClockTicks) -> u8 {+ ticks.pointer_rests_on_moving_content() as u8+}++/// Hands the clock lanes of `host`'s document that the pointer rests where the compositor's animations move what is+/// under it, ticks them at `frame_time_nanoseconds`, and waits as [`document_host_inject_pointer`] does. For a test.+#[unsafe(no_mangle)]+pub extern "C" fn document_host_inject_pointer_rest(+ host: &crate::render_state::DocumentHost,+ frame_time_nanoseconds: i64,+) {+ super::settle_lanes_for_testing();+ host.clock_ticks().inject_pointer_rest(frame_time_nanoseconds);+ super::settle_lanes_for_testing();+}+/// Hands the clock lanes of `host`'s document a pointer move to `x`, `y` in device pixels, as the compositor would,/// beside the mouse event with the input event id `input_event_id`, or none for 0, which the next tick hovers. For a/// test, whose clock ticks only where it injects them.diff --git a/Libraries/LibWeb/Rust/src/render_state/clock/lane.rs b/Libraries/LibWeb/Rust/src/render_state/clock/lane.rsindex 8406637a799..6dfeaf1af0a 100644--- a/Libraries/LibWeb/Rust/src/render_state/clock/lane.rs+++ b/Libraries/LibWeb/Rust/src/render_state/clock/lane.rs@@ -466,7 +466,7 @@ impl LaneSlot {{if let Some(pointer) = pointer {lane.hovered.go_on_from_nested(self.nested);- self.last_move = Some(lane.hover_read_only(pointer));+ self.last_move = Some(lane.hover_read_only(pointer, self.ticks.latest.load(Ordering::Acquire)));self.nested = lane.hovered.nested();}return;@@ -519,6 +519,11 @@ impl LaneSlot {colors: lane.presented_colors.clone(),compositor_animations: lane.presented_compositor_animations.clone(),};+ // The samples the tick showed may have moved a box under the pointer at rest, or away from under it: the+ // next tick hovers where the pointer rests again, in the frame this tick presented.+ if ticked.sampled {+ let _ = self.ticks.pointer_rests_on_moving_content();+ }}}diff --git a/Services/Compositor/CompositorState.h b/Services/Compositor/CompositorState.hindex 1aa9ce78b8f..ee5c2c06ad4 100644--- a/Services/Compositor/CompositorState.h+++ b/Services/Compositor/CompositorState.h@@ -65,6 +65,7 @@ public:virtual void clock_tick(Web::CompositorContextId, i64 frame_time_nanoseconds, double frame_interval_milliseconds, Vector<Web::CompositorScrollOffset> const& scroll_offsets) = 0;virtual void pointer_moved(Web::CompositorContextId, Web::DevicePixelPoint, u32 /* buttons */, bool /* scrolled_since_frame */, u64 /* input_event_id */) { }virtual void pointer_left(Web::CompositorContextId, u64 /* input_event_id */) { }+ virtual void pointer_rests_on_moving_content(Web::CompositorContextId) { }virtual void async_scroll_updates(Web::CompositorContextId, Compositing::PendingAsyncScrollUpdates const&) = 0;virtual void animated_content_moved_under_pointer(Web::CompositorContextId, i64 /* frame_time_nanoseconds */) { }virtual void overlay_scrollbar_visibilities_changed(Vector<Web::OverlayScrollbarVisibility> const&) { }diff --git a/Services/Compositor/ConnectionFromWebContent.cpp b/Services/Compositor/ConnectionFromWebContent.cppindex da619cf8755..43cc5accf7f 100644--- a/Services/Compositor/ConnectionFromWebContent.cpp+++ b/Services/Compositor/ConnectionFromWebContent.cpp@@ -83,6 +83,12 @@ void ConnectionFromWebContent::pointer_left(Web::CompositorContextId context_id,m_render_clock_connection->async_pointer_left(context_id, input_event_id);}+void ConnectionFromWebContent::pointer_rests_on_moving_content(Web::CompositorContextId context_id)+{+ if (m_render_clock_connection)+ m_render_clock_connection->async_pointer_rests_on_moving_content(context_id);+}+void ConnectionFromWebContent::add_video_sink(Media::VideoSinkHandle video_sink_handle, NonnullRefPtr<Compositing::VideoFramePresentationPage> presentation_page){m_video_frame_holds.add_sink(video_sink_handle, move(presentation_page));diff --git a/Services/Compositor/ConnectionFromWebContent.h b/Services/Compositor/ConnectionFromWebContent.hindex 506b67eb36d..fef654ee53c 100644--- a/Services/Compositor/ConnectionFromWebContent.h+++ b/Services/Compositor/ConnectionFromWebContent.h@@ -102,6 +102,7 @@ private:virtual void clock_tick(Web::CompositorContextId, i64 frame_time_nanoseconds, double frame_interval_milliseconds, Vector<Web::CompositorScrollOffset> const& scroll_offsets) override;virtual void pointer_moved(Web::CompositorContextId, Web::DevicePixelPoint, u32 buttons, bool scrolled_since_frame, u64 input_event_id) override;virtual void pointer_left(Web::CompositorContextId, u64 input_event_id) override;+ virtual void pointer_rests_on_moving_content(Web::CompositorContextId) override;virtual void async_scroll_updates(Web::CompositorContextId, Compositing::PendingAsyncScrollUpdates const&) override;virtual void animated_content_moved_under_pointer(Web::CompositorContextId, i64 frame_time_nanoseconds) override;virtual void overlay_scrollbar_visibilities_changed(Vector<Web::OverlayScrollbarVisibility> const&) override;diff --git a/Services/Compositor/ContextState.cpp b/Services/Compositor/ContextState.cppindex d3c5adec889..95b764a37dd 100644--- a/Services/Compositor/ContextState.cpp+++ b/Services/Compositor/ContextState.cpp@@ -2589,11 +2589,14 @@ bool ContextState::advance_visual_animations(MonotonicTime now){auto animations_are_active = m_scene.advance_visual_animations(now);// The main thread hovers what is under the pointer at rest again as a transform animation moves content under it,- // with the animation sampled at the frame's time, and once more as the content moves away.+ // with the animation sampled at the frame's time, and once more as the content moves away. So does the clock lane+ // of the frame, at its next tick, while the main thread runs a task.auto animated_content_is_under_pointer = animations_are_active && m_pointer_position.has_value()&& m_scene.visual_context_tree_for_compositing().running_transform_animation_covers_point(now.nanoseconds(), *m_pointer_position, m_scroll_state_snapshot);- if (animated_content_is_under_pointer || m_animated_content_was_under_pointer)+ if (animated_content_is_under_pointer || m_animated_content_was_under_pointer) {m_web_content_client.animated_content_moved_under_pointer(m_context_id, now.nanoseconds());+ m_web_content_client.pointer_rests_on_moving_content(m_context_id);+ }m_animated_content_was_under_pointer = animated_content_is_under_pointer;return animations_are_active;}diff --git a/Services/Compositor/RenderClockClient.ipc b/Services/Compositor/RenderClockClient.ipcindex 93ac1c473de..91261ee4839 100644--- a/Services/Compositor/RenderClockClient.ipc+++ b/Services/Compositor/RenderClockClient.ipc@@ -14,4 +14,5 @@ endpoint RenderClockClientpointer_moved(Web::CompositorContextId context_id, Web::DevicePixelPoint position, u32 buttons, bool scrolled_since_frame, u64 input_event_id) =|// The pointer left the context, beside the mouse event with the input event id `input_event_id`.pointer_left(Web::CompositorContextId context_id, u64 input_event_id) =|+ pointer_rests_on_moving_content(Web::CompositorContextId context_id) =|}diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-an-element-whose-animation-it-samples.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-an-element-whose-animation-it-samples.txtindex 584a149f568..2d9d4687f1a 100644--- a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-an-element-whose-animation-it-samples.txt+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-an-element-whose-animation-it-samples.txt@@ -3,5 +3,5 @@ cursor at a move over the box: Crosshairpresented height after the move: 80presented left at 4 s: 200last frame presented by: clock-box matches :hover after the task: true-cursor after the task: Crosshair+box matches :hover after the task: false+cursor after the task: Arrowdiff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-under-a-compositor-animation.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-under-a-compositor-animation.txtnew file mode 100644index 00000000000..4164a316c40--- /dev/null+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-under-a-compositor-animation.txt@@ -0,0 +1,6 @@+at 1 s, after a move beside the box: cursor Arrow, presented height undefined+at 5 s, the box under the pointer: cursor Crosshair, presented height 80+at 9 s, the box away: cursor Arrow, presented height 60+last frame presented by: clock+box matches :hover after the task: false+cursor after the task: Arrowdiff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-under-its-own-layout-animation.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-under-its-own-layout-animation.txtnew file mode 100644index 00000000000..393cf2205d8--- /dev/null+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-under-its-own-layout-animation.txt@@ -0,0 +1,6 @@+at 1 s, after a move beside the box: cursor Arrow, presented height 60+at 3 s, the box under the pointer: cursor Crosshair, presented height 80+at 6 s, the box away: cursor Arrow, presented height 60+last frame presented by: clock+box matches :hover after the task: false+cursor after the task: Arrowdiff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-hovers-an-element-whose-animation-it-samples.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-hovers-an-element-whose-animation-it-samples.htmlindex d9e34f4b101..253fc677868 100644--- a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-hovers-an-element-whose-animation-it-samples.html+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-hovers-an-element-whose-animation-it-samples.html@@ -14,7 +14,7 @@// A box the clock lane moves across the pointer at rest is hovered by the lane as the pointer moves, like any other// box: a hover that changes nothing of the element's animations leaves their plan as it is, so the lane installs the// hover's style itself and keeps sampling the animation over it, and shows the cursor of the box. The host hovers- // the same box afterwards.+ // where the pointer rests afterwards, which the box has left by then.asyncTest(async done => {internals.mouseMove(150, 50);await twoFrames();diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-hovers-under-a-compositor-animation.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-hovers-under-a-compositor-animation.htmlnew file mode 100644index 00000000000..a6507e6abfb--- /dev/null+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-hovers-under-a-compositor-animation.html@@ -0,0 +1,45 @@+<!DOCTYPE html>+<script src="../../include.js"></script>+<script src="frame-in-flight.js"></script>+<style>+ body { margin: 0; }+ #stage { position: relative; width: 400px; height: 150px; }+ #box { position: absolute; left: 100px; top: 20px; width: 100px; height: 60px; cursor: cell; transform: translateX(-300px); }+ #box:hover { height: 80px; }+ #stage.active #box { animation: slide 10s linear infinite; }+ @keyframes slide { from { transform: translateX(-300px); } to { transform: translateX(300px); } }+</style>+<div id="stage"><div id="box"></div></div>+<script>+ // The compositor moves a box across the pointer at rest with a transform animation, and tells the render clock that+ // the pointer rests on moving content. The clock lane hovers where the pointer rests again at its next tick, hit+ // testing the frame with the animation sampled at the tick's time, as the screen shows it: it hovers the box as it+ // covers the pointer, with its cursor, and hovers it no more once it has moved away.+ asyncTest(async done => {+ internals.mouseMove(150, 50);+ await twoFrames();+ const result = await whileLaneAnimates(() => {+ stage.classList.add("active");+ return box.getAnimations()[0];+ }, (frameTime, animation, startTime) => {+ const lines = [];+ // The lane hears of the pointer as the compositor tells it of a move: 1 s in, the box is away from it.+ internals.injectHoverPointer(150, 50, startTime + 1000);+ lines.push(`at 1 s, after a move beside the box: cursor ${internals.currentCursor()}, presented height ${internals.presentedBorderBox(box)?.height}`);+ // 5 s in, the box is translated by 0px: it spans 100..200 by 20..80, under the pointer.+ internals.injectPointerRestsOnMovingContent(startTime + 5000);+ lines.push(`at 5 s, the box under the pointer: cursor ${internals.currentCursor()}, presented height ${internals.presentedBorderBox(box)?.height}`);+ // 9 s in, the box is translated by 240px, away from the pointer.+ internals.injectPointerRestsOnMovingContent(startTime + 9000);+ lines.push(`at 9 s, the box away: cursor ${internals.currentCursor()}, presented height ${internals.presentedBorderBox(box)?.height}`);+ lines.push(`last frame presented by: ${internals.lastFramePresentedBy(document)}`);+ return lines;+ });+ for (const line of result)+ println(line);+ await nextFrame();+ println(`box matches :hover after the task: ${box.matches(":hover")}`);+ println(`cursor after the task: ${internals.currentCursor()}`);+ done();+ });+</script>diff --git a/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-hovers-under-its-own-layout-animation.html b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-hovers-under-its-own-layout-animation.htmlnew file mode 100644index 00000000000..cfef93f9c6e--- /dev/null+++ b/Tests/LibWeb/Text/input/HTML/frame-in-flight/hover-lane-hovers-under-its-own-layout-animation.html@@ -0,0 +1,46 @@+<!DOCTYPE html>+<script src="../../include.js"></script>+<script src="frame-in-flight.js"></script>+<style>+ body { margin: 0; }+ #stage { position: relative; width: 400px; height: 150px; }+ #box { position: absolute; width: 100px; height: 60px; top: 20px; left: -200px; cursor: cell; }+ #box:hover { height: 80px; }+ #stage.active #box { animation: walk 10s linear infinite; }+ @keyframes walk { from { left: -200px; } to { left: 800px; } }+</style>+<div id="stage"><div id="box"></div></div>+<script>+ // The clock lane moves a box across the pointer at rest with a layout animation it samples. A tick that moved a box+ // has the next tick hover where the pointer rests again, in the frame it presented: the lane hovers the box as it+ // covers the pointer, with its cursor, and hovers it no more once it has moved away, with no move of the pointer.+ asyncTest(async done => {+ internals.mouseMove(150, 50);+ await twoFrames();+ const result = await whileLaneAnimates(() => {+ stage.classList.add("active");+ return box.getAnimations()[0];+ }, (frameTime, animation, startTime) => {+ const lines = [];+ // The lane hears of the pointer as the compositor tells it of a move: 1 s in, the box is away from it.+ internals.injectHoverPointer(150, 50, startTime + 1000);+ lines.push(`at 1 s, after a move beside the box: cursor ${internals.currentCursor()}, presented height ${internals.presentedBorderBox(box)?.height}`);+ // 3 s in, the box spans 100..200 by 20..80, under the pointer: the tick after the one that moved it there hovers it.+ internals.injectClockTick(startTime + 3000);+ internals.injectClockTick(startTime + 3016);+ lines.push(`at 3 s, the box under the pointer: cursor ${internals.currentCursor()}, presented height ${internals.presentedBorderBox(box)?.height}`);+ // 6 s in, the box is away again.+ internals.injectClockTick(startTime + 6000);+ internals.injectClockTick(startTime + 6016);+ lines.push(`at 6 s, the box away: cursor ${internals.currentCursor()}, presented height ${internals.presentedBorderBox(box)?.height}`);+ lines.push(`last frame presented by: ${internals.lastFramePresentedBy(document)}`);+ return lines;+ });+ for (const line of result)+ println(line);+ await nextFrame();+ println(`box matches :hover after the task: ${box.matches(":hover")}`);+ println(`cursor after the task: ${internals.currentCursor()}`);+ done();+ });+</script>