aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorapopiak <alexander.popiak@gmail.com>2016-01-11 23:20:10 +0100
committerapopiak <alexander.popiak@gmail.com>2016-01-13 17:48:50 +0100
commit4b773cefe9ffdecd04993e4652fb2e436bf57e08 (patch)
treec7d396a4d1b7737707abe7f841eb973d98a0a35f
parent0e6bca8e8efce40f99aca24475d5ba1dac317e2c (diff)
downloadservo-4b773cefe9ffdecd04993e4652fb2e436bf57e08.tar.gz
servo-4b773cefe9ffdecd04993e4652fb2e436bf57e08.zip
move MozBrowserEvent to script_traits (+ documentation)
-rw-r--r--components/compositing/constellation.rs6
-rw-r--r--components/compositing/pipeline.rs4
-rw-r--r--components/msg/constellation_msg.rs55
-rw-r--r--components/script/dom/document.rs4
-rw-r--r--components/script/dom/htmliframeelement.rs5
-rw-r--r--components/script/dom/htmllinkelement.rs4
-rw-r--r--components/script/dom/window.rs6
-rw-r--r--components/script/script_thread.rs4
-rw-r--r--components/script_traits/lib.rs59
-rw-r--r--components/script_traits/script_msg.rs4
10 files changed, 74 insertions, 77 deletions
diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs
index 2daa652f6f4..90d244868ba 100644
--- a/components/compositing/constellation.rs
+++ b/components/compositing/constellation.rs
@@ -30,8 +30,7 @@ use msg::constellation_msg::AnimationState;
use msg::constellation_msg::WebDriverCommandMsg;
use msg::constellation_msg::{FrameId, PipelineId};
use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData};
-use msg::constellation_msg::{MozBrowserEvent, NavigationDirection};
-use msg::constellation_msg::{PipelineNamespace, PipelineNamespaceId};
+use msg::constellation_msg::{PipelineNamespace, PipelineNamespaceId, NavigationDirection};
use msg::constellation_msg::{SubpageId, WindowSizeData};
use msg::constellation_msg::{self, ConstellationChan, Failure};
use msg::webdriver_msg;
@@ -44,9 +43,8 @@ use profile_traits::mem;
use profile_traits::time;
use sandboxing;
use script_traits::{CompositorEvent, ConstellationControlMsg, DocumentState, LayoutControlMsg};
-use script_traits::{IFrameLoadInfo, IFrameSandboxState};
+use script_traits::{IFrameLoadInfo, IFrameSandboxState, MozBrowserEvent, TimerEventRequest};
use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, ScriptThreadFactory};
-use script_traits::{TimerEventRequest};
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::env;
diff --git a/components/compositing/pipeline.rs b/components/compositing/pipeline.rs
index 3c49bbf41db..2a4e3b1999e 100644
--- a/components/compositing/pipeline.rs
+++ b/components/compositing/pipeline.rs
@@ -16,14 +16,14 @@ use ipc_channel::router::ROUTER;
use layers::geometry::DevicePixel;
use layout_traits::{LayoutControlChan, LayoutThreadFactory};
use msg::constellation_msg::{ConstellationChan, Failure, FrameId, PipelineId, SubpageId};
-use msg::constellation_msg::{LoadData, MozBrowserEvent, WindowSizeData};
+use msg::constellation_msg::{LoadData, WindowSizeData};
use msg::constellation_msg::{PipelineNamespaceId};
use net_traits::ResourceThread;
use net_traits::image_cache_thread::ImageCacheThread;
use net_traits::storage_thread::StorageThread;
use profile_traits::mem as profile_mem;
use profile_traits::time;
-use script_traits::{ConstellationControlMsg, InitialScriptState};
+use script_traits::{ConstellationControlMsg, InitialScriptState, MozBrowserEvent};
use script_traits::{LayoutControlMsg, LayoutMsg, NewLayoutInfo, ScriptMsg};
use script_traits::{ScriptToCompositorMsg, ScriptThreadFactory, TimerEventRequest};
use std::mem;
diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs
index d1e9b39b02b..46fda6511e0 100644
--- a/components/msg/constellation_msg.rs
+++ b/components/msg/constellation_msg.rs
@@ -219,61 +219,6 @@ pub enum AnimationState {
NoAnimationCallbacksPresent,
}
-// https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API#Events
-#[derive(Deserialize, Serialize)]
-pub enum MozBrowserEvent {
- /// Sent when the scroll position within a browser `<iframe>` changes.
- AsyncScroll,
- /// Sent when window.close() is called within a browser `<iframe>`.
- Close,
- /// Sent when a browser `<iframe>` tries to open a context menu. This allows
- /// handling `<menuitem>` element available within the browser `<iframe>`'s content.
- ContextMenu,
- /// Sent when an error occurred while trying to load content within a browser `<iframe>`.
- Error,
- /// Sent when the favicon of a browser `<iframe>` changes.
- IconChange(String, String, String),
- /// Sent when the browser `<iframe>` has finished loading all its assets.
- LoadEnd,
- /// Sent when the browser `<iframe>` starts to load a new page.
- LoadStart,
- /// Sent when a browser `<iframe>`'s location changes.
- LocationChange(String),
- /// Sent when window.open() is called within a browser `<iframe>`.
- OpenWindow,
- /// Sent when the SSL state changes within a browser `<iframe>`.
- SecurityChange,
- /// Sent when alert(), confirm(), or prompt() is called within a browser `<iframe>`.
- ShowModalPrompt(String, String, String, String), // TODO(simartin): Handle unblock()
- /// Sent when the document.title changes within a browser `<iframe>`.
- TitleChange(String),
- /// Sent when an HTTP authentification is requested.
- UsernameAndPasswordRequired,
- /// Sent when a link to a search engine is found.
- OpenSearch,
-}
-
-impl MozBrowserEvent {
- pub fn name(&self) -> &'static str {
- match *self {
- MozBrowserEvent::AsyncScroll => "mozbrowserasyncscroll",
- MozBrowserEvent::Close => "mozbrowserclose",
- MozBrowserEvent::ContextMenu => "mozbrowsercontextmenu",
- MozBrowserEvent::Error => "mozbrowsererror",
- MozBrowserEvent::IconChange(_, _, _) => "mozbrowsericonchange",
- MozBrowserEvent::LoadEnd => "mozbrowserloadend",
- MozBrowserEvent::LoadStart => "mozbrowserloadstart",
- MozBrowserEvent::LocationChange(_) => "mozbrowserlocationchange",
- MozBrowserEvent::OpenWindow => "mozbrowseropenwindow",
- MozBrowserEvent::SecurityChange => "mozbrowsersecuritychange",
- MozBrowserEvent::ShowModalPrompt(_, _, _, _) => "mozbrowsershowmodalprompt",
- MozBrowserEvent::TitleChange(_) => "mozbrowsertitlechange",
- MozBrowserEvent::UsernameAndPasswordRequired => "mozbrowserusernameandpasswordrequired",
- MozBrowserEvent::OpenSearch => "mozbrowseropensearch"
- }
- }
-}
-
#[derive(Deserialize, Serialize)]
pub enum WebDriverCommandMsg {
LoadUrl(PipelineId, LoadData, IpcSender<LoadStatus>),
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 49afd4dc9ee..65987f4bf3e 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -83,13 +83,13 @@ use layout_interface::{LayoutChan, Msg, ReflowQueryType};
use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER};
use msg::constellation_msg::{AnimationState, PipelineId};
use msg::constellation_msg::{ConstellationChan, Key, KeyModifiers, KeyState};
-use msg::constellation_msg::{MouseButton, MozBrowserEvent, SubpageId};
+use msg::constellation_msg::{MouseButton, SubpageId};
use net_traits::ControlMsg::{GetCookiesForUrl, SetCookiesForUrl};
use net_traits::CookieSource::NonHTTP;
use net_traits::{AsyncResponseTarget, PendingAsyncLoad};
use num::ToPrimitive;
use script_thread::{MainThreadScriptMsg, Runnable};
-use script_traits::MouseEventType;
+use script_traits::{MouseEventType, MozBrowserEvent};
use script_traits::{ScriptMsg as ConstellationMsg, ScriptToCompositorMsg};
use script_traits::{TouchEventType, TouchId, UntrustedNodeAddress};
use std::ascii::AsciiExt;
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index 4d496903629..65cfd32fa17 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -26,12 +26,11 @@ use dom::virtualmethods::VirtualMethods;
use dom::window::Window;
use js::jsapi::{JSAutoCompartment, JSAutoRequest, RootedValue, JSContext, MutableHandleValue};
use js::jsval::{UndefinedValue, NullValue};
-use msg::constellation_msg::{ConstellationChan, MozBrowserEvent};
+use msg::constellation_msg::{ConstellationChan};
use msg::constellation_msg::{NavigationDirection, PipelineId, SubpageId};
use page::IterablePage;
-use script_traits::IFrameLoadInfo;
use script_traits::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
-use script_traits::ScriptMsg as ConstellationMsg;
+use script_traits::{IFrameLoadInfo, MozBrowserEvent, ScriptMsg as ConstellationMsg};
use std::ascii::AsciiExt;
use std::cell::Cell;
use string_cache::Atom;
diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs
index 58ce5dc6ea0..38bb2287ac3 100644
--- a/components/script/dom/htmllinkelement.rs
+++ b/components/script/dom/htmllinkelement.rs
@@ -24,10 +24,10 @@ use encoding::all::UTF_8;
use ipc_channel::ipc;
use ipc_channel::router::ROUTER;
use layout_interface::{LayoutChan, Msg};
-use msg::constellation_msg::{ConstellationChan, MozBrowserEvent};
+use msg::constellation_msg::ConstellationChan;
use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata};
use network_listener::{NetworkListener, PreInvoke};
-use script_traits::ScriptMsg as ConstellationMsg;
+use script_traits::{MozBrowserEvent, ScriptMsg as ConstellationMsg};
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::cell::Cell;
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 8ae52b9ccb0..df7f6a3faeb 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -43,8 +43,7 @@ use js::rust::Runtime;
use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow};
use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowQueryType};
use libc;
-use msg::constellation_msg::{ConstellationChan, LoadData};
-use msg::constellation_msg::{MozBrowserEvent, PipelineId, SubpageId, WindowSizeData};
+use msg::constellation_msg::{ConstellationChan, LoadData, PipelineId, SubpageId, WindowSizeData};
use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
use net_traits::ResourceThread;
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread};
@@ -57,9 +56,8 @@ use rustc_serialize::base64::{FromBase64, STANDARD, ToBase64};
use script_thread::{DOMManipulationThreadSource, UserInteractionThreadSource, NetworkingThreadSource};
use script_thread::{HistoryTraversalThreadSource, FileReadingThreadSource, SendableMainThreadScriptChan};
use script_thread::{ScriptChan, ScriptPort, MainThreadScriptChan, MainThreadScriptMsg, RunnableWrapper};
-use script_traits::ScriptMsg as ConstellationMsg;
use script_traits::{DocumentState, MsDuration, ScriptToCompositorMsg, TimerEvent, TimerEventId};
-use script_traits::{TimerEventRequest, TimerSource};
+use script_traits::{MozBrowserEvent, ScriptMsg as ConstellationMsg, TimerEventRequest, TimerSource};
use selectors::parser::PseudoElement;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index 3e397f2b5f9..1b42f35d716 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -64,7 +64,7 @@ use layout_interface::{self, LayoutChan, NewLayoutThreadInfo, ScriptLayoutChan};
use libc;
use mem::heap_size_of_self_and_children;
use msg::constellation_msg::{ConstellationChan, LoadData};
-use msg::constellation_msg::{MouseButton, MozBrowserEvent, PipelineId};
+use msg::constellation_msg::{MouseButton, PipelineId};
use msg::constellation_msg::{PipelineNamespace};
use msg::constellation_msg::{SubpageId, WindowSizeData};
use msg::webdriver_msg::WebDriverScriptCommand;
@@ -81,7 +81,7 @@ 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, EventResult};
-use script_traits::{InitialScriptState, MouseEventType, NewLayoutInfo};
+use script_traits::{InitialScriptState, MouseEventType, MozBrowserEvent, NewLayoutInfo};
use script_traits::{LayoutMsg, OpaqueScriptLayoutChannel, ScriptMsg as ConstellationMsg};
use script_traits::{ScriptThreadFactory, ScriptToCompositorMsg, TimerEvent, TimerEventRequest, TimerSource};
use script_traits::{TouchEventType, TouchId};
diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs
index 64e64e64ed9..d9fcba984ad 100644
--- a/components/script_traits/lib.rs
+++ b/components/script_traits/lib.rs
@@ -41,7 +41,7 @@ use ipc_channel::ipc::{IpcReceiver, IpcSender};
use libc::c_void;
use msg::constellation_msg::{ConstellationChan, Failure, PipelineId, WindowSizeData};
use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData, MouseButton};
-use msg::constellation_msg::{MozBrowserEvent, PipelineNamespaceId, SubpageId};
+use msg::constellation_msg::{PipelineNamespaceId, SubpageId};
use msg::webdriver_msg::WebDriverScriptCommand;
use net_traits::ResourceThread;
use net_traits::image_cache_thread::ImageCacheThread;
@@ -371,3 +371,60 @@ pub struct IFrameLoadInfo {
/// Sandbox type of this iframe
pub sandbox: IFrameSandboxState,
}
+
+// https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API#Events
+/// The events fired in a Browser API context (`<iframe mozbrowser>`)
+#[derive(Deserialize, Serialize)]
+pub enum MozBrowserEvent {
+ /// Sent when the scroll position within a browser `<iframe>` changes.
+ AsyncScroll,
+ /// Sent when window.close() is called within a browser `<iframe>`.
+ Close,
+ /// Sent when a browser `<iframe>` tries to open a context menu. This allows
+ /// handling `<menuitem>` element available within the browser `<iframe>`'s content.
+ ContextMenu,
+ /// Sent when an error occurred while trying to load content within a browser `<iframe>`.
+ Error,
+ /// Sent when the favicon of a browser `<iframe>` changes.
+ IconChange(String, String, String),
+ /// Sent when the browser `<iframe>` has finished loading all its assets.
+ LoadEnd,
+ /// Sent when the browser `<iframe>` starts to load a new page.
+ LoadStart,
+ /// Sent when a browser `<iframe>`'s location changes.
+ LocationChange(String),
+ /// Sent when window.open() is called within a browser `<iframe>`.
+ OpenWindow,
+ /// Sent when the SSL state changes within a browser `<iframe>`.
+ SecurityChange,
+ /// Sent when alert(), confirm(), or prompt() is called within a browser `<iframe>`.
+ ShowModalPrompt(String, String, String, String), // TODO(simartin): Handle unblock()
+ /// Sent when the document.title changes within a browser `<iframe>`.
+ TitleChange(String),
+ /// Sent when an HTTP authentification is requested.
+ UsernameAndPasswordRequired,
+ /// Sent when a link to a search engine is found.
+ OpenSearch,
+}
+
+impl MozBrowserEvent {
+ /// Get the name of the event as a `& str`
+ pub fn name(&self) -> &'static str {
+ match *self {
+ MozBrowserEvent::AsyncScroll => "mozbrowserasyncscroll",
+ MozBrowserEvent::Close => "mozbrowserclose",
+ MozBrowserEvent::ContextMenu => "mozbrowsercontextmenu",
+ MozBrowserEvent::Error => "mozbrowsererror",
+ MozBrowserEvent::IconChange(_, _, _) => "mozbrowsericonchange",
+ MozBrowserEvent::LoadEnd => "mozbrowserloadend",
+ MozBrowserEvent::LoadStart => "mozbrowserloadstart",
+ MozBrowserEvent::LocationChange(_) => "mozbrowserlocationchange",
+ MozBrowserEvent::OpenWindow => "mozbrowseropenwindow",
+ MozBrowserEvent::SecurityChange => "mozbrowsersecuritychange",
+ MozBrowserEvent::ShowModalPrompt(_, _, _, _) => "mozbrowsershowmodalprompt",
+ MozBrowserEvent::TitleChange(_) => "mozbrowsertitlechange",
+ MozBrowserEvent::UsernameAndPasswordRequired => "mozbrowserusernameandpasswordrequired",
+ MozBrowserEvent::OpenSearch => "mozbrowseropensearch"
+ }
+ }
+}
diff --git a/components/script_traits/script_msg.rs b/components/script_traits/script_msg.rs
index 195976806a6..b4e8e587a3d 100644
--- a/components/script_traits/script_msg.rs
+++ b/components/script_traits/script_msg.rs
@@ -5,12 +5,12 @@
use DocumentState;
use IFrameLoadInfo;
use MouseEventType;
+use MozBrowserEvent;
use canvas_traits::CanvasMsg;
use euclid::point::Point2D;
use euclid::size::Size2D;
use ipc_channel::ipc::IpcSender;
-use msg::constellation_msg::{AnimationState, NavigationDirection};
-use msg::constellation_msg::{Failure, MozBrowserEvent, PipelineId};
+use msg::constellation_msg::{AnimationState, NavigationDirection, Failure, PipelineId};
use msg::constellation_msg::{LoadData, MouseButton, SubpageId};
use offscreen_gl_context::GLContextAttributes;
use style_traits::viewport::ViewportConstraints;