mirror of
https://github.com/servo/servo.git
synced 2025-06-11 01:50:10 +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
|
@ -80,11 +80,10 @@ use script_layout_interface::{
|
|||
node_id_from_scroll_id, LayoutConfig, LayoutFactory, ReflowGoal, ScriptThreadFactory,
|
||||
};
|
||||
use script_traits::{
|
||||
ConstellationInputEvent, DiscardBrowsingContext, DocumentActivity, EventResult,
|
||||
InitialScriptState, JsEvalResult, LoadData, LoadOrigin, NavigationHistoryBehavior,
|
||||
NewLayoutInfo, Painter, ProgressiveWebMetricType, ScriptMsg, ScriptThreadMessage,
|
||||
ScriptToConstellationChan, ScrollState, StructuredSerializedData, UpdatePipelineIdReason,
|
||||
WindowSizeData, WindowSizeType,
|
||||
ConstellationInputEvent, DiscardBrowsingContext, DocumentActivity, InitialScriptState,
|
||||
JsEvalResult, LoadData, LoadOrigin, NavigationHistoryBehavior, NewLayoutInfo, Painter,
|
||||
ProgressiveWebMetricType, ScriptMsg, ScriptThreadMessage, ScriptToConstellationChan,
|
||||
ScrollState, StructuredSerializedData, UpdatePipelineIdReason, WindowSizeData, WindowSizeType,
|
||||
};
|
||||
use servo_atoms::Atom;
|
||||
use servo_config::opts;
|
||||
|
@ -1096,22 +1095,24 @@ impl ScriptThread {
|
|||
InputEvent::Touch(touch_event) => {
|
||||
let touch_result =
|
||||
document.handle_touch_event(touch_event, event.hit_test_result, can_gc);
|
||||
match touch_result {
|
||||
TouchEventResult::Processed(handled) => {
|
||||
let result = if handled {
|
||||
EventResult::DefaultAllowed(touch_event.action)
|
||||
} else {
|
||||
EventResult::DefaultPrevented(touch_event.event_type)
|
||||
};
|
||||
let message = ScriptMsg::TouchEventProcessed(result);
|
||||
self.senders
|
||||
.pipeline_to_constellation_sender
|
||||
.send((pipeline_id, message))
|
||||
.unwrap();
|
||||
},
|
||||
_ => {
|
||||
// TODO: Calling preventDefault on a touchup event should prevent clicks.
|
||||
},
|
||||
if let TouchEventResult::Processed(handled) = touch_result {
|
||||
let sequence_id = touch_event.expect_sequence_id();
|
||||
let result = if handled {
|
||||
script_traits::TouchEventResult::DefaultAllowed(
|
||||
sequence_id,
|
||||
touch_event.event_type,
|
||||
)
|
||||
} else {
|
||||
script_traits::TouchEventResult::DefaultPrevented(
|
||||
sequence_id,
|
||||
touch_event.event_type,
|
||||
)
|
||||
};
|
||||
let message = ScriptMsg::TouchEventProcessed(result);
|
||||
self.senders
|
||||
.pipeline_to_constellation_sender
|
||||
.send((pipeline_id, message))
|
||||
.unwrap();
|
||||
}
|
||||
},
|
||||
InputEvent::Wheel(wheel_event) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue