diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index 9c51aa6d1c7..3005d23c5f9 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -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) - "mouseevents" | "mouseevent" => Ok(EventCast::from_temporary(MouseEvent::new(&*window))), "uievents" | "uievent" => Ok(EventCast::from_temporary(UIEvent::new_uninitialized(&*window))), + "mouseevents" | "mouseevent" => Ok(EventCast::from_temporary(MouseEvent::new_uninitialized(&*window))), "htmlevents" | "events" | "event" => Ok(Event::new(&*window)), _ => Err(NotSupported) } diff --git a/src/components/script/dom/mouseevent.rs b/src/components/script/dom/mouseevent.rs index fbd0abfc4d4..32c7704b291 100644 --- a/src/components/script/dom/mouseevent.rs +++ b/src/components/script/dom/mouseevent.rs @@ -51,22 +51,46 @@ impl MouseEvent { } } - pub fn new(window: &JSRef) -> Temporary { + pub fn new_uninitialized(window: &JSRef) -> Temporary { reflect_dom_object(~MouseEvent::new_inherited(), window, MouseEventBinding::Wrap) } + pub fn new(window: &JSRef, + type_: DOMString, + canBubble: bool, + cancelable: bool, + view: Option>, + detail: i32, + screenX: i32, + screenY: i32, + clientX: i32, + clientY: i32, + ctrlKey: bool, + altKey: bool, + shiftKey: bool, + metaKey: bool, + button: u16, + relatedTarget: Option>) -> Temporary { + let mut ev = MouseEvent::new_uninitialized(window).root(); + ev.InitMouseEvent(type_, canBubble, cancelable, view, detail, + screenX, screenY, clientX, clientY, + ctrlKey, altKey, shiftKey, metaKey, + button, relatedTarget); + Temporary::from_rooted(&*ev) + } + pub fn Constructor(owner: &JSRef, type_: DOMString, init: &MouseEventBinding::MouseEventInit) -> Fallible> { - let mut ev = MouseEvent::new(owner).root(); - ev.InitMouseEvent(type_, init.bubbles, init.cancelable, init.view.root_ref(), - init.detail, init.screenX, init.screenY, - init.clientX, init.clientY, init.ctrlKey, - init.altKey, init.shiftKey, init.metaKey, - init.button, init.relatedTarget.root_ref()); - Ok(Temporary::from_rooted(&*ev)) + let event = MouseEvent::new(owner, type_, init.bubbles, init.cancelable, + init.view.root_ref(), + init.detail, init.screenX, init.screenY, + init.clientX, init.clientY, init.ctrlKey, + init.altKey, init.shiftKey, init.metaKey, + init.button, init.relatedTarget.root_ref()); + Ok(event) } }