diff options
Diffstat (limited to 'components/script_traits/lib.rs')
-rw-r--r-- | components/script_traits/lib.rs | 54 |
1 files changed, 48 insertions, 6 deletions
diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 5b1b169e8aa..ab1a7d7ee52 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; @@ -56,8 +61,10 @@ use profile_traits::mem; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::collections::HashMap; use std::sync::mpsc::{Sender, Receiver}; +use style_traits::{PagePx, ViewportPx}; use url::Url; use util::ipc::OptionalOpaqueIpcSender; +use webdriver_msg::{LoadStatus, WebDriverScriptCommand}; pub use script_msg::{LayoutMsg, ScriptMsg, EventResult}; @@ -275,7 +282,7 @@ pub enum CompositorEvent { /// Touchpad pressure event TouchpadPressureEvent(Point2D<f32>, f32, TouchpadPressurePhase), /// A key was pressed. - KeyEvent(Key, KeyState, KeyModifiers), + KeyEvent(Option<char>, Key, KeyState, KeyModifiers), } /// Touchpad pressure phase for TouchpadPressureEvent. @@ -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 { @@ -544,7 +586,7 @@ pub enum ConstellationMsg { /// 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), + KeyEvent(Option<char>, Key, KeyState, KeyModifiers), /// Request to load a page. LoadUrl(PipelineId, LoadData), /// Request to navigate a frame. |