diff options
author | Ms2ger <Ms2ger@gmail.com> | 2015-09-16 13:47:13 +0200 |
---|---|---|
committer | Ms2ger <Ms2ger@gmail.com> | 2015-09-16 16:28:57 +0200 |
commit | af6bc108f345fceb1da02864cb7554f7abe78c02 (patch) | |
tree | 017a67f7e00a38848ba13d38010fd22f440dcfe4 | |
parent | 995cb21b481366f21aeb599236e68083d5c28781 (diff) | |
download | servo-af6bc108f345fceb1da02864cb7554f7abe78c02.tar.gz servo-af6bc108f345fceb1da02864cb7554f7abe78c02.zip |
Use early returns in dispatch_to_listeners.
-rw-r--r-- | components/script/dom/eventdispatcher.rs | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/components/script/dom/eventdispatcher.rs b/components/script/dom/eventdispatcher.rs index 51617a49a2d..6ac2d38e976 100644 --- a/components/script/dom/eventdispatcher.rs +++ b/components/script/dom/eventdispatcher.rs @@ -37,26 +37,30 @@ fn dispatch_to_listeners(event: &Event, target: &EventTarget, chain: &[&EventTar } } } + if event.stop_propagation() { + return; + } /* at target */ - if !event.stop_propagation() { - event.set_phase(EventPhase::AtTarget); - event.set_current_target(target.clone()); + event.set_phase(EventPhase::AtTarget); + event.set_current_target(target.clone()); - if let Some(listeners) = target.get_listeners(&type_) { - for listener in listeners { - // Explicitly drop any exception on the floor. - listener.call_or_handle_event(target, event, Report); + if let Some(listeners) = target.get_listeners(&type_) { + for listener in listeners { + // Explicitly drop any exception on the floor. + listener.call_or_handle_event(target, event, Report); - if event.stop_immediate() { - break; - } + if event.stop_immediate() { + break; } } } + if event.stop_propagation() { + return; + } /* bubbling */ - if event.bubbles() && !event.stop_propagation() { + if event.bubbles() { event.set_phase(EventPhase::Bubbling); for cur_target in chain { |