aboutsummaryrefslogtreecommitdiffstats
path: root/components/script_traits/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script_traits/lib.rs')
-rw-r--r--components/script_traits/lib.rs50
1 files changed, 46 insertions, 4 deletions
diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs
index 5b1b169e8aa..bd82a498d46 100644
--- a/components/script_traits/lib.rs
+++ b/components/script_traits/lib.rs
@@ -13,16 +13,19 @@
extern crate app_units;
extern crate canvas_traits;
+extern crate cookie as cookie_rs;
extern crate devtools_traits;
extern crate euclid;
extern crate gfx_traits;
extern crate heapsize;
extern crate ipc_channel;
+extern crate layers;
extern crate libc;
extern crate msg;
extern crate net_traits;
extern crate offscreen_gl_context;
extern crate profile_traits;
+extern crate rustc_serialize;
extern crate serde;
extern crate style_traits;
extern crate time;
@@ -30,6 +33,7 @@ extern crate url;
extern crate util;
mod script_msg;
+pub mod webdriver_msg;
use app_units::Au;
use devtools_traits::ScriptToDevtoolsControlMsg;
@@ -37,17 +41,18 @@ use euclid::Size2D;
use euclid::length::Length;
use euclid::point::Point2D;
use euclid::rect::Rect;
+use euclid::scale_factor::ScaleFactor;
+use euclid::size::TypedSize2D;
use gfx_traits::Epoch;
use gfx_traits::LayerId;
use gfx_traits::StackingContextId;
use heapsize::HeapSizeOf;
use ipc_channel::ipc::{IpcReceiver, IpcSender};
+use layers::geometry::DevicePixel;
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, WindowSizeType};
use net_traits::ResourceThreads;
use net_traits::bluetooth_thread::BluetoothMethodMsg;
use net_traits::image_cache_thread::ImageCacheThread;
@@ -57,7 +62,9 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::collections::HashMap;
use std::sync::mpsc::{Sender, Receiver};
use url::Url;
+use util::geometry::{PagePx, ViewportPx};
use util::ipc::OptionalOpaqueIpcSender;
+use webdriver_msg::{LoadStatus, WebDriverScriptCommand};
pub use script_msg::{LayoutMsg, ScriptMsg, EventResult};
@@ -522,6 +529,41 @@ pub struct StackingContextScrollState {
pub scroll_offset: Point2D<f32>,
}
+/// Data about the window size.
+#[derive(Copy, Clone, Deserialize, Serialize, HeapSizeOf)]
+pub struct WindowSizeData {
+ /// The size of the initial layout viewport, before parsing an
+ /// http://www.w3.org/TR/css-device-adapt/#initial-viewport
+ pub initial_viewport: TypedSize2D<ViewportPx, f32>,
+
+ /// The "viewing area" in page px. See `PagePx` documentation for details.
+ pub visible_viewport: TypedSize2D<PagePx, f32>,
+
+ /// The resolution of the window in dppx, not including any "pinch zoom" factor.
+ pub device_pixel_ratio: ScaleFactor<ViewportPx, DevicePixel, f32>,
+}
+
+/// Messages to the constellation originating from the WebDriver server.
+#[derive(Deserialize, Serialize)]
+pub enum WebDriverCommandMsg {
+ /// Get the window size.
+ GetWindowSize(PipelineId, IpcSender<WindowSizeData>),
+ /// Load a URL in the pipeline with the given ID.
+ LoadUrl(PipelineId, LoadData, IpcSender<LoadStatus>),
+ /// Refresh the pipeline with the given ID.
+ Refresh(PipelineId, IpcSender<LoadStatus>),
+ /// 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<u32>, IpcSender<WindowSizeData>),
+ /// Take a screenshot of the window, if the pipeline with the given ID is
+ /// the root pipeline.
+ TakeScreenshot(PipelineId, IpcSender<Option<Image>>),
+}
+
/// Messages to the constellation.
#[derive(Deserialize, Serialize)]
pub enum ConstellationMsg {