Truly independent web browser
LibWeb: Hover from the state past an update that paints nothing
Andreas Kling8f1964191284
diff --git a/Libraries/LibWeb/Rust/src/render_state/clock.rs b/Libraries/LibWeb/Rust/src/render_state/clock.rsindex 5593a28821c..3544696b2c2 100644--- a/Libraries/LibWeb/Rust/src/render_state/clock.rs+++ b/Libraries/LibWeb/Rust/src/render_state/clock.rs@@ -363,7 +363,11 @@ pub(crate) struct Lane {pub(crate) enum LaneState {#[default]Shown,- Forked(super::RenderFork),+ Forked {+ fork: super::RenderFork,+ /// Whether the host wrote the state since the lane forked it.+ state_moved_on: bool,+ },MovedOn,}@@ -371,14 +375,40 @@ impl LaneState {/// Forks the render state of `document`, where it still shows the lane's frame.pub(super) fn fork(&mut self, document: DocumentId) {if matches!(self, Self::Shown) {- *self = Self::Forked(super::owner::with_state(document, None, |state| state.fork()));+ *self = Self::Forked {+ fork: super::owner::with_state(document, None, |state| state.fork()),+ state_moved_on: false,+ };}}- /// Notes that the render state no longer shows the lane's frame, where the lane did not fork it.+ /// Notes that the render state no longer shows the lane's frame.pub(super) fn move_on(&mut self) {- if matches!(self, Self::Shown) {- *self = Self::MovedOn;+ match self {+ Self::Shown => *self = Self::MovedOn,+ Self::Forked { state_moved_on, .. } => *state_moved_on = true,+ Self::MovedOn => {}+ }+ }++ /// Notes that a rendering update ended that presents no frame of its own, which leaves the render state showing the+ /// lane's frame, with all the host wrote: the screen and the document have no other state than that. A fork from+ /// before those writes shows what the document no longer is, and goes, for the next tick or the next task's first+ /// write to fork the state again. Answers whether a fork went.+ pub(super) fn rejoin_the_state(&mut self) -> bool {+ match std::mem::take(self) {+ Self::Forked {+ fork,+ state_moved_on: true,+ } => {+ super::owner::drop_after_hold(fork);+ true+ }+ forked @ Self::Forked { .. } => {+ *self = forked;+ false+ }+ Self::Shown | Self::MovedOn => false,}}}@@ -1271,6 +1301,14 @@ impl Lane {self.ticked.is_empty() && self.effects.iter().all(effects::ElementEffects::is_host)}+ /// Has the lane go on from the render state as a rendering update that presents no frame of its own left it, where+ /// no tick showed a sample in a box of its fork. What the hover installed in that fork goes with it.+ fn rejoin_the_state(&mut self) {+ if self.samples_nothing() && self.state.rejoin_the_state() {+ self.hovered.installs.clear();+ }+ }+/// Has the lane follow no plan, as a rendering update that sealed none leaves it: it ticks nothing until the plan of/// a later update that presents no frame of its own.fn unplan(&mut self) {@@ -1315,15 +1353,15 @@ impl Lane {pointer: Option<PendingPointer>,samples_animations: bool,) -> Option<Ticked> {- let mut fork = match std::mem::take(&mut self.state) {- LaneState::Forked(fork) => fork,+ let (mut fork, state_moved_on) = match std::mem::take(&mut self.state) {+ LaneState::Forked { fork, state_moved_on } => (fork, state_moved_on),state => {self.state = state;return None;}};let ticked = self.tick(&mut fork, frame_time_nanoseconds, pointer, samples_animations);- self.state = LaneState::Forked(fork);+ self.state = LaneState::Forked { fork, state_moved_on };Some(ticked)}diff --git a/Libraries/LibWeb/Rust/src/render_state/clock/effects.rs b/Libraries/LibWeb/Rust/src/render_state/clock/effects.rsindex 1c9a4c81953..1d23b5092b0 100644--- a/Libraries/LibWeb/Rust/src/render_state/clock/effects.rs+++ b/Libraries/LibWeb/Rust/src/render_state/clock/effects.rs@@ -198,12 +198,15 @@ impl Lane {.map(ElementEffects::node).collect();if !unplanned.is_empty()- && let super::LaneState::Forked(mut fork) = std::mem::take(&mut self.state)+ && let super::LaneState::Forked {+ mut fork,+ state_moved_on,+ } = std::mem::take(&mut self.state){for &node in &unplanned {self.show_host_styles_of_started(&mut fork, node);}- self.state = super::LaneState::Forked(fork);+ self.state = super::LaneState::Forked { fork, state_moved_on };}self.effects.retain(|effects| !unplanned.contains(&effects.node()) || !effects.is_host());diff --git a/Libraries/LibWeb/Rust/src/render_state/clock/lane.rs b/Libraries/LibWeb/Rust/src/render_state/clock/lane.rsindex 36e5fdc0cdc..fe33258078f 100644--- a/Libraries/LibWeb/Rust/src/render_state/clock/lane.rs+++ b/Libraries/LibWeb/Rust/src/render_state/clock/lane.rs@@ -14,7 +14,8 @@//! was sampled, which the state then still shows: as the first tick that needs it runs, or before the host first writes//! the state, where the pointer moves over the document or a task runs the plan's animations. Until a lane comes//! together, the one before it follows the pointer, whose frames the presenter drops once it presented the newer-//! frame.+//! frame. A rendering update that presents no frame of its own leaves the lane of the frame before it to go on from the+//! state as the update left it: a fork the update's writes passed goes, and the state is forked again.use super::super::owner::{self, DocumentId};use super::{@@ -341,6 +342,10 @@ impl LaneSlot {}match (&mut self.lanes, plan) {(Lanes::Coming { pieces, .. }, plan) => {+ // NB: The frame's own update sealed already, so this one presented no frame of its own.+ if self.taken_in.is_none() && !matches!(pieces.plan, FramePlan::Unsealed) {+ pieces.state.rejoin_the_state();+ }pieces.plan = plan.map_or(FramePlan::None, FramePlan::Sealed);self.come_together();}@@ -348,8 +353,8 @@ impl LaneSlot {(Lanes::Newest(lane), Some(plan)) => {// NB: With no replacement frame, the completed update left the host showing this lane's frame.// Its next tick or the next task's first write can preserve that state then.- if self.taken_in.is_none() && matches!(lane.state, LaneState::MovedOn) && lane.samples_nothing() {- lane.state = LaneState::Shown;+ if self.taken_in.is_none() {+ lane.rejoin_the_state();}lane.replan(plan);}diff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-the-class-a-task-wrote-before-an-update-that-paints-nothing.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-the-class-a-task-wrote-before-an-update-that-paints-nothing.txtindex 3f6764c593d..ff665439b58 100644--- a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-the-class-a-task-wrote-before-an-update-that-paints-nothing.txt+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-the-class-a-task-wrote-before-an-update-that-paints-nothing.txt@@ -1,4 +1,4 @@computed width in the task: 100px-width on screen: 200+width on screen: 300last frame presented by: clockcomputed width: 300pxdiff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-the-class-of-an-update-beside-its-flying-frame.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-the-class-of-an-update-beside-its-flying-frame.txtindex 663c6c9de77..c9e31cc5bdc 100644--- a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-the-class-of-an-update-beside-its-flying-frame.txt+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-the-class-of-an-update-beside-its-flying-frame.txt@@ -1,5 +1,5 @@lane of the flying frame is coming: trueafter the update beside it: true-width on screen: 200+width on screen: 300last frame presented by: clockcomputed width: 300pxdiff --git a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-the-class-written-beside-its-flying-frame.txt b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-the-class-written-beside-its-flying-frame.txtindex 636077c67e6..14add6ced2b 100644--- a/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-the-class-written-beside-its-flying-frame.txt+++ b/Tests/LibWeb/Text/expected/HTML/frame-in-flight/hover-lane-hovers-the-class-written-beside-its-flying-frame.txt@@ -1,5 +1,5 @@lane of the flying frame is coming: truecomputed width beside the frame: 100px-width on screen: 200+width on screen: 300last frame presented by: clockcomputed width: 300px