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
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue