From f594691af99175571db61c4a41203f7fd6723985 Mon Sep 17 00:00:00 2001 From: Bi Fuguo <1782765876@qq.com> Date: Tue, 4 Mar 2025 14:46:25 +0800 Subject: [PATCH] Optimize IPC for non-cancelable touch events (#35785) * The cancelable feature is optimized. If the cancelable feature is a non-cancelable feature, no message is sent back to the Compositor. Add a warning log when prevent TouchsequenceInfo cannot be found. Signed-off-by: kongbai1996 <1782765876@qq.com> * fix Clippy Error Reported in the Pipeline. Signed-off-by: kongbai1996 <1782765876@qq.com> --------- Signed-off-by: kongbai1996 <1782765876@qq.com> --- components/compositing/compositor.rs | 3 ++- components/compositing/touch.rs | 4 ++++ components/script/script_thread.rs | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index bbc391ff609..8bbbe76916f 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -1396,7 +1396,8 @@ impl IOCompositor { if !self .touch_handler .is_handling_touch_move(self.touch_handler.current_sequence_id) && - self.send_touch_event(event) + self.send_touch_event(event) && + event.is_cancelable() { self.touch_handler .set_handling_touch_move(self.touch_handler.current_sequence_id, true); diff --git a/components/compositing/touch.rs b/components/compositing/touch.rs index 4d49b42189f..fb55bab8bb0 100644 --- a/components/compositing/touch.rs +++ b/components/compositing/touch.rs @@ -229,12 +229,16 @@ impl TouchHandler { pub(crate) fn prevent_click(&mut self, sequence_id: TouchSequenceId) { if let Some(sequence) = self.touch_sequence_map.get_mut(&sequence_id) { sequence.prevent_click = true; + } else { + warn!("TouchSequenceInfo corresponding to the sequence number has been deleted."); } } pub(crate) fn prevent_move(&mut self, sequence_id: TouchSequenceId) { if let Some(sequence) = self.touch_sequence_map.get_mut(&sequence_id) { sequence.prevent_move = TouchMoveAllowed::Prevented; + } else { + warn!("TouchSequenceInfo corresponding to the sequence number has been deleted."); } } diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index bdeec8c7160..4a30e58328d 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1095,7 +1095,9 @@ impl ScriptThread { InputEvent::Touch(touch_event) => { let touch_result = document.handle_touch_event(touch_event, event.hit_test_result, can_gc); - if let TouchEventResult::Processed(handled) = touch_result { + if let (TouchEventResult::Processed(handled), true) = + (touch_result, touch_event.is_cancelable()) + { let sequence_id = touch_event.expect_sequence_id(); let result = if handled { script_traits::TouchEventResult::DefaultAllowed(