Implement Event::new_initialized and initialize the event in Event::new.

This commit is contained in:
Ms2ger 2014-05-31 10:42:21 +02:00
parent d7cac61d9c
commit d896442a4a
4 changed files with 22 additions and 13 deletions

View file

@ -83,18 +83,25 @@ impl Event {
}
}
pub fn new(window: &JSRef<Window>) -> Temporary<Event> {
pub fn new_uninitialized(window: &JSRef<Window>) -> Temporary<Event> {
reflect_dom_object(box Event::new_inherited(HTMLEventTypeId),
window,
EventBinding::Wrap)
}
pub fn new(window: &JSRef<Window>,
type_: DOMString,
can_bubble: bool,
cancelable: bool) -> Temporary<Event> {
let mut event = Event::new_uninitialized(window).root();
event.InitEvent(type_, can_bubble, cancelable);
Temporary::from_rooted(&*event)
}
pub fn Constructor(global: &JSRef<Window>,
type_: DOMString,
init: &EventBinding::EventInit) -> Fallible<Temporary<Event>> {
let mut ev = Event::new(global).root();
ev.InitEvent(type_, init.bubbles, init.cancelable);
Ok(Temporary::from_rooted(&*ev))
Ok(Event::new(global, type_, init.bubbles, init.cancelable))
}
}