diff options
Diffstat (limited to 'components/script_traits/script_msg.rs')
-rw-r--r-- | components/script_traits/script_msg.rs | 97 |
1 files changed, 86 insertions, 11 deletions
diff --git a/components/script_traits/script_msg.rs b/components/script_traits/script_msg.rs index 7fc871eb4cc..aaa22732937 100644 --- a/components/script_traits/script_msg.rs +++ b/components/script_traits/script_msg.rs @@ -8,13 +8,17 @@ use IFrameLoadInfo; use MouseButton; use MouseEventType; use MozBrowserEvent; +use WorkerGlobalScopeInit; +use WorkerScriptLoadOrigin; use canvas_traits::CanvasMsg; +use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId}; use euclid::point::Point2D; use euclid::size::Size2D; use gfx_traits::LayerId; use ipc_channel::ipc::IpcSender; use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData}; -use msg::constellation_msg::{NavigationDirection, PipelineId, SubpageId}; +use msg::constellation_msg::{PipelineId, TraversalDirection}; +use net_traits::CoreResourceMsg; use offscreen_gl_context::{GLContextAttributes, GLLimits}; use style_traits::cursor::Cursor; use style_traits::viewport::ViewportConstraints; @@ -40,6 +44,19 @@ pub enum EventResult { DefaultPrevented, } +/// A log entry reported to the constellation +/// We don't report all log entries, just serious ones. +/// We need a separate type for this because LogLevel isn't serializable. +#[derive(Clone, Debug, Deserialize, Serialize)] +pub enum LogEntry { + /// Panic, with a reason and backtrace + Panic(String, String), + /// Error, with a reason + Error(String), + /// warning, with a reason + Warn(String) +} + /// Messages from the script to the constellation. #[derive(Deserialize, Serialize)] pub enum ScriptMsg { @@ -53,10 +70,6 @@ pub enum ScriptMsg { CreateWebGLPaintThread(Size2D<i32>, GLContextAttributes, IpcSender<Result<(IpcSender<CanvasMsg>, GLLimits), String>>), - /// Dispatched after the DOM load event has fired on a document - /// Causes a `load` event to be dispatched to any enclosing frame context element - /// for the given pipeline. - DOMLoad(PipelineId), /// Notifies the constellation that this frame has received focus. Focus(PipelineId), /// Re-send a mouse button event that was sent to the parent window. @@ -67,14 +80,19 @@ pub enum ScriptMsg { GetClipboardContents(IpcSender<String>), /// <head> tag finished parsing HeadParsed, - /// All pending loads are complete. + /// All pending loads are complete, and the `load` event for this pipeline + /// has been dispatched. LoadComplete(PipelineId), /// A new load has been requested. LoadUrl(PipelineId, LoadData), - /// Dispatch a mozbrowser event to a given iframe. Only available in experimental mode. - MozBrowserEvent(PipelineId, SubpageId, MozBrowserEvent), - /// HTMLIFrameElement Forward or Back navigation. - Navigate(Option<(PipelineId, SubpageId)>, NavigationDirection), + /// Dispatch a mozbrowser event to a given iframe, + /// or to the window if no subpage id is provided. + /// First PipelineId is for the parent, second PipelineId is for the actual pipeline. + MozBrowserEvent(PipelineId, Option<PipelineId>, MozBrowserEvent), + /// HTMLIFrameElement Forward or Back traversal. + TraverseHistory(Option<PipelineId>, TraversalDirection), + /// Gets the length of the joint session history from the constellation. + JointSessionHistoryLength(PipelineId, IpcSender<u32>), /// Favicon detected NewFavicon(Url), /// Status message to be displayed in the chrome, eg. a link URL on mouseover. @@ -103,7 +121,7 @@ pub enum ScriptMsg { /// https://html.spec.whatwg.org/multipage/#document.title SetTitle(PipelineId, Option<String>), /// Send a key event - SendKeyEvent(Key, KeyState, KeyModifiers), + SendKeyEvent(Option<char>, Key, KeyState, KeyModifiers), /// Get Window Informations size and position GetClientWindow(IpcSender<(Size2D<u32>, Point2D<i32>)>), /// Move the window to a point @@ -114,8 +132,65 @@ pub enum ScriptMsg { TouchEventProcessed(EventResult), /// Get Scroll Offset GetScrollOffset(PipelineId, LayerId, IpcSender<Point2D<f32>>), + /// A log entry, with the pipeline id and thread name + LogEntry(Option<PipelineId>, Option<String>, LogEntry), /// Notifies the constellation that this pipeline has exited. PipelineExited(PipelineId), + /// Send messages from postMessage calls from serviceworker + /// to constellation for storing in service worker manager + ForwardDOMMessage(DOMMessage, Url), + /// Store the data required to activate a service worker for the given scope + RegisterServiceWorker(ScopeThings, Url), /// Requests that the compositor shut down. + Exit +} + +/// Entities required to spawn service workers +#[derive(Deserialize, Serialize, Clone)] +pub struct ScopeThings { + /// script resource url + pub script_url: Url, + /// pipeline which requested the activation + pub pipeline_id: PipelineId, + /// network load origin of the resource + pub worker_load_origin: WorkerScriptLoadOrigin, + /// base resources required to create worker global scopes + pub init: WorkerGlobalScopeInit, + /// the port to receive devtools message from + pub devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>, + /// service worker id + pub worker_id: WorkerId, +} + +/// Message that gets passed to service worker scope on postMessage +#[derive(Deserialize, Serialize, Debug, Clone)] +pub struct DOMMessage(pub Vec<u8>); + +/// Channels to allow service worker manager to communicate with constellation and resource thread +pub struct SWManagerSenders { + /// sender for communicating with constellation + pub swmanager_sender: IpcSender<SWManagerMsg>, + /// sender for communicating with resource thread + pub resource_sender: IpcSender<CoreResourceMsg> +} + +/// Messages sent to Service Worker Manager thread +#[derive(Deserialize, Serialize)] +pub enum ServiceWorkerMsg { + /// Message to register the service worker + RegisterServiceWorker(ScopeThings, Url), + /// Timeout message sent by active service workers + Timeout(Url), + /// Message sent by constellation to forward to a running service worker + ForwardDOMMessage(DOMMessage, Url), + /// Exit the service worker manager Exit, } + +/// Messages outgoing from the Service Worker Manager thread to constellation +#[derive(Deserialize, Serialize)] +pub enum SWManagerMsg { + /// Provide the constellation with a means of communicating with the Service Worker Manager + OwnSender(IpcSender<ServiceWorkerMsg>) + +} |