mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Synchronize dispatch_actions
in WebDriver (#36932)
Implement missing synchronization in `dispatch_actions` of `WebDriver`. https://w3c.github.io/webdriver/#dispatching-actions > The user agent event loop has spun enough times to process the DOM events generated by the last invocation of the >[dispatch tick actions](https://w3c.github.io/webdriver/#dfn-dispatch-tick-actions) steps. - Add a way for `ScriptThread` to notify `WebDriver` about the completion of input commands. - Add a `webdriver_id` field for `InputEvent`. `ScriptThread` uses it to distinguish WebDriver events and sends notification. Tests: `./mach test-wpt --product servodriver -r tests\wpt\tests\webdriver\tests\classic\element_click\events.py` pass if `hit_testing` pass. Check [issue](https://github.com/servo/servo/issues/36676#issuecomment-2882917136) cc: @xiaochengh --------- Signed-off-by: batu_hoang <longvatrong111@gmail.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
3a527d784b
commit
f52fa9b672
13 changed files with 471 additions and 140 deletions
|
@ -1081,6 +1081,10 @@ impl ScriptThread {
|
|||
for event in document.take_pending_input_events().into_iter() {
|
||||
document.update_active_keyboard_modifiers(event.active_keyboard_modifiers);
|
||||
|
||||
// We do this now, because the event is consumed below, but the order doesn't really
|
||||
// matter as the event will be handled before any new ScriptThread messages are processed.
|
||||
self.notify_webdriver_input_event_completed(pipeline_id, &event.event);
|
||||
|
||||
match event.event {
|
||||
InputEvent::MouseButton(mouse_button_event) => {
|
||||
document.handle_mouse_button_event(
|
||||
|
@ -1144,6 +1148,19 @@ impl ScriptThread {
|
|||
ScriptThread::set_user_interacting(false);
|
||||
}
|
||||
|
||||
fn notify_webdriver_input_event_completed(&self, pipeline_id: PipelineId, event: &InputEvent) {
|
||||
let Some(id) = event.webdriver_message_id() else {
|
||||
return;
|
||||
};
|
||||
|
||||
if let Err(error) = self.senders.pipeline_to_constellation_sender.send((
|
||||
pipeline_id,
|
||||
ScriptToConstellationMessage::WebDriverInputComplete(id),
|
||||
)) {
|
||||
warn!("ScriptThread failed to send WebDriverInputComplete {id:?}: {error:?}",);
|
||||
}
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#update-the-rendering>
|
||||
///
|
||||
/// Attempt to update the rendering and then do a microtask checkpoint if rendering was actually
|
||||
|
@ -3420,7 +3437,7 @@ impl ScriptThread {
|
|||
// the pointer, when the user presses down and releases the primary pointer button"
|
||||
|
||||
// Servo-specific: Trigger if within 10px of the down point
|
||||
if let InputEvent::MouseButton(mouse_button_event) = event.event {
|
||||
if let InputEvent::MouseButton(mouse_button_event) = &event.event {
|
||||
if let MouseButton::Left = mouse_button_event.button {
|
||||
match mouse_button_event.action {
|
||||
MouseButtonAction::Up => {
|
||||
|
@ -3429,16 +3446,23 @@ impl ScriptThread {
|
|||
let pixel_dist =
|
||||
(pixel_dist.x * pixel_dist.x + pixel_dist.y * pixel_dist.y).sqrt();
|
||||
if pixel_dist < 10.0 * document.window().device_pixel_ratio().get() {
|
||||
document.note_pending_input_event(event.clone());
|
||||
// Pass webdriver_id to the newly generated click event
|
||||
document.note_pending_input_event(ConstellationInputEvent {
|
||||
hit_test_result: event.hit_test_result.clone(),
|
||||
pressed_mouse_buttons: event.pressed_mouse_buttons,
|
||||
active_keyboard_modifiers: event.active_keyboard_modifiers,
|
||||
event: event.event.clone().with_webdriver_message_id(None),
|
||||
});
|
||||
document.note_pending_input_event(ConstellationInputEvent {
|
||||
hit_test_result: event.hit_test_result,
|
||||
pressed_mouse_buttons: event.pressed_mouse_buttons,
|
||||
active_keyboard_modifiers: event.active_keyboard_modifiers,
|
||||
event: InputEvent::MouseButton(MouseButtonEvent {
|
||||
action: MouseButtonAction::Click,
|
||||
button: mouse_button_event.button,
|
||||
point: mouse_button_event.point,
|
||||
}),
|
||||
event: InputEvent::MouseButton(MouseButtonEvent::new(
|
||||
MouseButtonAction::Click,
|
||||
mouse_button_event.button,
|
||||
mouse_button_event.point,
|
||||
))
|
||||
.with_webdriver_message_id(event.event.webdriver_message_id()),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue