diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 9bb58649088..671a4cb2b63 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -1396,7 +1396,7 @@ impl IOCompositor { self.send_touch_event(event); } - fn on_touch_move(&mut self, event: TouchEvent) { + fn on_touch_move(&mut self, mut event: TouchEvent) { let action: TouchMoveAction = self.touch_handler.on_touch_move(event.id, event.point); if TouchMoveAction::NoAction != action { // if first move processed and allowed, we directly process the move event, @@ -1405,6 +1405,8 @@ impl IOCompositor { .touch_handler .move_allowed(self.touch_handler.current_sequence_id) { + // https://w3c.github.io/touch-events/#cancelability + event.disable_cancelable(); match action { TouchMoveAction::Scroll(delta, point) => self.on_scroll_window_event( ScrollLocation::Delta(LayoutVector2D::from_untyped(delta.to_untyped())), diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 859bab01496..a1b6b8cd04b 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -2090,7 +2090,7 @@ impl Document { window, DOMString::from(event_name), EventBubbles::Bubbles, - EventCancelable::Cancelable, + EventCancelable::from(event.is_cancelable()), Some(window), 0i32, &touches, diff --git a/components/shared/embedder/input_events.rs b/components/shared/embedder/input_events.rs index 2775ac88c5f..0268be6dd9c 100644 --- a/components/shared/embedder/input_events.rs +++ b/components/shared/embedder/input_events.rs @@ -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, } @@ -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