servo: Merge #11364 - Move CompositorMsg to script_traits (from Ms2ger:CompositorMsg); r=nox
authorMs2ger <Ms2ger@gmail.com>
Tue, 24 May 2016 06:48:46 -0700
changeset 338892 c1f26391396ed3fcedb9b654c162a59ddcf5df83
parent 338891 30769cfe07cc0ae03ac873a5b69ac4aa25356175
child 338893 069b529edd2aeddf68a9e7f8b0d5ee116e3ce29e
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnox
servo: Merge #11364 - Move CompositorMsg to script_traits (from Ms2ger:CompositorMsg); r=nox Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy --faster` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). Either: - [ ] There are tests for these changes OR - [x] These changes do not require tests because refactoring Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. Source-Repo: https://github.com/servo/servo Source-Revision: cd1396fa9ae72bebf13115ed0d752fb21ce0df19
servo/components/compositing/compositor.rs
servo/components/compositing/compositor_thread.rs
servo/components/compositing/lib.rs
servo/components/constellation/constellation.rs
servo/components/script_traits/lib.rs
servo/components/servo/Cargo.lock
servo/components/servo/lib.rs
servo/components/webdriver_server/Cargo.toml
servo/components/webdriver_server/lib.rs
servo/ports/cef/Cargo.lock
--- a/servo/components/compositing/compositor.rs
+++ b/servo/components/compositing/compositor.rs
@@ -1,15 +1,13 @@
 /* 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 AnimationTickType;
 use CompositionPipeline;
-use CompositorMsg as ConstellationMsg;
 use SendableFrameTree;
 use app_units::Au;
 use compositor_layer::{CompositorData, CompositorLayer, RcCompositorLayer, WantsScrollEventsFlag};
 use compositor_thread::{CompositorEventListener, CompositorProxy};
 use compositor_thread::{CompositorReceiver, InitialCompositorState, Msg, RenderListener};
 use delayed_composition::DelayedCompositionTimerProxy;
 use euclid::point::TypedPoint2D;
 use euclid::rect::TypedRect;
@@ -32,18 +30,19 @@ use layers::scene::Scene;
 use layout_traits::{ConvertPipelineIdToWebRender, LayoutControlChan};
 use msg::constellation_msg::{Image, PixelFormat};
 use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData};
 use msg::constellation_msg::{NavigationDirection, PipelineId, PipelineIndex, PipelineNamespaceId};
 use msg::constellation_msg::{WindowSizeData, WindowSizeType};
 use profile_traits::mem::{self, ReportKind, Reporter, ReporterRequest};
 use profile_traits::time::{self, ProfilerCategory, profile};
 use script_traits::CompositorEvent::{MouseMoveEvent, MouseButtonEvent, TouchEvent};
-use script_traits::{AnimationState, ConstellationControlMsg, LayoutControlMsg};
-use script_traits::{MouseButton, MouseEventType, TouchpadPressurePhase, TouchEventType, TouchId};
+use script_traits::{AnimationState, AnimationTickType, ConstellationControlMsg};
+use script_traits::{ConstellationMsg, LayoutControlMsg, MouseButton};
+use script_traits::{MouseEventType, TouchpadPressurePhase, TouchEventType, TouchId};
 use std::collections::hash_map::Entry::{Occupied, Vacant};
 use std::collections::{HashMap, HashSet};
 use std::fs::File;
 use std::mem as std_mem;
 use std::rc::Rc;
 use std::sync::mpsc::Sender;
 use style_traits::viewport::ViewportConstraints;
 use surface_map::SurfaceMap;
--- a/servo/components/compositing/compositor_thread.rs
+++ b/servo/components/compositing/compositor_thread.rs
@@ -1,27 +1,26 @@
 /* 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/. */
 
 //! Communication with the compositor thread.
 
-use CompositorMsg as ConstellationMsg;
 use SendableFrameTree;
 use compositor::{self, CompositingReason};
 use euclid::point::Point2D;
 use euclid::size::Size2D;
 use gfx_traits::{Epoch, FrameTreeId, LayerId, LayerProperties, PaintListener};
 use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
 use layers::layers::{BufferRequest, LayerBufferSet};
 use layers::platform::surface::{NativeDisplay, NativeSurface};
 use msg::constellation_msg::{Image, Key, KeyModifiers, KeyState, PipelineId};
 use profile_traits::mem;
 use profile_traits::time;
-use script_traits::{AnimationState, EventResult, ScriptToCompositorMsg};
+use script_traits::{AnimationState, ConstellationMsg, EventResult, ScriptToCompositorMsg};
 use std::fmt::{Debug, Error, Formatter};
 use std::rc::Rc;
 use std::sync::mpsc::{Receiver, Sender, channel};
 use style_traits::cursor::Cursor;
 use style_traits::viewport::ViewportConstraints;
 use url::Url;
 use webrender;
 use webrender_traits;
--- a/servo/components/compositing/lib.rs
+++ b/servo/components/compositing/lib.rs
@@ -24,83 +24,42 @@ extern crate layers;
 extern crate layout_traits;
 #[macro_use]
 extern crate log;
 extern crate msg;
 extern crate net_traits;
 #[macro_use]
 extern crate profile_traits;
 extern crate script_traits;
-extern crate serde;
 extern crate style_traits;
 extern crate time;
 extern crate url;
 #[macro_use]
 extern crate util;
 extern crate webrender;
 extern crate webrender_traits;
 
 pub use compositor_thread::{CompositorEventListener, CompositorProxy, CompositorThread};
-use euclid::size::{Size2D, TypedSize2D};
+use euclid::size::TypedSize2D;
 use gfx::paint_thread::ChromeToPaintMsg;
-use gfx_traits::Epoch;
 use ipc_channel::ipc::{IpcSender};
 use layout_traits::LayoutControlChan;
-use msg::constellation_msg::{FrameId, Key, KeyState, KeyModifiers, LoadData};
-use msg::constellation_msg::{NavigationDirection, PipelineId, SubpageId};
-use msg::constellation_msg::{WebDriverCommandMsg, WindowSizeData, WindowSizeType};
+use msg::constellation_msg::PipelineId;
 use script_traits::ConstellationControlMsg;
-use std::collections::HashMap;
 use std::sync::mpsc::Sender;
-use url::Url;
 use util::geometry::PagePx;
 
 mod compositor;
 mod compositor_layer;
 pub mod compositor_thread;
 mod delayed_composition;
 mod surface_map;
 mod touch;
 pub mod windowing;
 
-/// Specifies whether the script or layout thread needs to be ticked for animation.
-#[derive(Deserialize, Serialize)]
-pub enum AnimationTickType {
-    Script,
-    Layout,
-}
-
-/// Messages from the compositor to the constellation.
-#[derive(Deserialize, Serialize)]
-pub enum CompositorMsg {
-    Exit,
-    FrameSize(PipelineId, Size2D<f32>),
-    /// Request that the constellation send the FrameId corresponding to the document
-    /// with the provided pipeline id
-    GetFrame(PipelineId, IpcSender<Option<FrameId>>),
-    /// 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.
-    /// Also returns a boolean saying whether the document has finished loading or not.
-    GetPipeline(Option<FrameId>, IpcSender<Option<(PipelineId, bool)>>),
-    /// Requests that the constellation inform the compositor of the title of the pipeline
-    /// immediately.
-    GetPipelineTitle(PipelineId),
-    InitLoadUrl(Url),
-    /// Query the constellation to see if the current compositor output is stable
-    IsReadyToSaveImage(HashMap<PipelineId, Epoch>),
-    KeyEvent(Key, KeyState, KeyModifiers),
-    LoadUrl(PipelineId, LoadData),
-    Navigate(Option<(PipelineId, SubpageId)>, NavigationDirection),
-    WindowSize(WindowSizeData, WindowSizeType),
-    /// Requests that the constellation instruct layout to begin a new tick of the animation.
-    TickAnimation(PipelineId, AnimationTickType),
-    /// Dispatch a webdriver command
-    WebDriverCommand(WebDriverCommandMsg),
-}
-
 pub struct SendableFrameTree {
     pub pipeline: CompositionPipeline,
     pub size: Option<TypedSize2D<PagePx, f32>>,
     pub children: Vec<SendableFrameTree>,
 }
 
 /// The subset of the pipeline that is needed for layer composition.
 #[derive(Clone)]
--- a/servo/components/constellation/constellation.rs
+++ b/servo/components/constellation/constellation.rs
@@ -8,20 +8,19 @@
 //! graphics compositor and the many `Pipeline`s in the browser's
 //! navigation context, each `Pipeline` encompassing a `ScriptThread`,
 //! `LayoutThread`, and `PaintThread`.
 
 use canvas::canvas_paint_thread::CanvasPaintThread;
 use canvas::webgl_paint_thread::WebGLPaintThread;
 use canvas_traits::CanvasMsg;
 use clipboard::ClipboardContext;
-use compositing::CompositorMsg as FromCompositorMsg;
+use compositing::SendableFrameTree;
 use compositing::compositor_thread::CompositorProxy;
 use compositing::compositor_thread::Msg as ToCompositorMsg;
-use compositing::{AnimationTickType, SendableFrameTree};
 use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg};
 use euclid::scale_factor::ScaleFactor;
 use euclid::size::{Size2D, TypedSize2D};
 #[cfg(not(target_os = "windows"))]
 use gaol;
 #[cfg(not(target_os = "windows"))]
 use gaol::sandbox::{self, Sandbox, SandboxMethods};
 use gfx::font_cache_thread::FontCacheThread;
@@ -44,17 +43,18 @@ use net_traits::storage_thread::StorageT
 use net_traits::{self, ResourceThreads, IpcSend};
 use offscreen_gl_context::{GLContextAttributes, GLLimits};
 use pipeline::{InitialPipelineState, Pipeline, UnprivilegedPipelineContent};
 use profile_traits::mem;
 use profile_traits::time;
 use rand::{random, Rng, SeedableRng, StdRng};
 #[cfg(not(target_os = "windows"))]
 use sandboxing::content_process_sandbox_profile;
-use script_traits::{AnimationState, CompositorEvent, ConstellationControlMsg};
+use script_traits::{AnimationState, AnimationTickType, CompositorEvent};
+use script_traits::{ConstellationControlMsg, ConstellationMsg as FromCompositorMsg};
 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 std::borrow::ToOwned;
 use std::collections::HashMap;
 #[cfg(not(target_os = "windows"))]
 use std::env;
--- a/servo/components/script_traits/lib.rs
+++ b/servo/components/script_traits/lib.rs
@@ -36,26 +36,29 @@ use devtools_traits::ScriptToDevtoolsCon
 use euclid::Size2D;
 use euclid::length::Length;
 use euclid::point::Point2D;
 use euclid::rect::Rect;
 use gfx_traits::Epoch;
 use gfx_traits::LayerId;
 use ipc_channel::ipc::{IpcReceiver, IpcSender};
 use libc::c_void;
-use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData};
-use msg::constellation_msg::{PanicMsg, PipelineId, PipelineNamespaceId};
-use msg::constellation_msg::{SubpageId, WindowSizeData, WindowSizeType};
+use msg::constellation_msg::{FrameId, 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 net_traits::ResourceThreads;
 use net_traits::bluetooth_thread::BluetoothMethodMsg;
 use net_traits::image_cache_thread::ImageCacheThread;
 use net_traits::response::HttpsState;
 use profile_traits::mem;
 use std::any::Any;
+use std::collections::HashMap;
+use url::Url;
 use util::ipc::OptionalOpaqueIpcSender;
 
 pub use script_msg::{LayoutMsg, ScriptMsg};
 
 /// The address of a node. Layout sends these back. They must be validated via
 /// `from_untrusted_node_address` before they can be used, because we do not trust layout.
 #[derive(Copy, Clone, Debug)]
 pub struct UntrustedNodeAddress(pub *const c_void);
@@ -486,8 +489,52 @@ pub enum MozBrowserErrorType {
 impl MozBrowserErrorType {
     /// Get the name of the error type as a `& str`
     pub fn name(&self) -> &'static str {
         match *self {
             MozBrowserErrorType::Fatal => "fatal",
         }
     }
 }
+
+/// Specifies whether the script or layout thread needs to be ticked for animation.
+#[derive(Deserialize, Serialize)]
+pub enum AnimationTickType {
+    /// The script thread.
+    Script,
+    /// The layout thread.
+    Layout,
+}
+
+/// Messages to the constellation.
+#[derive(Deserialize, Serialize)]
+pub enum ConstellationMsg {
+    /// Exit the constellation.
+    Exit,
+    /// Inform the constellation of the size of the viewport.
+    FrameSize(PipelineId, Size2D<f32>),
+    /// Request that the constellation send the FrameId corresponding to the document
+    /// with the provided pipeline id
+    GetFrame(PipelineId, IpcSender<Option<FrameId>>),
+    /// 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.
+    /// Also returns a boolean saying whether the document has finished loading or not.
+    GetPipeline(Option<FrameId>, IpcSender<Option<(PipelineId, bool)>>),
+    /// Requests that the constellation inform the compositor of the title of the pipeline
+    /// immediately.
+    GetPipelineTitle(PipelineId),
+    /// Request to load the initial page.
+    InitLoadUrl(Url),
+    /// Query the constellation to see if the current compositor output is stable
+    IsReadyToSaveImage(HashMap<PipelineId, Epoch>),
+    /// Inform the constellation of a key event.
+    KeyEvent(Key, KeyState, KeyModifiers),
+    /// Request to load a page.
+    LoadUrl(PipelineId, LoadData),
+    /// Request to navigate a frame.
+    Navigate(Option<(PipelineId, SubpageId)>, NavigationDirection),
+    /// Inform the constellation of a window being resized.
+    WindowSize(WindowSizeData, WindowSizeType),
+    /// Requests that the constellation instruct layout to begin a new tick of the animation.
+    TickAnimation(PipelineId, AnimationTickType),
+    /// Dispatch a webdriver command
+    WebDriverCommand(WebDriverCommandMsg),
+}
--- a/servo/components/servo/Cargo.lock
+++ b/servo/components/servo/Cargo.lock
@@ -2475,26 +2475,26 @@ dependencies = [
  "regex 0.1.71 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "webdriver_server"
 version = "0.0.1"
 dependencies = [
- "compositing 0.0.1",
  "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "hyper 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "image 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "ipc-channel 0.2.2 (git+https://github.com/servo/ipc-channel)",
  "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "msg 0.0.1",
  "plugins 0.0.1",
  "regex 0.1.71 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
+ "script_traits 0.0.1",
  "url 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "util 0.0.1",
  "uuid 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "webdriver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "webrender"
--- a/servo/components/servo/lib.rs
+++ b/servo/components/servo/lib.rs
@@ -53,17 +53,16 @@ extern crate webrender_traits;
 fn webdriver(port: u16, constellation: Sender<ConstellationMsg>) {
     webdriver_server::start_server(port, constellation);
 }
 
 #[cfg(not(feature = "webdriver"))]
 fn webdriver(_port: u16, _constellation: Sender<ConstellationMsg>) { }
 
 use compositing::CompositorEventListener;
-use compositing::CompositorMsg as ConstellationMsg;
 use compositing::compositor_thread::InitialCompositorState;
 use compositing::windowing::WindowEvent;
 use compositing::windowing::WindowMethods;
 use compositing::{CompositorProxy, CompositorThread};
 #[cfg(not(target_os = "windows"))]
 use constellation::content_process_sandbox_profile;
 use constellation::{Constellation, InitialConstellationState, UnprivilegedPipelineContent};
 #[cfg(not(target_os = "windows"))]
@@ -74,16 +73,17 @@ use net::bluetooth_thread::BluetoothThre
 use net::image_cache_thread::new_image_cache_thread;
 use net::resource_thread::new_resource_threads;
 use net_traits::IpcSend;
 use net_traits::bluetooth_thread::BluetoothMethodMsg;
 use profile::mem as profile_mem;
 use profile::time as profile_time;
 use profile_traits::mem;
 use profile_traits::time;
+use script_traits::ConstellationMsg;
 use std::rc::Rc;
 use std::sync::mpsc::Sender;
 use util::resource_files::resources_dir_path;
 use util::{opts, prefs};
 
 pub use gleam::gl;
 
 /// The in-process interface to Servo.
--- a/servo/components/webdriver_server/Cargo.toml
+++ b/servo/components/webdriver_server/Cargo.toml
@@ -4,22 +4,22 @@ version = "0.0.1"
 authors = ["The Servo Project Developers"]
 publish = false
 
 [lib]
 name = "webdriver_server"
 path = "lib.rs"
 
 [dependencies]
-compositing = {path = "../compositing"}
 msg = {path = "../msg"}
 plugins = {path = "../plugins"}
 util = {path = "../util"}
 euclid = {version = "0.6.4", features = ["plugins"]}
 ipc-channel = {git = "https://github.com/servo/ipc-channel"}
 image = "0.10"
 log = "0.3.5"
 hyper = "0.9"
 rustc-serialize = "0.3.4"
 regex = "0.1.55"
+script_traits = {path = "../script_traits"}
 url = {version = "1.0.0", features = ["heap_size"]}
 uuid = { version = "0.2", features = ["v4"] }
 webdriver = "0.9"
--- a/servo/components/webdriver_server/lib.rs
+++ b/servo/components/webdriver_server/lib.rs
@@ -5,43 +5,43 @@
 #![crate_name = "webdriver_server"]
 #![crate_type = "rlib"]
 
 #![feature(plugin)]
 #![plugin(plugins)]
 
 #![deny(unsafe_code)]
 
-extern crate compositing;
 extern crate euclid;
 extern crate hyper;
 extern crate image;
 extern crate ipc_channel;
 extern crate msg;
 extern crate regex;
 extern crate rustc_serialize;
+extern crate script_traits;
 extern crate url;
 extern crate util;
 extern crate uuid;
 extern crate webdriver;
 
 mod keys;
 
-use compositing::CompositorMsg as ConstellationMsg;
 use euclid::Size2D;
 use hyper::method::Method::{self, Post};
 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::webdriver_msg::{LoadStatus, WebDriverFrameId, 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 std::borrow::ToOwned;
 use std::collections::BTreeMap;
 use std::net::{SocketAddr, SocketAddrV4};
 use std::sync::mpsc::Sender;
 use std::thread;
 use std::time::Duration;
 use url::Url;
 use util::prefs::{get_pref, reset_all_prefs, reset_pref, set_pref, PrefValue};
--- a/servo/ports/cef/Cargo.lock
+++ b/servo/ports/cef/Cargo.lock
@@ -2336,26 +2336,26 @@ dependencies = [
  "regex 0.1.71 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "webdriver_server"
 version = "0.0.1"
 dependencies = [
- "compositing 0.0.1",
  "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "hyper 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "image 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "ipc-channel 0.2.2 (git+https://github.com/servo/ipc-channel)",
  "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "msg 0.0.1",
  "plugins 0.0.1",
  "regex 0.1.71 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
+ "script_traits 0.0.1",
  "url 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "util 0.0.1",
  "uuid 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "webdriver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "webrender"