mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Touch handler: Fix race condition and rate-limit move events (#35537)
* TouchSequenceInfo is added to store information about a touch sequence. For details about TouchSequenceInfo, see the code comments. The handling_touch_move attribute is added to the TouchHandler, indicating that the script is processing the touch move event. When handling_touch_move is set to true, the touch move event does not need to be sent to the script thread. Signed-off-by: kongbai1996 <1782765876@qq.com> * move touch state, active_touch_point and handling_touch_move to TouchSequenceInfo form TouchHandler. remove TouchSequenceInfo end_sequence property, add Finished state mark sequence end. if preventDefault on touchup, do not prevent Fling. Signed-off-by: kongbai1996 <1782765876@qq.com> * Refactor Touchhandler - Add a newtype wrapper for the TouchSequenceId - Move more state back into the TouchSequenceState - Rename TouchAction to TouchMoveAction, since it only covers immediate actions now. Everything else is handled via state, since it needs to wait on the handler. Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> * Fix test-tidy Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> * Fix clippy missing-default lint Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> * Fix remaining clippy lints Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> * Remove accidental committed test file Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> * Remove wrong todo comment (move events that are sent to script are just raw touchpoints, no merging needed) Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> * Fix preventdefault after long touch_down handler Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> --------- Signed-off-by: kongbai1996 <1782765876@qq.com> Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> Co-authored-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
parent
374bfc6983
commit
f3a8bf8ca2
9 changed files with 746 additions and 278 deletions
|
@ -23,8 +23,8 @@ use servo::{
|
|||
InputMethodType, Key, KeyState, KeyboardEvent, LoadStatus, MediaSessionActionType,
|
||||
MediaSessionEvent, MouseButton, MouseButtonAction, MouseButtonEvent, MouseMoveEvent,
|
||||
NavigationRequest, PermissionRequest, PromptDefinition, PromptOrigin, PromptResult,
|
||||
RenderingContext, Servo, ServoDelegate, ServoError, TouchAction, TouchEvent, TouchEventType,
|
||||
TouchId, WebView, WebViewDelegate, WindowRenderingContext,
|
||||
RenderingContext, Servo, ServoDelegate, ServoError, TouchEvent, TouchEventType, TouchId,
|
||||
WebView, WebViewDelegate, WindowRenderingContext,
|
||||
};
|
||||
use url::Url;
|
||||
|
||||
|
@ -378,12 +378,10 @@ impl RunningAppState {
|
|||
/// everytime wakeup is called or when embedder wants Servo
|
||||
/// to act on its pending events.
|
||||
pub fn perform_updates(&self) {
|
||||
debug!("perform_updates");
|
||||
let should_continue = self.servo.spin_event_loop();
|
||||
if !should_continue {
|
||||
self.callbacks.host_callbacks.on_shutdown_complete();
|
||||
}
|
||||
debug!("done perform_updates");
|
||||
}
|
||||
|
||||
/// Load an URL.
|
||||
|
@ -486,48 +484,44 @@ impl RunningAppState {
|
|||
/// Touch event: press down
|
||||
pub fn touch_down(&self, x: f32, y: f32, pointer_id: i32) {
|
||||
self.active_webview()
|
||||
.notify_input_event(InputEvent::Touch(TouchEvent {
|
||||
event_type: TouchEventType::Down,
|
||||
id: TouchId(pointer_id),
|
||||
point: Point2D::new(x, y),
|
||||
action: TouchAction::NoAction,
|
||||
}));
|
||||
.notify_input_event(InputEvent::Touch(TouchEvent::new(
|
||||
TouchEventType::Down,
|
||||
TouchId(pointer_id),
|
||||
Point2D::new(x, y),
|
||||
)));
|
||||
self.perform_updates();
|
||||
}
|
||||
|
||||
/// Touch event: move touching finger
|
||||
pub fn touch_move(&self, x: f32, y: f32, pointer_id: i32) {
|
||||
self.active_webview()
|
||||
.notify_input_event(InputEvent::Touch(TouchEvent {
|
||||
event_type: TouchEventType::Move,
|
||||
id: TouchId(pointer_id),
|
||||
point: Point2D::new(x, y),
|
||||
action: TouchAction::NoAction,
|
||||
}));
|
||||
.notify_input_event(InputEvent::Touch(TouchEvent::new(
|
||||
TouchEventType::Move,
|
||||
TouchId(pointer_id),
|
||||
Point2D::new(x, y),
|
||||
)));
|
||||
self.perform_updates();
|
||||
}
|
||||
|
||||
/// Touch event: Lift touching finger
|
||||
pub fn touch_up(&self, x: f32, y: f32, pointer_id: i32) {
|
||||
self.active_webview()
|
||||
.notify_input_event(InputEvent::Touch(TouchEvent {
|
||||
event_type: TouchEventType::Up,
|
||||
id: TouchId(pointer_id),
|
||||
point: Point2D::new(x, y),
|
||||
action: TouchAction::NoAction,
|
||||
}));
|
||||
.notify_input_event(InputEvent::Touch(TouchEvent::new(
|
||||
TouchEventType::Up,
|
||||
TouchId(pointer_id),
|
||||
Point2D::new(x, y),
|
||||
)));
|
||||
self.perform_updates();
|
||||
}
|
||||
|
||||
/// Cancel touch event
|
||||
pub fn touch_cancel(&self, x: f32, y: f32, pointer_id: i32) {
|
||||
self.active_webview()
|
||||
.notify_input_event(InputEvent::Touch(TouchEvent {
|
||||
event_type: TouchEventType::Cancel,
|
||||
id: TouchId(pointer_id),
|
||||
point: Point2D::new(x, y),
|
||||
action: TouchAction::NoAction,
|
||||
}));
|
||||
.notify_input_event(InputEvent::Touch(TouchEvent::new(
|
||||
TouchEventType::Cancel,
|
||||
TouchId(pointer_id),
|
||||
Point2D::new(x, y),
|
||||
)));
|
||||
self.perform_updates();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue