diff options
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 4815e6feae1..3ee5bfbd662 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -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; } |