Remove "fire a simple event" concept, refactor event firing API.

"fire a simple event" concept was removed in
https://github.com/whatwg/html/pull/1933.
This commit is contained in:
Corey Farwell 2016-11-02 22:44:51 -04:00
parent 5b4cc9568d
commit c3b279a4c3
15 changed files with 58 additions and 52 deletions

View file

@ -490,21 +490,42 @@ impl EventTarget {
!self.handlers.borrow().is_empty()
}
// https://html.spec.whatwg.org/multipage/#fire-a-simple-event
pub fn fire_simple_event(&self, name: &str) -> Root<Event> {
self.fire_event(name, EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable)
// https://dom.spec.whatwg.org/#concept-event-fire
pub fn fire_event(&self, name: &str) -> Root<Event> {
self.fire_event_with_params(name,
EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable)
}
// https://dom.spec.whatwg.org/#concept-event-fire
pub fn fire_event(&self, name: &str,
bubbles: EventBubbles,
cancelable: EventCancelable)
-> Root<Event> {
pub fn fire_bubbling_event(&self, name: &str) -> Root<Event> {
self.fire_event_with_params(name,
EventBubbles::Bubbles,
EventCancelable::NotCancelable)
}
// https://dom.spec.whatwg.org/#concept-event-fire
pub fn fire_cancelable_event(&self, name: &str) -> Root<Event> {
self.fire_event_with_params(name,
EventBubbles::DoesNotBubble,
EventCancelable::Cancelable)
}
// https://dom.spec.whatwg.org/#concept-event-fire
pub fn fire_bubbling_cancelable_event(&self, name: &str) -> Root<Event> {
self.fire_event_with_params(name,
EventBubbles::Bubbles,
EventCancelable::Cancelable)
}
// https://dom.spec.whatwg.org/#concept-event-fire
pub fn fire_event_with_params(&self,
name: &str,
bubbles: EventBubbles,
cancelable: EventCancelable)
-> Root<Event> {
let event = Event::new(&self.global(), Atom::from(name), bubbles, cancelable);
event.fire(self);
event
}
}