mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
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>
This commit is contained in:
parent
6dce329acc
commit
3fe42a0b5a
12 changed files with 273 additions and 255 deletions
|
@ -26,7 +26,7 @@ use devtools_traits::ScriptToDevtoolsControlMsg;
|
|||
use dom_struct::dom_struct;
|
||||
use embedder_traits::{
|
||||
AllowOrDeny, ContextMenuResult, EditingActionEvent, EmbedderMsg, ImeEvent, InputEvent,
|
||||
LoadStatus, MouseButton, MouseButtonAction, MouseButtonEvent, TouchEvent, TouchEventAction,
|
||||
LoadStatus, MouseButton, MouseButtonAction, MouseButtonEvent, TouchEvent, TouchEventType,
|
||||
TouchId, WheelEvent,
|
||||
};
|
||||
use encoding_rs::{Encoding, UTF_8};
|
||||
|
@ -2013,11 +2013,11 @@ impl Document {
|
|||
};
|
||||
|
||||
let TouchId(identifier) = event.id;
|
||||
let event_name = match event.action {
|
||||
TouchEventAction::Down => "touchstart",
|
||||
TouchEventAction::Move => "touchmove",
|
||||
TouchEventAction::Up => "touchend",
|
||||
TouchEventAction::Cancel => "touchcancel",
|
||||
let event_name = match event.event_type {
|
||||
TouchEventType::Down => "touchstart",
|
||||
TouchEventType::Move => "touchmove",
|
||||
TouchEventType::Up => "touchend",
|
||||
TouchEventType::Cancel => "touchcancel",
|
||||
};
|
||||
|
||||
let node = unsafe { node::from_untrusted_compositor_node_address(hit_test_result.node) };
|
||||
|
@ -2043,14 +2043,14 @@ impl Document {
|
|||
client_x, client_y, page_x, page_y,
|
||||
);
|
||||
|
||||
match event.action {
|
||||
TouchEventAction::Down => {
|
||||
match event.event_type {
|
||||
TouchEventType::Down => {
|
||||
// Add a new touch point
|
||||
self.active_touch_points
|
||||
.borrow_mut()
|
||||
.push(Dom::from_ref(&*touch));
|
||||
},
|
||||
TouchEventAction::Move => {
|
||||
TouchEventType::Move => {
|
||||
// Replace an existing touch point
|
||||
let mut active_touch_points = self.active_touch_points.borrow_mut();
|
||||
match active_touch_points
|
||||
|
@ -2061,7 +2061,7 @@ impl Document {
|
|||
None => warn!("Got a touchmove event for a non-active touch point"),
|
||||
}
|
||||
},
|
||||
TouchEventAction::Up | TouchEventAction::Cancel => {
|
||||
TouchEventType::Up | TouchEventType::Cancel => {
|
||||
// Remove an existing touch point
|
||||
let mut active_touch_points = self.active_touch_points.borrow_mut();
|
||||
match active_touch_points
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue