diff options
-rw-r--r-- | components/compositing/compositor_task.rs | 3 | ||||
-rw-r--r-- | components/compositing/pipeline.rs | 3 | ||||
-rw-r--r-- | components/compositing/touch.rs | 3 | ||||
-rw-r--r-- | components/msg/compositor_msg.rs | 20 | ||||
-rw-r--r-- | components/script/dom/document.rs | 4 | ||||
-rw-r--r-- | components/script/dom/window.rs | 4 | ||||
-rw-r--r-- | components/script/script_task.rs | 6 | ||||
-rw-r--r-- | components/script_traits/lib.rs | 34 |
8 files changed, 45 insertions, 32 deletions
diff --git a/components/compositing/compositor_task.rs b/components/compositing/compositor_task.rs index 07a60289cec..75943b7932f 100644 --- a/components/compositing/compositor_task.rs +++ b/components/compositing/compositor_task.rs @@ -13,11 +13,12 @@ use headless; use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use layers::layers::{BufferRequest, LayerBufferSet}; use layers::platform::surface::{NativeDisplay, NativeSurface}; -use msg::compositor_msg::{Epoch, EventResult, FrameTreeId, LayerId, LayerProperties, ScriptToCompositorMsg}; +use msg::compositor_msg::{Epoch, FrameTreeId, LayerId, LayerProperties}; use msg::constellation_msg::{AnimationState, PipelineId}; use msg::constellation_msg::{Image, Key, KeyModifiers, KeyState}; use profile_traits::mem; use profile_traits::time; +use script_traits::{EventResult, ScriptToCompositorMsg}; use std::fmt::{Debug, Error, Formatter}; use std::rc::Rc; use std::sync::mpsc::{Receiver, Sender, channel}; diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs index ffcb915153c..c2d38442434 100644 --- a/components/compositing/pipeline.rs +++ b/components/compositing/pipeline.rs @@ -14,7 +14,6 @@ use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; use ipc_channel::router::ROUTER; use layers::geometry::DevicePixel; use layout_traits::{LayoutControlChan, LayoutTaskFactory}; -use msg::compositor_msg::ScriptToCompositorMsg; use msg::constellation_msg::PaintMsg; use msg::constellation_msg::{ConstellationChan, Failure, FrameId, PipelineId, SubpageId}; use msg::constellation_msg::{LoadData, MozBrowserEvent, WindowSizeData}; @@ -26,7 +25,7 @@ use profile_traits::mem as profile_mem; use profile_traits::time; use script_traits::{ConstellationControlMsg, InitialScriptState}; use script_traits::{LayoutControlMsg, NewLayoutInfo, ScriptMsg as ConstellationMsg}; -use script_traits::{ScriptTaskFactory, TimerEventRequest}; +use script_traits::{ScriptToCompositorMsg, ScriptTaskFactory, TimerEventRequest}; use std::mem; use std::sync::mpsc::{Receiver, Sender, channel}; use std::thread; diff --git a/components/compositing/touch.rs b/components/compositing/touch.rs index 46d38c378ca..1dbd9914f89 100644 --- a/components/compositing/touch.rs +++ b/components/compositing/touch.rs @@ -5,8 +5,7 @@ use euclid::point::TypedPoint2D; use euclid::scale_factor::ScaleFactor; use layers::geometry::DevicePixel; -use msg::compositor_msg::EventResult; -use script_traits::TouchId; +use script_traits::{EventResult, TouchId}; use self::TouchState::*; /// Minimum number of ScreenPx to begin touch scrolling. diff --git a/components/msg/compositor_msg.rs b/components/msg/compositor_msg.rs index 6c48e293554..ca2a68d55bd 100644 --- a/components/msg/compositor_msg.rs +++ b/components/msg/compositor_msg.rs @@ -4,7 +4,7 @@ use azure::azure_hl::Color; use constellation_msg::{Key, KeyModifiers, KeyState, PipelineId}; -use euclid::{Matrix4, Point2D, Rect, Size2D}; +use euclid::{Matrix4, Point2D, Rect}; use ipc_channel::ipc::IpcSender; use std::fmt::{self, Debug, Formatter}; @@ -123,21 +123,3 @@ pub struct LayerProperties { /// Whether this layer scrolls its overflow area. pub scrolls_overflow_area: bool, } - -#[derive(Deserialize, Serialize)] -pub enum ScriptToCompositorMsg { - ScrollFragmentPoint(PipelineId, LayerId, Point2D<f32>, bool), - SetTitle(PipelineId, Option<String>), - SendKeyEvent(Key, KeyState, KeyModifiers), - GetClientWindow(IpcSender<(Size2D<u32>, Point2D<i32>)>), - MoveTo(Point2D<i32>), - ResizeTo(Size2D<u32>), - TouchEventProcessed(EventResult), - Exit, -} - -#[derive(Deserialize, Serialize)] -pub enum EventResult { - DefaultAllowed, - DefaultPrevented, -} diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 1d7c7c43eb3..d682188c461 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -80,7 +80,6 @@ use js::jsapi::{JSContext, JSObject, JSRuntime}; use layout_interface::{HitTestResponse, MouseOverResponse}; use layout_interface::{LayoutChan, Msg}; use layout_interface::{ReflowGoal, ReflowQueryType}; -use msg::compositor_msg::ScriptToCompositorMsg; use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER}; use msg::constellation_msg::{AnimationState, PipelineId}; use msg::constellation_msg::{ConstellationChan, Key, KeyModifiers, KeyState}; @@ -91,7 +90,8 @@ use net_traits::{AsyncResponseTarget, PendingAsyncLoad}; use num::ToPrimitive; use script_task::CSSError; use script_task::{MainThreadScriptMsg, Runnable}; -use script_traits::{ScriptMsg as ConstellationMsg, TouchEventType, TouchId, UntrustedNodeAddress}; +use script_traits::{ScriptMsg as ConstellationMsg, ScriptToCompositorMsg}; +use script_traits::{TouchEventType, TouchId, UntrustedNodeAddress}; use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::boxed::FnBox; diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 47639f0c362..36a7aafc080 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -43,7 +43,7 @@ use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleRe use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowGoal, ReflowQueryType}; use libc; use msg::ParseErrorReporter; -use msg::compositor_msg::{LayerId, ScriptToCompositorMsg}; +use msg::compositor_msg::LayerId; use msg::constellation_msg::{ConstellationChan, DocumentState, LoadData}; use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData}; use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult}; @@ -58,7 +58,7 @@ use rustc_serialize::base64::{FromBase64, STANDARD, ToBase64}; use script_task::{ScriptChan, ScriptPort, MainThreadScriptMsg, RunnableWrapper}; use script_task::{SendableMainThreadScriptChan, MainThreadScriptChan}; use script_traits::ScriptMsg as ConstellationMsg; -use script_traits::{MsDuration, TimerEvent, TimerEventId, TimerEventRequest, TimerSource}; +use script_traits::{MsDuration, ScriptToCompositorMsg, TimerEvent, TimerEventId, TimerEventRequest, TimerSource}; use selectors::parser::PseudoElement; use std::ascii::AsciiExt; use std::borrow::ToOwned; diff --git a/components/script/script_task.rs b/components/script/script_task.rs index ccba560e83b..94193b3077a 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -61,7 +61,7 @@ use layout_interface::{ReflowQueryType}; use layout_interface::{self, LayoutChan, NewLayoutTaskInfo, ReflowGoal, ScriptLayoutChan}; use libc; use mem::heap_size_of_self_and_children; -use msg::compositor_msg::{EventResult, LayerId, ScriptToCompositorMsg}; +use msg::compositor_msg::LayerId; use msg::constellation_msg::{ConstellationChan, LoadData}; use msg::constellation_msg::{MouseButton, MouseEventType, MozBrowserEvent, PipelineId}; use msg::constellation_msg::{PipelineNamespace}; @@ -79,9 +79,9 @@ use profile_traits::mem::{self, OpaqueSender, Report, ReportKind, ReportsChan}; use profile_traits::time::{self, ProfilerCategory, profile}; use script_traits::CompositorEvent::{KeyEvent, MouseButtonEvent, MouseMoveEvent, ResizeEvent}; use script_traits::CompositorEvent::{TouchEvent}; -use script_traits::{CompositorEvent, ConstellationControlMsg, InitialScriptState, NewLayoutInfo}; +use script_traits::{CompositorEvent, ConstellationControlMsg, EventResult, InitialScriptState, NewLayoutInfo}; use script_traits::{OpaqueScriptLayoutChannel, ScriptMsg as ConstellationMsg}; -use script_traits::{ScriptTaskFactory, TimerEvent, TimerEventRequest, TimerSource}; +use script_traits::{ScriptTaskFactory, ScriptToCompositorMsg, TimerEvent, TimerEventRequest, TimerSource}; use script_traits::{TouchEventType, TouchId}; use std::any::Any; use std::borrow::ToOwned; 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, +} |