mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Use early returns in dispatch_to_listeners.
This commit is contained in:
parent
995cb21b48
commit
af6bc108f3
1 changed files with 15 additions and 11 deletions
|
@ -37,26 +37,30 @@ fn dispatch_to_listeners(event: &Event, target: &EventTarget, chain: &[&EventTar
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if event.stop_propagation() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* at target */
|
/* at target */
|
||||||
if !event.stop_propagation() {
|
event.set_phase(EventPhase::AtTarget);
|
||||||
event.set_phase(EventPhase::AtTarget);
|
event.set_current_target(target.clone());
|
||||||
event.set_current_target(target.clone());
|
|
||||||
|
|
||||||
if let Some(listeners) = target.get_listeners(&type_) {
|
if let Some(listeners) = target.get_listeners(&type_) {
|
||||||
for listener in listeners {
|
for listener in listeners {
|
||||||
// Explicitly drop any exception on the floor.
|
// Explicitly drop any exception on the floor.
|
||||||
listener.call_or_handle_event(target, event, Report);
|
listener.call_or_handle_event(target, event, Report);
|
||||||
|
|
||||||
if event.stop_immediate() {
|
if event.stop_immediate() {
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if event.stop_propagation() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* bubbling */
|
/* bubbling */
|
||||||
if event.bubbles() && !event.stop_propagation() {
|
if event.bubbles() {
|
||||||
event.set_phase(EventPhase::Bubbling);
|
event.set_phase(EventPhase::Bubbling);
|
||||||
|
|
||||||
for cur_target in chain {
|
for cur_target in chain {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue