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

@ -103,10 +103,16 @@ fn dispatch_to_listeners(event: &Event, target: &EventTarget, event_path: &[&Eve
}
}
#[derive(PartialEq)]
pub enum EventStatus {
Canceled,
NotCanceled
}
// https://dom.spec.whatwg.org/#concept-event-dispatch
pub fn dispatch_event(target: &EventTarget,
target_override: Option<&EventTarget>,
event: &Event) -> bool {
event: &Event) -> EventStatus {
assert!(!event.dispatching());
assert!(event.initialized());
assert_eq!(event.phase(), EventPhase::None);
@ -126,7 +132,7 @@ pub fn dispatch_event(target: &EventTarget,
event.clear_dispatching_flags();
// Step 14.
return !event.DefaultPrevented();
return event.status();
}
// Step 3. The "invoke" algorithm is only used on `target` separately,
@ -165,8 +171,8 @@ pub fn dispatch_event(target: &EventTarget,
// Step 10-12.
event.clear_dispatching_flags();
// Step 13.
!event.DefaultPrevented()
// Step 14.
event.status()
}
// https://dom.spec.whatwg.org/#concept-event-listener-invoke