mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01: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
|
@ -8,6 +8,8 @@ use malloc_size_of_derive::MallocSizeOf;
|
|||
use serde::{Deserialize, Serialize};
|
||||
use webrender_api::units::DevicePoint;
|
||||
|
||||
use crate::WebDriverMessageId;
|
||||
|
||||
/// An input event that is sent from the embedder to Servo.
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub enum InputEvent {
|
||||
|
@ -42,6 +44,38 @@ impl InputEvent {
|
|||
InputEvent::Wheel(event) => Some(event.point),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn webdriver_message_id(&self) -> Option<WebDriverMessageId> {
|
||||
match self {
|
||||
InputEvent::EditingAction(..) => None,
|
||||
InputEvent::Gamepad(..) => None,
|
||||
InputEvent::Ime(..) => None,
|
||||
InputEvent::Keyboard(..) => None,
|
||||
InputEvent::MouseButton(event) => event.webdriver_id,
|
||||
InputEvent::MouseMove(event) => event.webdriver_id,
|
||||
InputEvent::Touch(..) => None,
|
||||
InputEvent::Wheel(..) => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_webdriver_message_id(self, webdriver_id: Option<WebDriverMessageId>) -> Self {
|
||||
match self {
|
||||
InputEvent::EditingAction(..) => {},
|
||||
InputEvent::Gamepad(..) => {},
|
||||
InputEvent::Ime(..) => {},
|
||||
InputEvent::Keyboard(..) => {},
|
||||
InputEvent::MouseButton(mut event) => {
|
||||
event.webdriver_id = webdriver_id;
|
||||
},
|
||||
InputEvent::MouseMove(mut event) => {
|
||||
event.webdriver_id = webdriver_id;
|
||||
},
|
||||
InputEvent::Touch(..) => {},
|
||||
InputEvent::Wheel(..) => {},
|
||||
};
|
||||
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||
|
@ -49,6 +83,18 @@ pub struct MouseButtonEvent {
|
|||
pub action: MouseButtonAction,
|
||||
pub button: MouseButton,
|
||||
pub point: DevicePoint,
|
||||
webdriver_id: Option<WebDriverMessageId>,
|
||||
}
|
||||
|
||||
impl MouseButtonEvent {
|
||||
pub fn new(action: MouseButtonAction, button: MouseButton, point: DevicePoint) -> Self {
|
||||
Self {
|
||||
action,
|
||||
button,
|
||||
point,
|
||||
webdriver_id: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||
|
@ -102,6 +148,16 @@ pub enum MouseButtonAction {
|
|||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||
pub struct MouseMoveEvent {
|
||||
pub point: DevicePoint,
|
||||
webdriver_id: Option<WebDriverMessageId>,
|
||||
}
|
||||
|
||||
impl MouseMoveEvent {
|
||||
pub fn new(point: DevicePoint) -> Self {
|
||||
Self {
|
||||
point,
|
||||
webdriver_id: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The type of input represented by a multi-touch event.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue