From b6485a9eafacc29661aa9d0e3cdcd477eefdb66f Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 10 Jul 2015 11:16:27 -0700 Subject: [PATCH] compositing: Make the constellation messages serializable. --- components/compositing/Cargo.toml | 3 +- components/compositing/compositor_task.rs | 4 +- components/compositing/constellation.rs | 10 +- components/devtools/Cargo.toml | 7 +- components/devtools_traits/Cargo.toml | 7 +- components/gfx/Cargo.toml | 2 +- components/layout/Cargo.toml | 2 +- components/layout_traits/Cargo.toml | 2 +- components/msg/Cargo.toml | 11 +- components/msg/constellation_msg.rs | 33 +++--- components/msg/webdriver_msg.rs | 27 +++-- components/net/Cargo.toml | 8 +- components/net_traits/Cargo.toml | 8 +- components/profile_traits/Cargo.toml | 2 +- components/script/Cargo.toml | 10 +- components/script/clipboard_provider.rs | 3 +- components/script/dom/bindings/trace.rs | 9 ++ components/script/dom/window.rs | 7 +- components/script/lib.rs | 1 + components/script/webdriver_handlers.rs | 39 ++++--- components/script_traits/Cargo.toml | 2 +- components/servo/Cargo.lock | 102 +++++++++--------- components/servo/Cargo.toml | 3 +- components/style/Cargo.toml | 2 +- components/style/lib.rs | 1 + components/style/viewport.rs | 2 +- components/util/Cargo.toml | 2 +- components/webdriver_server/Cargo.toml | 6 +- components/webdriver_server/lib.rs | 35 +++--- ports/cef/Cargo.lock | 96 +++++++++-------- ports/gonk/Cargo.lock | 96 +++++++++-------- .../wpt/metadata/url/url-constructor.html.ini | 3 - 32 files changed, 316 insertions(+), 229 deletions(-) diff --git a/components/compositing/Cargo.toml b/components/compositing/Cargo.toml index 0c027195b25..b9fea313f32 100644 --- a/components/compositing/Cargo.toml +++ b/components/compositing/Cargo.toml @@ -48,6 +48,7 @@ git = "https://github.com/servo/rust-layers" [dependencies.png] git = "https://github.com/servo/rust-png" +features = [ "serde-serialization" ] [dependencies.clipboard] git = "https://github.com/aweinstock314/rust-clipboard" @@ -58,7 +59,7 @@ git = "https://github.com/pcwalton/ipc-channel" [dependencies] log = "*" num = "0.1.24" -url = "0.2.35" +url = "0.2.36" time = "0.1.17" libc = "*" gleam = "0.1" diff --git a/components/compositing/compositor_task.rs b/components/compositing/compositor_task.rs index d8ada04bbdf..b9738685f6b 100644 --- a/components/compositing/compositor_task.rs +++ b/components/compositing/compositor_task.rs @@ -13,7 +13,7 @@ use windowing::{WindowEvent, WindowMethods}; use euclid::point::Point2D; use euclid::rect::Rect; -use ipc_channel::ipc::IpcReceiver; +use ipc_channel::ipc::{IpcReceiver, IpcSender}; use layers::platform::surface::NativeDisplay; use layers::layers::{BufferRequest, LayerBuffer, LayerBufferSet}; use msg::compositor_msg::{Epoch, LayerId, LayerProperties, FrameTreeId}; @@ -183,7 +183,7 @@ pub enum Msg { /// Changes the cursor. SetCursor(Cursor), /// Composite to a PNG file and return the Image over a passed channel. - CreatePng(Sender>), + CreatePng(IpcSender>), /// Informs the compositor that the paint task for the given pipeline has exited. PaintTaskExited(PipelineId), /// Alerts the compositor that the viewport has been constrained in some manner diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index b7498ccf843..7dd06342790 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -19,7 +19,7 @@ use euclid::rect::{Rect, TypedRect}; use euclid::size::Size2D; use euclid::scale_factor::ScaleFactor; use gfx::font_cache_task::FontCacheTask; -use ipc_channel::ipc; +use ipc_channel::ipc::{self, IpcSender}; use layout_traits::{LayoutControlChan, LayoutTaskFactory}; use libc; use msg::compositor_msg::{Epoch, LayerId}; @@ -44,7 +44,7 @@ use std::collections::HashMap; use std::io::{self, Write}; use std::marker::PhantomData; use std::mem::replace; -use std::sync::mpsc::{Sender, Receiver, channel}; +use std::sync::mpsc::{Receiver, channel}; use style::viewport::ViewportConstraints; use url::Url; use util::cursor::Cursor; @@ -191,7 +191,7 @@ pub struct SendableFrameTree { } struct WebDriverData { - load_channel: Option<(PipelineId, Sender)> + load_channel: Option<(PipelineId, IpcSender)> } impl WebDriverData { @@ -849,7 +849,7 @@ impl Constellation { } fn handle_get_pipeline(&mut self, frame_id: Option, - resp_chan: Sender>) { + resp_chan: IpcSender>) { let current_pipeline_id = frame_id.or(self.root_frame_id).map(|frame_id| { let frame = self.frames.get(&frame_id).unwrap(); frame.current @@ -863,7 +863,7 @@ impl Constellation { fn handle_get_frame(&mut self, containing_pipeline_id: PipelineId, subpage_id: SubpageId, - resp_chan: Sender>) { + resp_chan: IpcSender>) { let frame_id = self.subpage_map.get(&(containing_pipeline_id, subpage_id)).and_then( |x| self.pipeline_to_frame_map.get(&x)).map(|x| *x); resp_chan.send(frame_id).unwrap(); diff --git a/components/devtools/Cargo.toml b/components/devtools/Cargo.toml index 63cba3ccfe3..ac16535dcd8 100644 --- a/components/devtools/Cargo.toml +++ b/components/devtools/Cargo.toml @@ -7,6 +7,10 @@ authors = ["The Servo Project Developers"] name = "devtools" path = "lib.rs" +[dependencies.hyper] +version = "0.6" +features = [ "serde-serialization" ] + [dependencies.devtools_traits] path = "../devtools_traits" @@ -20,5 +24,4 @@ path = "../util" log = "*" time = "*" rustc-serialize = "0.3" -url = "*" -hyper = "0.6" +url = "0.2" diff --git a/components/devtools_traits/Cargo.toml b/components/devtools_traits/Cargo.toml index 9cdd5d1311a..1dc3cfdc4a1 100644 --- a/components/devtools_traits/Cargo.toml +++ b/components/devtools_traits/Cargo.toml @@ -7,6 +7,10 @@ authors = ["The Servo Project Developers"] name = "devtools_traits" path = "lib.rs" +[dependencies.hyper] +version = "0.6" +features = [ "serde-serialization" ] + [dependencies.msg] path = "../msg" @@ -16,6 +20,5 @@ path = "../util" [dependencies] time = "*" rustc-serialize = "0.3" -url = "*" -hyper = "0.6" +url = "0.2" bitflags = "*" diff --git a/components/gfx/Cargo.toml b/components/gfx/Cargo.toml index b0376d7e335..eaf53aac46b 100644 --- a/components/gfx/Cargo.toml +++ b/components/gfx/Cargo.toml @@ -47,7 +47,7 @@ path = "../script_traits" [dependencies] log = "*" fnv = "1.0" -url = "0.2.35" +url = "0.2.36" time = "0.1.12" bitflags = "*" rustc-serialize = "0.3" diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index 5feddfb72eb..526c1f73a7f 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -62,7 +62,7 @@ git = "https://github.com/pcwalton/ipc-channel" log = "*" encoding = "0.2" fnv = "1.0" -url = "0.2.35" +url = "0.2.36" bitflags = "*" rustc-serialize = "0.3" libc = "*" diff --git a/components/layout_traits/Cargo.toml b/components/layout_traits/Cargo.toml index 94f3b9d0498..e7b0c54d998 100644 --- a/components/layout_traits/Cargo.toml +++ b/components/layout_traits/Cargo.toml @@ -29,7 +29,7 @@ path = "../util" git = "https://github.com/pcwalton/ipc-channel" [dependencies] -url = "0.2.35" +url = "0.2.36" euclid = "0.1" serde = "*" serde_macros = "*" 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, Sender>), + GetPipeline(Option, IpcSender>), /// Request that the constellation send the FrameId corresponding to the document /// with the provided parent pipeline id and subpage id - GetFrame(PipelineId, SubpageId, Sender>), + GetFrame(PipelineId, SubpageId, IpcSender>), /// Notifies the constellation that this frame has received focus. Focus(PipelineId), /// Requests that the constellation retrieve the current contents of the clipboard - GetClipboardContents(Sender), + GetClipboardContents(IpcSender), /// 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