diff options
Diffstat (limited to 'components/script_traits/lib.rs')
-rw-r--r-- | components/script_traits/lib.rs | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 67130403194..e06fbf32c10 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -30,12 +30,13 @@ mod script_msg; use app_units::Au; use devtools_traits::ScriptToDevtoolsControlMsg; +use euclid::Size2D; use euclid::length::Length; use euclid::point::Point2D; use euclid::rect::Rect; use ipc_channel::ipc::{IpcReceiver, IpcSender}; use libc::c_void; -use msg::compositor_msg::{Epoch, LayerId, ScriptToCompositorMsg}; +use msg::compositor_msg::{Epoch, LayerId}; use msg::constellation_msg::{ConstellationChan, Failure, PipelineId, WindowSizeData}; use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData, SubpageId}; use msg::constellation_msg::{MouseButton, MouseEventType}; @@ -289,3 +290,34 @@ pub trait ScriptTaskFactory { fn clone_layout_channel(_phantom: Option<&mut Self>, pair: &OpaqueScriptLayoutChannel) -> Box<Any + Send>; } + +/// Messages sent from the script thread to the compositor +#[derive(Deserialize, Serialize)] +pub enum ScriptToCompositorMsg { + /// Scroll a page in a window + ScrollFragmentPoint(PipelineId, LayerId, Point2D<f32>, bool), + /// Set title of current page + /// https://html.spec.whatwg.org/multipage/#document.title + SetTitle(PipelineId, Option<String>), + /// Send a key event + SendKeyEvent(Key, KeyState, KeyModifiers), + /// Get Window Informations size and position + GetClientWindow(IpcSender<(Size2D<u32>, Point2D<i32>)>), + /// Move the window to a point + MoveTo(Point2D<i32>), + /// Resize the window to size + ResizeTo(Size2D<u32>), + /// Script has handled a touch event, and either prevented or allowed default actions. + TouchEventProcessed(EventResult), + /// Requests that the compositor shut down. + Exit, +} + +/// Whether a DOM event was prevented by web content +#[derive(Deserialize, Serialize)] +pub enum EventResult { + /// Allowed by web content + DefaultAllowed, + /// Prevented by web content + DefaultPrevented, +} |