add cancelable property to the TouchEvent (#35713)

* add `cancelable` property to the `TouchEvent`
set cancellable = false when sending move events to script, if the first touch_move event did not cancel it

Signed-off-by: kongbai1996 <1782765876@qq.com>

* modified review commentss

Signed-off-by: kongbai1996 <1782765876@qq.com>

---------

Signed-off-by: kongbai1996 <1782765876@qq.com>
This commit is contained in:
Bi Fuguo 2025-03-02 16:12:26 +08:00 committed by GitHub
parent 67bd557f30
commit 929f87f598
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 2 deletions

View file

@ -147,6 +147,8 @@ pub struct TouchEvent {
pub event_type: TouchEventType,
pub id: TouchId,
pub point: DevicePoint,
/// cancelable default value is true, once the first move has been processed by script disable it.
cancelable: bool,
/// The sequence_id will be set by servo's touch handler.
sequence_id: Option<TouchSequenceId>,
}
@ -158,6 +160,7 @@ impl TouchEvent {
id,
point,
sequence_id: None,
cancelable: true,
}
}
/// Embedders should ignore this.
@ -175,6 +178,16 @@ impl TouchEvent {
pub fn expect_sequence_id(&self) -> TouchSequenceId {
self.sequence_id.expect("Sequence ID not initialized")
}
#[doc(hidden)]
pub fn disable_cancelable(&mut self) {
self.cancelable = false;
}
#[doc(hidden)]
pub fn is_cancelable(&self) -> bool {
self.cancelable
}
}
/// Mode to measure WheelDelta floats in