aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-03-25 20:00:54 -0600
committerbors-servo <metajack+bors@gmail.com>2015-03-25 20:00:54 -0600
commit432739164b1f3a117c0aac1dfc97b41018c89b46 (patch)
treef319c4b967f1a9045376c34f74eea11c01a1ec14 /components/script
parent88ca398cae4070957306890b0c7006ac7b9e5cef (diff)
parentcb9cfe2b22e6d80e8b30ad64f2cff5e22a61c284 (diff)
downloadservo-432739164b1f3a117c0aac1dfc97b41018c89b46.tar.gz
servo-432739164b1f3a117c0aac1dfc97b41018c89b46.zip
auto merge of #5359 : aweinstock314/servo/moz-events, r=jdm
Addresses #5352. This is based on https://github.com/glennw/servo/tree/moz-events
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/document.rs17
-rw-r--r--components/script/dom/htmliframeelement.rs12
-rw-r--r--components/script/script_task.rs19
3 files changed, 22 insertions, 26 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index a153d462772..8ceb6ace1f3 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -61,7 +61,7 @@ use dom::window::{Window, WindowHelpers, ReflowReason};
use layout_interface::{HitTestResponse, MouseOverResponse};
use msg::compositor_msg::ScriptListener;
use msg::constellation_msg::Msg as ConstellationMsg;
-use msg::constellation_msg::{ConstellationChan, Key, KeyState, KeyModifiers};
+use msg::constellation_msg::{ConstellationChan, Key, KeyState, KeyModifiers, MozBrowserEvent};
use msg::constellation_msg::{SUPER, ALT, SHIFT, CONTROL};
use net::resource_task::ControlMsg::{SetCookiesForUrl, GetCookiesForUrl};
use net::cookie_storage::CookieSource::NonHTTP;
@@ -223,7 +223,7 @@ pub trait DocumentHelpers<'a> {
fn handle_mouse_move_event(self, js_runtime: *mut JSRuntime, point: Point2D<f32>,
prev_mouse_over_targets: &mut Vec<JS<Node>>) -> bool;
fn set_current_script(self, script: Option<JSRef<HTMLScriptElement>>);
- fn trigger_mozbrowser_event(self, event_name: String, event_detail: Option<String>);
+ fn trigger_mozbrowser_event(self, event: MozBrowserEvent);
}
impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
@@ -458,7 +458,7 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
/// Handles any updates when the document's title has changed.
fn title_changed(self) {
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsertitlechange
- self.trigger_mozbrowser_event("mozbrowsertitlechange".to_owned(), Some(self.Title()));
+ self.trigger_mozbrowser_event(MozBrowserEvent::TitleChange(self.Title()));
self.send_title_to_compositor();
}
@@ -683,16 +683,15 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
self.current_script.assign(script);
}
- fn trigger_mozbrowser_event(self, event_name: String, event_detail: Option<String>) {
+ fn trigger_mozbrowser_event(self, event: MozBrowserEvent) {
if opts::experimental_enabled() {
let window = self.window.root();
if let Some((containing_pipeline_id, subpage_id)) = window.r().parent_info() {
let ConstellationChan(ref chan) = window.r().constellation_chan();
- let event = ConstellationMsg::MozBrowserEvent(containing_pipeline_id,
- subpage_id,
- event_name,
- event_detail);
+ let event = ConstellationMsg::MozBrowserEventMsg(containing_pipeline_id,
+ subpage_id,
+ event);
chan.send(event).unwrap();
}
}
@@ -1464,7 +1463,7 @@ impl DocumentProgressHandler {
});
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadend
- document.r().trigger_mozbrowser_event("mozbrowserloadend".to_owned(), None);
+ document.r().trigger_mozbrowser_event(MozBrowserEvent::LoadEnd);
window_ref.reflow(ReflowGoal::ForDisplay,
ReflowQueryType::NoQuery,
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index 64a0f2db7a7..1c5e9ec2349 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -29,7 +29,7 @@ use dom::virtualmethods::VirtualMethods;
use dom::window::{Window, WindowHelpers};
use page::IterablePage;
-use msg::constellation_msg::{PipelineId, SubpageId, ConstellationChan, NavigationDirection};
+use msg::constellation_msg::{PipelineId, SubpageId, ConstellationChan, MozBrowserEvent, NavigationDirection};
use msg::constellation_msg::IFrameSandboxState::{IFrameSandboxed, IFrameUnsandboxed};
use msg::constellation_msg::Msg as ConstellationMsg;
use util::opts;
@@ -72,7 +72,7 @@ pub trait HTMLIFrameElementHelpers {
fn process_the_iframe_attributes(self);
fn generate_new_subpage_id(self) -> (SubpageId, Option<SubpageId>);
fn navigate_child_browsing_context(self, url: Url);
- fn dispatch_mozbrowser_event(self, event_name: String, event_detail: Option<String>);
+ fn dispatch_mozbrowser_event(self, event: MozBrowserEvent);
fn update_subpage_id(self, new_subpage_id: SubpageId);
}
@@ -125,7 +125,7 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
if opts::experimental_enabled() {
// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadstart
- self.dispatch_mozbrowser_event("mozbrowserloadstart".to_owned(), None);
+ self.dispatch_mozbrowser_event(MozBrowserEvent::LoadStart);
}
}
@@ -138,7 +138,7 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
self.navigate_child_browsing_context(url);
}
- fn dispatch_mozbrowser_event(self, event_name: String, event_detail: Option<String>) {
+ fn dispatch_mozbrowser_event(self, event: MozBrowserEvent) {
// TODO(gw): Support mozbrowser event types that have detail which is not a string.
// See https://developer.mozilla.org/en-US/docs/Web/API/Using_the_Browser_API
// for a list of mozbrowser events.
@@ -148,10 +148,10 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
let window = window_from_node(self).root();
let cx = window.r().get_cx();
let custom_event = CustomEvent::new(GlobalRef::Window(window.r()),
- event_name.to_owned(),
+ event.name().to_owned(),
true,
true,
- event_detail.to_jsval(cx)).root();
+ event.detail().to_jsval(cx)).root();
let target: JSRef<EventTarget> = EventTargetCast::from_ref(self);
let event: JSRef<Event> = EventCast::from_ref(custom_event.r());
event.fire(target);
diff --git a/components/script/script_task.rs b/components/script/script_task.rs
index 8aa3ccd0259..42db9aaf155 100644
--- a/components/script/script_task.rs
+++ b/components/script/script_task.rs
@@ -57,8 +57,8 @@ use script_traits::ScriptTaskFactory;
use msg::compositor_msg::ReadyState::{FinishedLoading, Loading, PerformingLayout};
use msg::compositor_msg::{LayerId, ScriptListener};
use msg::constellation_msg::{ConstellationChan};
-use msg::constellation_msg::{LoadData, PipelineId, SubpageId};
-use msg::constellation_msg::{Failure, Msg, WindowSizeData, PipelineExitType};
+use msg::constellation_msg::{LoadData, PipelineId, SubpageId, MozBrowserEvent};
+use msg::constellation_msg::{Failure, WindowSizeData, PipelineExitType};
use msg::constellation_msg::Msg as ConstellationMsg;
use net::image_cache_task::ImageCacheTask;
use net::resource_task::{ResourceTask, ControlMsg, LoadResponse};
@@ -650,14 +650,12 @@ impl ScriptTask {
self.handle_freeze_msg(pipeline_id),
ConstellationControlMsg::Thaw(pipeline_id) =>
self.handle_thaw_msg(pipeline_id),
- ConstellationControlMsg::MozBrowserEvent(parent_pipeline_id,
- subpage_id,
- event_name,
- event_detail) =>
+ ConstellationControlMsg::MozBrowserEventMsg(parent_pipeline_id,
+ subpage_id,
+ event) =>
self.handle_mozbrowser_event_msg(parent_pipeline_id,
subpage_id,
- event_name,
- event_detail),
+ event),
ConstellationControlMsg::UpdateSubpageId(containing_pipeline_id,
old_subpage_id,
new_subpage_id) =>
@@ -810,8 +808,7 @@ impl ScriptTask {
fn handle_mozbrowser_event_msg(&self,
parent_pipeline_id: PipelineId,
subpage_id: SubpageId,
- event_name: String,
- event_detail: Option<String>) {
+ event: MozBrowserEvent) {
let borrowed_page = self.root_page();
let frame_element = borrowed_page.find(parent_pipeline_id).and_then(|page| {
@@ -825,7 +822,7 @@ impl ScriptTask {
}).root();
if let Some(frame_element) = frame_element {
- frame_element.r().dispatch_mozbrowser_event(event_name, event_detail);
+ frame_element.r().dispatch_mozbrowser_event(event);
}
}