diff options
author | Bi Fuguo <1782765876@qq.com> | 2025-02-17 18:50:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-17 10:50:04 +0000 |
commit | 3fe42a0b5aa08101d4f9151a0be33e6d5cb03535 (patch) | |
tree | a3f38206d9c3382b533250778aa945d8a05bbda9 /components/script/script_thread.rs | |
parent | 6dce329acc67ee55b2a640add7791ace0be0180d (diff) | |
download | servo-3fe42a0b5aa08101d4f9151a0be33e6d5cb03535.tar.gz servo-3fe42a0b5aa08101d4f9151a0be33e6d5cb03535.zip |
implement Touchevent prevent default behavior (#35031)
* implement Touchevent prevent default behavior
* The status change logic of the `TouchHandler` is changed.
> The `WaitingForScript` state is canceled. TouchAction can be identified
based on the current touch type and numbers if touch points.
* Sends current event to script thread along with recognized `TouchAction`.
> After dispatch event, script thread sends a `TouchEventProcess(EventResult)`
message to main thread. If the event is set to `DefaultAllowed`, the
corresponding `TouchAction` information is added.
* After receiving `DefaultAllowed(TouchAction)` message, main thread executes corresponding action.
> `DefaultPrevented(TouchEventType)` is received. Use `prevent_click` to mark
that the default `Click` is blocked, and `prevent_move` to mark that the
default `Scroll` and `Zoom` are blocked. In this way, all TouchActions
implement preventDefault.
Signed-off-by: Bi Fuguo <1782765876@qq.com>
* fix some suggestions
* support preventDefault fling
* move `TouchAction` to share touch directory
* check preventDefault everytime when touch
* fix zoom ineffective
Signed-off-by: Bi Fuguo <1782765876@qq.com>
* fix some suggestions
rename on_event_processed to on_touch_event_processed
clear unused features
Signed-off-by: Bi Fuguo <1782765876@qq.com>
* Optimizes pan performance by continuously sliding without waiting for the eventhandler.
Signed-off-by: kongbai1996 <1782765876@qq.com>
* resolve conflict
Signed-off-by: kongbai1996 <1782765876@qq.com>
---------
Signed-off-by: Bi Fuguo <1782765876@qq.com>
Signed-off-by: kongbai1996 <1782765876@qq.com>
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 58043823088..8992b457f0f 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -45,7 +45,7 @@ use devtools_traits::{ CSSError, DevtoolScriptControlMsg, DevtoolsPageInfo, NavigationState, ScriptToDevtoolsControlMsg, WorkerId, }; -use embedder_traits::{EmbedderMsg, InputEvent, MediaSessionActionType, Theme, TouchEventAction}; +use embedder_traits::{EmbedderMsg, InputEvent, MediaSessionActionType, Theme}; use euclid::default::Rect; use fonts::{FontContext, SystemFontServiceProxy}; use headers::{HeaderMapExt, LastModified, ReferrerPolicy as ReferrerPolicyHeader}; @@ -1101,13 +1101,12 @@ impl ScriptThread { InputEvent::Touch(touch_event) => { let touch_result = document.handle_touch_event(touch_event, event.hit_test_result, can_gc); - match (touch_event.action, touch_result) { - (TouchEventAction::Down, TouchEventResult::Processed(handled)) => { + match touch_result { + TouchEventResult::Processed(handled) => { let result = if handled { - // TODO: Wait to see if preventDefault is called on the first touchmove event. - EventResult::DefaultAllowed + EventResult::DefaultAllowed(touch_event.action) } else { - EventResult::DefaultPrevented + EventResult::DefaultPrevented(touch_event.event_type) }; let message = ScriptMsg::TouchEventProcessed(result); self.senders |