Add UIEvent::new_uninitialized().

This commit is contained in:
Tetsuharu OHZEKI 2014-05-10 01:17:52 +09:00
parent 146eccdf80
commit ac288f6657
3 changed files with 20 additions and 10 deletions

View file

@ -532,8 +532,8 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
match interface.to_ascii_lower().as_slice() {
// FIXME: Implement CustomEvent (http://dom.spec.whatwg.org/#customevent)
"uievents" | "uievent" => Ok(EventCast::from_temporary(UIEvent::new(&*window))),
"mouseevents" | "mouseevent" => Ok(EventCast::from_temporary(MouseEvent::new(&*window))),
"uievents" | "uievent" => Ok(EventCast::from_temporary(UIEvent::new_uninitialized(&*window))),
"htmlevents" | "events" | "event" => Ok(Event::new(&*window)),
_ => Err(NotSupported)
}

View file

@ -36,19 +36,30 @@ impl UIEvent {
}
}
pub fn new(window: &JSRef<Window>) -> Temporary<UIEvent> {
pub fn new_uninitialized(window: &JSRef<Window>) -> Temporary<UIEvent> {
reflect_dom_object(~UIEvent::new_inherited(UIEventTypeId),
window,
UIEventBinding::Wrap)
}
pub fn new(window: &JSRef<Window>,
type_: DOMString,
can_bubble: bool,
cancelable: bool,
view: Option<JSRef<Window>>,
detail: i32) -> Temporary<UIEvent> {
let mut ev = UIEvent::new_uninitialized(window).root();
ev.InitUIEvent(type_, can_bubble, cancelable, view, detail);
Temporary::from_rooted(&*ev)
}
pub fn Constructor(owner: &JSRef<Window>,
type_: DOMString,
init: &UIEventBinding::UIEventInit) -> Fallible<Temporary<UIEvent>> {
let mut ev = UIEvent::new(owner).root();
ev.InitUIEvent(type_, init.parent.bubbles, init.parent.cancelable,
init.view.root_ref(), init.detail);
Ok(Temporary::from_rooted(&*ev))
let event = UIEvent::new(owner, type_,
init.parent.bubbles, init.parent.cancelable,
init.view.root_ref(), init.detail);
Ok(event)
}
}