diff options
Diffstat (limited to 'components/msg')
-rw-r--r-- | components/msg/Cargo.toml | 4 | ||||
-rw-r--r-- | components/msg/constellation_msg.rs | 10 | ||||
-rw-r--r-- | components/msg/lib.rs | 3 | ||||
-rw-r--r-- | components/msg/webdriver_msg.rs | 56 |
4 files changed, 66 insertions, 7 deletions
diff --git a/components/msg/Cargo.toml b/components/msg/Cargo.toml index fa70fe5463e..53d152d60ec 100644 --- a/components/msg/Cargo.toml +++ b/components/msg/Cargo.toml @@ -13,9 +13,6 @@ path = "../style" [dependencies.util] path = "../util" -[dependencies.webdriver_traits] -path = "../webdriver_traits" - [dependencies.azure] git = "https://github.com/servo/rust-azure" @@ -38,3 +35,4 @@ git = "https://github.com/servo/rust-png" url = "0.2.16" bitflags = "*" hyper = "0.4" +rustc-serialize = "0.3.4"
\ No newline at end of file diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index 8706a807cab..6680804c3ef 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -18,8 +18,8 @@ use util::geometry::{PagePx, ViewportPx}; use std::collections::HashMap; use std::sync::mpsc::{channel, Sender, Receiver}; use style::viewport::ViewportConstraints; -use webdriver_traits::{WebDriverScriptCommand, LoadComplete}; use url::Url; +use webdriver_msg::{WebDriverScriptCommand, LoadComplete}; #[derive(Clone)] pub struct ConstellationChan(pub Sender<Msg>); @@ -230,8 +230,12 @@ pub enum Msg { ChangeRunningAnimationsState(PipelineId, AnimationState), /// Requests that the constellation instruct layout to begin a new tick of the animation. TickAnimation(PipelineId), - /// Request that the constellation send the current root pipeline id over a provided channel - GetRootPipeline(Sender<Option<PipelineId>>), + /// Request that the constellation send the current pipeline id for the provided frame + /// id, or for the root frame if this is None, over a provided channel + GetPipeline(Option<FrameId>, Sender<Option<PipelineId>>), + /// Request that the constellation send the FrameId corresponding to the document + /// with the provided parent pipeline id and subpage id + GetFrame(PipelineId, SubpageId, Sender<Option<FrameId>>), /// Notifies the constellation that this frame has received focus. Focus(PipelineId), /// Requests that the constellation retrieve the current contents of the clipboard diff --git a/components/msg/lib.rs b/components/msg/lib.rs index 73c5255ddca..52fa7fe4817 100644 --- a/components/msg/lib.rs +++ b/components/msg/lib.rs @@ -8,10 +8,10 @@ extern crate geom; extern crate hyper; extern crate layers; extern crate png; +extern crate rustc_serialize; extern crate util; extern crate url; extern crate style; -extern crate webdriver_traits; #[cfg(target_os="macos")] extern crate core_foundation; @@ -20,3 +20,4 @@ extern crate io_surface; pub mod compositor_msg; pub mod constellation_msg; +pub mod webdriver_msg; diff --git a/components/msg/webdriver_msg.rs b/components/msg/webdriver_msg.rs new file mode 100644 index 00000000000..7921bb0a156 --- /dev/null +++ b/components/msg/webdriver_msg.rs @@ -0,0 +1,56 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +use rustc_serialize::json::{Json, ToJson}; +use constellation_msg::{PipelineId, SubpageId}; + +use std::sync::mpsc::Sender; + +pub enum WebDriverScriptCommand { + ExecuteScript(String, Sender<WebDriverJSResult>), + ExecuteAsyncScript(String, Sender<WebDriverJSResult>), + FindElementCSS(String, Sender<Result<Option<String>, ()>>), + FindElementsCSS(String, Sender<Result<Vec<String>, ()>>), + GetActiveElement(Sender<Option<String>>), + GetElementTagName(String, Sender<Result<String, ()>>), + GetElementText(String, Sender<Result<String, ()>>), + GetFrameId(WebDriverFrameId, Sender<Result<Option<(PipelineId, SubpageId)>, ()>>), + GetTitle(Sender<String>) +} + +pub enum WebDriverJSValue { + Undefined, + Null, + Boolean(bool), + Number(f64), + String(String), + // TODO: Object and WebElement +} + +pub enum WebDriverJSError { + Timeout, + UnknownType +} + +pub type WebDriverJSResult = Result<WebDriverJSValue, WebDriverJSError>; + +pub enum WebDriverFrameId { + Short(u16), + Element(String), + Parent +} + +impl ToJson for WebDriverJSValue { + fn to_json(&self) -> Json { + match *self { + WebDriverJSValue::Undefined => Json::Null, + WebDriverJSValue::Null => Json::Null, + WebDriverJSValue::Boolean(ref x) => x.to_json(), + WebDriverJSValue::Number(ref x) => x.to_json(), + WebDriverJSValue::String(ref x) => x.to_json() + } + } +} + +pub struct LoadComplete; |