aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/activation.rs2
-rw-r--r--components/script/dom/element.rs6
-rw-r--r--components/script/dom/eventdispatcher.rs1
-rw-r--r--components/script/dom/eventtarget.rs19
-rw-r--r--components/script/dom/messageevent.rs2
-rw-r--r--components/script/dom/xmlhttprequest.rs4
6 files changed, 20 insertions, 14 deletions
diff --git a/components/script/dom/activation.rs b/components/script/dom/activation.rs
index e4a54112e58..97bc66f5362 100644
--- a/components/script/dom/activation.rs
+++ b/components/script/dom/activation.rs
@@ -49,7 +49,7 @@ pub trait Activatable : Copy {
0, None).root();
let event: JSRef<Event> = EventCast::from_ref(*mouse);
event.set_trusted(true);
- target.dispatch_event_with_target(None, event).ok();
+ target.dispatch_event(event);
// Step 5
if event.DefaultPrevented() {
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index e24407d7957..1dc277e0fc1 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -1262,7 +1262,7 @@ impl<'a> ActivationElementHelpers<'a> for JSRef<'a, Element> {
Some(elem) => {
// Step 5-6
elem.pre_click_activation();
- target.dispatch_event_with_target(None, event).ok();
+ target.dispatch_event(event);
if !event.DefaultPrevented() {
// post click activation
elem.activation_behavior();
@@ -1271,10 +1271,10 @@ impl<'a> ActivationElementHelpers<'a> for JSRef<'a, Element> {
}
}
// Step 6
- None => {target.dispatch_event_with_target(None, event).ok();}
+ None => {target.dispatch_event(event);}
},
// Step 6
- None => {target.dispatch_event_with_target(None, event).ok();}
+ None => {target.dispatch_event(event);}
}
// Step 7
self.set_click_in_progress(false);
diff --git a/components/script/dom/eventdispatcher.rs b/components/script/dom/eventdispatcher.rs
index bdfb98c7bae..74ffc1f5136 100644
--- a/components/script/dom/eventdispatcher.rs
+++ b/components/script/dom/eventdispatcher.rs
@@ -16,6 +16,7 @@ pub fn dispatch_event<'a, 'b>(target: JSRef<'a, EventTarget>,
pseudo_target: Option<JSRef<'b, EventTarget>>,
event: JSRef<Event>) -> bool {
assert!(!event.dispatching());
+ assert!(event.initialized());
event.set_target(match pseudo_target {
Some(pseudo_target) => pseudo_target,
diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs
index 151a1ac939a..394b66e6acc 100644
--- a/components/script/dom/eventtarget.rs
+++ b/components/script/dom/eventtarget.rs
@@ -107,7 +107,8 @@ impl EventTarget {
pub trait EventTargetHelpers {
fn dispatch_event_with_target(self,
target: Option<JSRef<EventTarget>>,
- event: JSRef<Event>) -> Fallible<bool>;
+ event: JSRef<Event>) -> bool;
+ fn dispatch_event(self, event: JSRef<Event>) -> bool;
fn set_inline_event_listener(self,
ty: DOMString,
listener: Option<EventListener>);
@@ -128,11 +129,12 @@ pub trait EventTargetHelpers {
impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
fn dispatch_event_with_target(self,
target: Option<JSRef<EventTarget>>,
- event: JSRef<Event>) -> Fallible<bool> {
- if event.dispatching() || !event.initialized() {
- return Err(InvalidState);
- }
- Ok(dispatch_event(self, target, event))
+ event: JSRef<Event>) -> bool {
+ dispatch_event(self, target, event)
+ }
+
+ fn dispatch_event(self, event: JSRef<Event>) -> bool {
+ self.dispatch_event_with_target(None, event)
}
fn set_inline_event_listener(self,
@@ -290,7 +292,10 @@ impl<'a> EventTargetMethods for JSRef<'a, EventTarget> {
}
fn DispatchEvent(self, event: JSRef<Event>) -> Fallible<bool> {
- self.dispatch_event_with_target(None, event)
+ if event.dispatching() || !event.initialized() {
+ return Err(InvalidState);
+ }
+ Ok(self.dispatch_event(event))
}
}
diff --git a/components/script/dom/messageevent.rs b/components/script/dom/messageevent.rs
index 32842fd2897..9dda3ccc8cc 100644
--- a/components/script/dom/messageevent.rs
+++ b/components/script/dom/messageevent.rs
@@ -81,7 +81,7 @@ impl MessageEvent {
scope, "message".to_string(), false, false, message,
"".to_string(), "".to_string()).root();
let event: JSRef<Event> = EventCast::from_ref(*messageevent);
- target.dispatch_event_with_target(None, event).unwrap();
+ target.dispatch_event(event);
}
}
diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs
index 0f8e770d8d5..b5f580fc6a5 100644
--- a/components/script/dom/xmlhttprequest.rs
+++ b/components/script/dom/xmlhttprequest.rs
@@ -817,7 +817,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> {
"readystatechange".to_string(),
DoesNotBubble, Cancelable).root();
let target: JSRef<EventTarget> = EventTargetCast::from_ref(self);
- target.dispatch_event_with_target(None, *event).ok();
+ target.dispatch_event(*event);
}
fn process_partial_response(self, progress: XHRProgress) {
@@ -957,7 +957,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> {
EventTargetCast::from_ref(self)
};
let event: JSRef<Event> = EventCast::from_ref(*progressevent);
- target.dispatch_event_with_target(None, event).ok();
+ target.dispatch_event(event);
}
fn dispatch_upload_progress_event(self, type_: DOMString, partial_load: Option<u64>) {