diff options
Diffstat (limited to 'components/shared/embedder')
-rw-r--r-- | components/shared/embedder/input_events.rs | 56 | ||||
-rw-r--r-- | components/shared/embedder/resources.rs | 4 | ||||
-rw-r--r-- | components/shared/embedder/webdriver.rs | 26 |
3 files changed, 82 insertions, 4 deletions
diff --git a/components/shared/embedder/input_events.rs b/components/shared/embedder/input_events.rs index acaa9afb3ff..869c4eee004 100644 --- a/components/shared/embedder/input_events.rs +++ b/components/shared/embedder/input_events.rs @@ -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. diff --git a/components/shared/embedder/resources.rs b/components/shared/embedder/resources.rs index 830a403698e..28464a95d1a 100644 --- a/components/shared/embedder/resources.rs +++ b/components/shared/embedder/resources.rs @@ -116,7 +116,7 @@ impl Resource { match self { Resource::BluetoothBlocklist => "gatt_blocklist.txt", Resource::DomainList => "public_domains.txt", - Resource::HstsPreloadList => "hsts_preload.json", + Resource::HstsPreloadList => "hsts_preload.fstmap", Resource::BadCertHTML => "badcert.html", Resource::NetErrorHTML => "neterror.html", Resource::RippyPNG => "rippy.png", @@ -155,7 +155,7 @@ fn resources_for_tests() -> Box<dyn ResourceReaderMethods + Sync + Send> { &include_bytes!("../../../resources/public_domains.txt")[..] }, Resource::HstsPreloadList => { - &include_bytes!("../../../resources/hsts_preload.json")[..] + &include_bytes!("../../../resources/hsts_preload.fstmap")[..] }, Resource::BadCertHTML => &include_bytes!("../../../resources/badcert.html")[..], Resource::NetErrorHTML => &include_bytes!("../../../resources/neterror.html")[..], diff --git a/components/shared/embedder/webdriver.rs b/components/shared/embedder/webdriver.rs index 3716a29951a..e7118d32737 100644 --- a/components/shared/embedder/webdriver.rs +++ b/components/shared/embedder/webdriver.rs @@ -24,6 +24,9 @@ use webrender_api::units::DeviceIntSize; use crate::{MouseButton, MouseButtonAction}; +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] +pub struct WebDriverMessageId(pub usize); + /// Messages to the constellation originating from the WebDriver server. #[derive(Debug, Deserialize, Serialize)] pub enum WebDriverCommandMsg { @@ -41,9 +44,23 @@ pub enum WebDriverCommandMsg { /// Act as if keys were pressed or release in the browsing context with the given ID. KeyboardAction(BrowsingContextId, KeyboardEvent), /// Act as if the mouse was clicked in the browsing context with the given ID. - MouseButtonAction(WebViewId, MouseButtonAction, MouseButton, f32, f32), + MouseButtonAction( + WebViewId, + MouseButtonAction, + MouseButton, + f32, + f32, + WebDriverMessageId, + IpcSender<WebDriverCommandResponse>, + ), /// Act as if the mouse was moved in the browsing context with the given ID. - MouseMoveAction(WebViewId, f32, f32), + MouseMoveAction( + WebViewId, + f32, + f32, + WebDriverMessageId, + IpcSender<WebDriverCommandResponse>, + ), /// Act as if the mouse wheel is scrolled in the browsing context given the given ID. WheelScrollAction(WebViewId, f32, f32, f64, f64), /// Set the window size. @@ -189,6 +206,11 @@ pub enum WebDriverFrameId { } #[derive(Debug, Deserialize, Serialize)] +pub struct WebDriverCommandResponse { + pub id: WebDriverMessageId, +} + +#[derive(Debug, Deserialize, Serialize)] pub enum WebDriverLoadStatus { Complete, Timeout, |