aboutsummaryrefslogtreecommitdiffstats
path: root/components/msg
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2015-07-10 11:16:27 -0700
committerPatrick Walton <pcwalton@mimiga.net>2015-07-18 12:43:08 -0700
commitb6485a9eafacc29661aa9d0e3cdcd477eefdb66f (patch)
treef35644c31699e771b6b2f646831264e6ae6c2087 /components/msg
parenta0cf597946446c427c54da363fe989ff68db4270 (diff)
downloadservo-b6485a9eafacc29661aa9d0e3cdcd477eefdb66f.tar.gz
servo-b6485a9eafacc29661aa9d0e3cdcd477eefdb66f.zip
compositing: Make the constellation messages serializable.
Diffstat (limited to 'components/msg')
-rw-r--r--components/msg/Cargo.toml11
-rw-r--r--components/msg/constellation_msg.rs33
-rw-r--r--components/msg/webdriver_msg.rs27
3 files changed, 44 insertions, 27 deletions
diff --git a/components/msg/Cargo.toml b/components/msg/Cargo.toml
index fefc32ef5b0..d645bddb58b 100644
--- a/components/msg/Cargo.toml
+++ b/components/msg/Cargo.toml
@@ -21,14 +21,21 @@ git = "https://github.com/servo/rust-layers"
[dependencies.png]
git = "https://github.com/servo/rust-png"
+features = [ "serde-serialization" ]
+
+[dependencies.hyper]
+version = "0.6"
+features = [ "serde-serialization" ]
+
+[dependencies.url]
+version = "0.2.36"
+features = [ "serde_serialization" ]
[dependencies.ipc-channel]
git = "https://github.com/pcwalton/ipc-channel"
[dependencies]
-url = "0.2.35"
bitflags = "*"
-hyper = "0.6"
rustc-serialize = "0.3.4"
euclid = "0.1"
serde = "*"
diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs
index 662e1bed34a..52b883615e5 100644
--- a/components/msg/constellation_msg.rs
+++ b/components/msg/constellation_msg.rs
@@ -6,13 +6,15 @@
//! reduce coupling between these two components.
use compositor_msg::Epoch;
+
use euclid::rect::Rect;
use euclid::size::TypedSize2D;
use euclid::scale_factor::ScaleFactor;
use hyper::header::Headers;
use hyper::method::Method;
+use ipc_channel::ipc::IpcSender;
use layers::geometry::DevicePixel;
-use png;
+use png::Image;
use util::cursor::Cursor;
use util::geometry::{PagePx, ViewportPx};
use std::collections::HashMap;
@@ -31,20 +33,20 @@ impl ConstellationChan {
}
}
-#[derive(PartialEq, Eq, Copy, Clone, Debug)]
+#[derive(PartialEq, Eq, Copy, Clone, Debug, Deserialize, Serialize)]
pub enum IFrameSandboxState {
IFrameSandboxed,
IFrameUnsandboxed
}
// We pass this info to various tasks, so it lives in a separate, cloneable struct.
-#[derive(Clone, Copy)]
+#[derive(Clone, Copy, Deserialize, Serialize)]
pub struct Failure {
pub pipeline_id: PipelineId,
pub parent_info: Option<(PipelineId, SubpageId)>,
}
-#[derive(Copy, Clone)]
+#[derive(Copy, Clone, Deserialize, Serialize)]
pub struct WindowSizeData {
/// The size of the initial layout viewport, before parsing an
/// http://www.w3.org/TR/css-device-adapt/#initial-viewport
@@ -209,6 +211,7 @@ pub enum FocusType {
}
/// Messages from the compositor and script to the constellation.
+#[derive(Deserialize, Serialize)]
pub enum Msg {
Exit,
Failure(Failure),
@@ -234,14 +237,14 @@ pub enum Msg {
TickAnimation(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>>),
+ GetPipeline(Option<FrameId>, IpcSender<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>>),
+ GetFrame(PipelineId, SubpageId, IpcSender<Option<FrameId>>),
/// Notifies the constellation that this frame has received focus.
Focus(PipelineId),
/// Requests that the constellation retrieve the current contents of the clipboard
- GetClipboardContents(Sender<String>),
+ GetClipboardContents(IpcSender<String>),
/// Dispatch a webdriver command
WebDriverCommand(WebDriverCommandMsg),
/// Notifies the constellation that the viewport has been constrained in some manner
@@ -256,7 +259,7 @@ pub enum Msg {
HeadParsed,
}
-#[derive(Clone, Eq, PartialEq)]
+#[derive(Clone, Eq, PartialEq, Deserialize, Serialize)]
pub enum AnimationState {
AnimationsPresent,
AnimationCallbacksPresent,
@@ -265,6 +268,7 @@ pub enum AnimationState {
}
// https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API#Events
+#[derive(Deserialize, Serialize)]
pub enum MozBrowserEvent {
/// Sent when the scroll position within a browser <iframe> changes.
AsyncScroll,
@@ -329,16 +333,17 @@ impl MozBrowserEvent {
}
}
+#[derive(Deserialize, Serialize)]
pub enum WebDriverCommandMsg {
- LoadUrl(PipelineId, LoadData, Sender<LoadStatus>),
+ LoadUrl(PipelineId, LoadData, IpcSender<LoadStatus>),
ScriptCommand(PipelineId, WebDriverScriptCommand),
- TakeScreenshot(PipelineId, Sender<Option<png::Image>>)
+ TakeScreenshot(PipelineId, IpcSender<Option<Image>>)
}
/// Similar to net::resource_task::LoadData
/// can be passed to LoadUrl to load a page with GET/POST
/// parameters or headers
-#[derive(Clone)]
+#[derive(Clone, Deserialize, Serialize)]
pub struct LoadData {
pub url: Url,
pub method: Method,
@@ -357,16 +362,16 @@ impl LoadData {
}
}
-#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug)]
+#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize)]
pub enum NavigationDirection {
Forward,
Back,
}
-#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug)]
+#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize)]
pub struct FrameId(pub u32);
-#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug)]
+#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize)]
pub struct WorkerId(pub u32);
#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize)]
diff --git a/components/msg/webdriver_msg.rs b/components/msg/webdriver_msg.rs
index bc57f58fa28..0c2d8860a96 100644
--- a/components/msg/webdriver_msg.rs
+++ b/components/msg/webdriver_msg.rs
@@ -2,23 +2,25 @@
* 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;
+use ipc_channel::ipc::IpcSender;
+use rustc_serialize::json::{Json, ToJson};
+#[derive(Deserialize, Serialize)]
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>)
+ ExecuteScript(String, IpcSender<WebDriverJSResult>),
+ ExecuteAsyncScript(String, IpcSender<WebDriverJSResult>),
+ FindElementCSS(String, IpcSender<Result<Option<String>, ()>>),
+ FindElementsCSS(String, IpcSender<Result<Vec<String>, ()>>),
+ GetActiveElement(IpcSender<Option<String>>),
+ GetElementTagName(String, IpcSender<Result<String, ()>>),
+ GetElementText(String, IpcSender<Result<String, ()>>),
+ GetFrameId(WebDriverFrameId, IpcSender<Result<Option<(PipelineId, SubpageId)>, ()>>),
+ GetTitle(IpcSender<String>)
}
+#[derive(Deserialize, Serialize)]
pub enum WebDriverJSValue {
Undefined,
Null,
@@ -28,6 +30,7 @@ pub enum WebDriverJSValue {
// TODO: Object and WebElement
}
+#[derive(Deserialize, Serialize)]
pub enum WebDriverJSError {
Timeout,
UnknownType
@@ -35,6 +38,7 @@ pub enum WebDriverJSError {
pub type WebDriverJSResult = Result<WebDriverJSValue, WebDriverJSError>;
+#[derive(Deserialize, Serialize)]
pub enum WebDriverFrameId {
Short(u16),
Element(String),
@@ -53,6 +57,7 @@ impl ToJson for WebDriverJSValue {
}
}
+#[derive(Deserialize, Serialize)]
pub enum LoadStatus {
LoadComplete,
LoadTimeout