From 54bb138ddcbb853acb089c728b14bf5fe6255023 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Mon, 4 Jul 2016 14:03:16 +0200 Subject: [PATCH] Move WebDriverCommandMsg to script_traits. --- components/constellation/constellation.rs | 3 +-- components/msg/constellation_msg.rs | 16 ++----------- components/script_traits/lib.rs | 28 +++++++++++++++++++---- components/webdriver_server/lib.rs | 4 ++-- 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 585fc5372fe..45f41cd82d2 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -24,7 +24,6 @@ use gfx_traits::Epoch; use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::router::ROUTER; use layout_traits::LayoutThreadFactory; -use msg::constellation_msg::WebDriverCommandMsg; use msg::constellation_msg::{FrameId, FrameType, PipelineId}; use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData}; use msg::constellation_msg::{PipelineNamespace, PipelineNamespaceId, NavigationDirection}; @@ -46,7 +45,7 @@ use script_traits::{ConstellationControlMsg, ConstellationMsg as FromCompositorM use script_traits::{DocumentState, LayoutControlMsg}; use script_traits::{IFrameLoadInfo, IFrameSandboxState, TimerEventRequest}; use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, ScriptThreadFactory}; -use script_traits::{MozBrowserEvent, MozBrowserErrorType}; +use script_traits::{MozBrowserEvent, MozBrowserErrorType, WebDriverCommandMsg}; use std::borrow::ToOwned; use std::collections::HashMap; use std::io::Error as IOError; diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index 8d81702c465..5ab9ac75a3b 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -6,16 +6,15 @@ //! reduce coupling between these two components. use euclid::scale_factor::ScaleFactor; -use euclid::size::{Size2D, TypedSize2D}; +use euclid::size::TypedSize2D; use hyper::header::Headers; use hyper::method::Method; -use ipc_channel::ipc::{IpcSender, IpcSharedMemory}; +use ipc_channel::ipc::IpcSharedMemory; use layers::geometry::DevicePixel; use std::cell::Cell; use std::fmt; use url::Url; use util::geometry::{PagePx, ViewportPx}; -use webdriver_msg::{LoadStatus, WebDriverScriptCommand}; use webrender_traits; pub type PanicMsg = (Option, String, String); @@ -186,17 +185,6 @@ bitflags! { } } -#[derive(Deserialize, Serialize)] -pub enum WebDriverCommandMsg { - GetWindowSize(PipelineId, IpcSender), - LoadUrl(PipelineId, LoadData, IpcSender), - Refresh(PipelineId, IpcSender), - ScriptCommand(PipelineId, WebDriverScriptCommand), - SendKeys(PipelineId, Vec<(Key, KeyModifiers, KeyState)>), - SetWindowSize(PipelineId, Size2D, IpcSender), - TakeScreenshot(PipelineId, IpcSender>), -} - #[derive(Clone, Copy, Deserialize, Eq, PartialEq, Serialize, HeapSizeOf)] pub enum PixelFormat { K8, // Luminance channel only diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 5b1b169e8aa..75671dff2ff 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -43,11 +43,10 @@ use gfx_traits::StackingContextId; use heapsize::HeapSizeOf; use ipc_channel::ipc::{IpcReceiver, IpcSender}; use libc::c_void; -use msg::constellation_msg::{FrameId, FrameType, Key, KeyModifiers, KeyState, LoadData}; +use msg::constellation_msg::{FrameId, FrameType, Image, Key, KeyModifiers, KeyState, LoadData}; use msg::constellation_msg::{NavigationDirection, PanicMsg, PipelineId}; -use msg::constellation_msg::{PipelineNamespaceId, SubpageId, WindowSizeData}; -use msg::constellation_msg::{WebDriverCommandMsg, WindowSizeType}; -use msg::webdriver_msg::WebDriverScriptCommand; +use msg::constellation_msg::{PipelineNamespaceId, SubpageId, WindowSizeData, WindowSizeType}; +use msg::webdriver_msg::{LoadStatus, WebDriverScriptCommand}; use net_traits::ResourceThreads; use net_traits::bluetooth_thread::BluetoothMethodMsg; use net_traits::image_cache_thread::ImageCacheThread; @@ -522,6 +521,27 @@ pub struct StackingContextScrollState { pub scroll_offset: Point2D, } +/// Messages to the constellation originating from the WebDriver server. +#[derive(Deserialize, Serialize)] +pub enum WebDriverCommandMsg { + /// Get the window size. + GetWindowSize(PipelineId, IpcSender), + /// Load a URL in the pipeline with the given ID. + LoadUrl(PipelineId, LoadData, IpcSender), + /// Refresh the pipeline with the given ID. + Refresh(PipelineId, IpcSender), + /// Pass a webdriver command to the script thread of the pipeline with the + /// given ID for execution. + ScriptCommand(PipelineId, WebDriverScriptCommand), + /// Act as if keys were pressed in the pipeline with the given ID. + SendKeys(PipelineId, Vec<(Key, KeyModifiers, KeyState)>), + /// Set the window size. + SetWindowSize(PipelineId, Size2D, IpcSender), + /// Take a screenshot of the window, if the pipeline with the given ID is + /// the root pipeline. + TakeScreenshot(PipelineId, IpcSender>), +} + /// Messages to the constellation. #[derive(Deserialize, Serialize)] pub enum ConstellationMsg { diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs index 586bbac1def..39a91e2143b 100644 --- a/components/webdriver_server/lib.rs +++ b/components/webdriver_server/lib.rs @@ -32,13 +32,13 @@ use image::{DynamicImage, ImageFormat, RgbImage}; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use keys::keycodes_to_keys; use msg::constellation_msg::{FrameId, LoadData, PipelineId}; -use msg::constellation_msg::{NavigationDirection, PixelFormat, WebDriverCommandMsg}; +use msg::constellation_msg::{NavigationDirection, PixelFormat}; use msg::webdriver_msg::{LoadStatus, WebDriverCookieError, WebDriverFrameId}; use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult, WebDriverScriptCommand}; use regex::Captures; use rustc_serialize::base64::{CharacterSet, Config, Newline, ToBase64}; use rustc_serialize::json::{Json, ToJson}; -use script_traits::ConstellationMsg; +use script_traits::{ConstellationMsg, WebDriverCommandMsg}; use std::borrow::ToOwned; use std::collections::BTreeMap; use std::net::{SocketAddr, SocketAddrV4};