aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared/script/script_msg.rs
diff options
context:
space:
mode:
authorBi Fuguo <1782765876@qq.com>2025-02-25 15:13:16 +0800
committerGitHub <noreply@github.com>2025-02-25 07:13:16 +0000
commitf3a8bf8ca20ddfeb843e842e2d1721018cb4b920 (patch)
treea8d55f1fc05e14c4971d2621ed977aff80dff5bc /components/shared/script/script_msg.rs
parent374bfc6983351ef9bd1745d51a13f3a2426a439e (diff)
downloadservo-f3a8bf8ca20ddfeb843e842e2d1721018cb4b920.tar.gz
servo-f3a8bf8ca20ddfeb843e842e2d1721018cb4b920.zip
Touch handler: Fix race condition and rate-limit move events (#35537)
* TouchSequenceInfo is added to store information about a touch sequence. For details about TouchSequenceInfo, see the code comments. The handling_touch_move attribute is added to the TouchHandler, indicating that the script is processing the touch move event. When handling_touch_move is set to true, the touch move event does not need to be sent to the script thread. Signed-off-by: kongbai1996 <1782765876@qq.com> * move touch state, active_touch_point and handling_touch_move to TouchSequenceInfo form TouchHandler. remove TouchSequenceInfo end_sequence property, add Finished state mark sequence end. if preventDefault on touchup, do not prevent Fling. Signed-off-by: kongbai1996 <1782765876@qq.com> * Refactor Touchhandler - Add a newtype wrapper for the TouchSequenceId - Move more state back into the TouchSequenceState - Rename TouchAction to TouchMoveAction, since it only covers immediate actions now. Everything else is handled via state, since it needs to wait on the handler. Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> * Fix test-tidy Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> * Fix clippy missing-default lint Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> * Fix remaining clippy lints Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> * Remove accidental committed test file Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> * Remove wrong todo comment (move events that are sent to script are just raw touchpoints, no merging needed) Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> * Fix preventdefault after long touch_down handler Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> --------- Signed-off-by: kongbai1996 <1782765876@qq.com> Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> Co-authored-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Diffstat (limited to 'components/shared/script/script_msg.rs')
-rw-r--r--components/shared/script/script_msg.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/components/shared/script/script_msg.rs b/components/shared/script/script_msg.rs
index f3f3a417898..9321b623cbd 100644
--- a/components/shared/script/script_msg.rs
+++ b/components/shared/script/script_msg.rs
@@ -14,7 +14,7 @@ use base::Epoch;
use canvas_traits::canvas::{CanvasId, CanvasMsg};
use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId};
use embedder_traits::{
- EmbedderMsg, MediaSessionEvent, TouchAction, TouchEventType, TraversalDirection,
+ EmbedderMsg, MediaSessionEvent, TouchEventType, TouchSequenceId, TraversalDirection,
};
use euclid::default::Size2D as UntypedSize2D;
use euclid::Size2D;
@@ -62,13 +62,13 @@ impl fmt::Debug for LayoutMsg {
}
}
-/// Whether a DOM event was prevented by web content
+/// Whether the default action for a touch event was prevented by web content
#[derive(Debug, Deserialize, Serialize)]
-pub enum EventResult {
+pub enum TouchEventResult {
/// Allowed by web content
- DefaultAllowed(TouchAction),
+ DefaultAllowed(TouchSequenceId, TouchEventType),
/// Prevented by web content
- DefaultPrevented(TouchEventType),
+ DefaultPrevented(TouchSequenceId, TouchEventType),
}
/// A log entry reported to the constellation
@@ -217,7 +217,7 @@ pub enum ScriptMsg {
/// Update the pipeline Url, which can change after redirections.
SetFinalUrl(ServoUrl),
/// Script has handled a touch event, and either prevented or allowed default actions.
- TouchEventProcessed(EventResult),
+ TouchEventProcessed(TouchEventResult),
/// A log entry, with the top-level browsing context id and thread name
LogEntry(Option<String>, LogEntry),
/// Discard the document.