Auto merge of #13014 - nox:dispatch, r=Ms2ger

Fix step 10 of eventdispatcher::dispatch_event (fixes #11609)

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13014)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-08-24 07:17:22 -05:00 committed by GitHub
commit ccf79de66e
3 changed files with 19 additions and 21 deletions

View file

@ -153,11 +153,6 @@ impl Event {
self.cancelable.set(cancelable); self.cancelable.set(cancelable);
} }
#[inline]
pub fn clear_current_target(&self) {
self.current_target.set(None);
}
#[inline] #[inline]
pub fn set_current_target(&self, val: &EventTarget) { pub fn set_current_target(&self, val: &EventTarget) {
self.current_target.set(Some(val)); self.current_target.set(Some(val));
@ -199,8 +194,22 @@ impl Event {
} }
#[inline] #[inline]
pub fn set_dispatching(&self, val: bool) { // https://dom.spec.whatwg.org/#concept-event-dispatch Step 1.
self.dispatching.set(val) pub fn mark_as_dispatching(&self) {
assert!(!self.dispatching.get());
self.dispatching.set(true);
}
#[inline]
// https://dom.spec.whatwg.org/#concept-event-dispatch Steps 10-12.
pub fn clear_dispatching_flags(&self) {
assert!(self.dispatching.get());
self.dispatching.set(false);
self.stop_propagation.set(false);
self.stop_immediate.set(false);
self.set_phase(EventPhase::None);
self.current_target.set(None);
} }
#[inline] #[inline]

View file

@ -123,7 +123,7 @@ pub fn dispatch_event(target: &EventTarget,
} }
// Step 1. Postponed here for the reason stated above. // Step 1. Postponed here for the reason stated above.
event.set_dispatching(true); event.mark_as_dispatching();
// Step 3. The "invoke" algorithm is only used on `target` separately, // Step 3. The "invoke" algorithm is only used on `target` separately,
// so we don't put it in the path. // so we don't put it in the path.
@ -158,14 +158,8 @@ pub fn dispatch_event(target: &EventTarget,
None => {} None => {}
} }
// Step 10. // Step 10-12.
event.set_dispatching(false); event.clear_dispatching_flags();
// Step 11.
event.set_phase(EventPhase::None);
// Step 12.
event.clear_current_target();
// Step 13. // Step 13.
!event.DefaultPrevented() !event.DefaultPrevented()

View file

@ -1,5 +0,0 @@
[Event-dispatch-multiple-stopPropagation.html]
type: testharness
[ Multiple dispatchEvent() and stopPropagation() ]
expected: FAIL