Return an enum instead of a boolean from dispatch_event

Fixes #13196
This commit is contained in:
Adolfo Ochagavía 2016-09-23 17:51:24 +02:00
parent 821797d6f7
commit 6c8bfdb774
7 changed files with 45 additions and 17 deletions

View file

@ -18,6 +18,7 @@ use dom::bindings::str::DOMString;
use dom::document::Document;
use dom::element::{AttributeMutation, Element, ElementCreator};
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::eventdispatcher::EventStatus;
use dom::htmlelement::HTMLElement;
use dom::node::{ChildrenMutation, CloneChildrenFlag, Node};
use dom::node::{document_from_node, window_from_node};
@ -444,7 +445,7 @@ impl HTMLScriptElement {
}
// TODO(#12446): beforescriptexecute.
if !self.dispatch_before_script_execute_event() {
if self.dispatch_before_script_execute_event() == EventStatus::Canceled {
return;
}
@ -491,7 +492,7 @@ impl HTMLScriptElement {
window.dom_manipulation_task_source().queue_simple_event(self.upcast(), atom!("error"), window.r());
}
pub fn dispatch_before_script_execute_event(&self) -> bool {
pub fn dispatch_before_script_execute_event(&self) -> EventStatus {
self.dispatch_event(atom!("beforescriptexecute"),
EventBubbles::Bubbles,
EventCancelable::Cancelable)
@ -562,7 +563,7 @@ impl HTMLScriptElement {
fn dispatch_event(&self,
type_: Atom,
bubbles: EventBubbles,
cancelable: EventCancelable) -> bool {
cancelable: EventCancelable) -> EventStatus {
let window = window_from_node(self);
let window = window.r();
let event = Event::new(GlobalRef::Window(window), type_, bubbles, cancelable);