aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/event.rs23
-rw-r--r--components/script/dom/eventdispatcher.rs12
-rw-r--r--tests/wpt/metadata/dom/events/Event-dispatch-multiple-stopPropagation.html.ini5
3 files changed, 19 insertions, 21 deletions
diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs
index da7664e0e19..07330a776ae 100644
--- a/components/script/dom/event.rs
+++ b/components/script/dom/event.rs
@@ -154,11 +154,6 @@ impl Event {
}
#[inline]
- pub fn clear_current_target(&self) {
- self.current_target.set(None);
- }
-
- #[inline]
pub fn set_current_target(&self, val: &EventTarget) {
self.current_target.set(Some(val));
}
@@ -199,8 +194,22 @@ impl Event {
}
#[inline]
- pub fn set_dispatching(&self, val: bool) {
- self.dispatching.set(val)
+ // https://dom.spec.whatwg.org/#concept-event-dispatch Step 1.
+ 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]
diff --git a/components/script/dom/eventdispatcher.rs b/components/script/dom/eventdispatcher.rs
index 7509df2ef13..01973e7c916 100644
--- a/components/script/dom/eventdispatcher.rs
+++ b/components/script/dom/eventdispatcher.rs
@@ -123,7 +123,7 @@ pub fn dispatch_event(target: &EventTarget,
}
// 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,
// so we don't put it in the path.
@@ -158,14 +158,8 @@ pub fn dispatch_event(target: &EventTarget,
None => {}
}
- // Step 10.
- event.set_dispatching(false);
-
- // Step 11.
- event.set_phase(EventPhase::None);
-
- // Step 12.
- event.clear_current_target();
+ // Step 10-12.
+ event.clear_dispatching_flags();
// Step 13.
!event.DefaultPrevented()
diff --git a/tests/wpt/metadata/dom/events/Event-dispatch-multiple-stopPropagation.html.ini b/tests/wpt/metadata/dom/events/Event-dispatch-multiple-stopPropagation.html.ini
deleted file mode 100644
index 5da27d7bc78..00000000000
--- a/tests/wpt/metadata/dom/events/Event-dispatch-multiple-stopPropagation.html.ini
+++ /dev/null
@@ -1,5 +0,0 @@
-[Event-dispatch-multiple-stopPropagation.html]
- type: testharness
- [ Multiple dispatchEvent() and stopPropagation() ]
- expected: FAIL
-