mirror of
https://github.com/servo/servo.git
synced 2025-06-24 09:04:33 +01:00
Add MouseEvent::new_uninitialized().
This commit is contained in:
parent
ac288f6657
commit
5f8f551c95
2 changed files with 33 additions and 9 deletions
|
@ -532,8 +532,8 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
|
|
||||||
match interface.to_ascii_lower().as_slice() {
|
match interface.to_ascii_lower().as_slice() {
|
||||||
// FIXME: Implement CustomEvent (http://dom.spec.whatwg.org/#customevent)
|
// 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))),
|
"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)),
|
"htmlevents" | "events" | "event" => Ok(Event::new(&*window)),
|
||||||
_ => Err(NotSupported)
|
_ => Err(NotSupported)
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,22 +51,46 @@ impl MouseEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(window: &JSRef<Window>) -> Temporary<MouseEvent> {
|
pub fn new_uninitialized(window: &JSRef<Window>) -> Temporary<MouseEvent> {
|
||||||
reflect_dom_object(~MouseEvent::new_inherited(),
|
reflect_dom_object(~MouseEvent::new_inherited(),
|
||||||
window,
|
window,
|
||||||
MouseEventBinding::Wrap)
|
MouseEventBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn new(window: &JSRef<Window>,
|
||||||
|
type_: DOMString,
|
||||||
|
canBubble: bool,
|
||||||
|
cancelable: bool,
|
||||||
|
view: Option<JSRef<Window>>,
|
||||||
|
detail: i32,
|
||||||
|
screenX: i32,
|
||||||
|
screenY: i32,
|
||||||
|
clientX: i32,
|
||||||
|
clientY: i32,
|
||||||
|
ctrlKey: bool,
|
||||||
|
altKey: bool,
|
||||||
|
shiftKey: bool,
|
||||||
|
metaKey: bool,
|
||||||
|
button: u16,
|
||||||
|
relatedTarget: Option<JSRef<EventTarget>>) -> Temporary<MouseEvent> {
|
||||||
|
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<Window>,
|
pub fn Constructor(owner: &JSRef<Window>,
|
||||||
type_: DOMString,
|
type_: DOMString,
|
||||||
init: &MouseEventBinding::MouseEventInit) -> Fallible<Temporary<MouseEvent>> {
|
init: &MouseEventBinding::MouseEventInit) -> Fallible<Temporary<MouseEvent>> {
|
||||||
let mut ev = MouseEvent::new(owner).root();
|
let event = MouseEvent::new(owner, type_, init.bubbles, init.cancelable,
|
||||||
ev.InitMouseEvent(type_, init.bubbles, init.cancelable, init.view.root_ref(),
|
init.view.root_ref(),
|
||||||
init.detail, init.screenX, init.screenY,
|
init.detail, init.screenX, init.screenY,
|
||||||
init.clientX, init.clientY, init.ctrlKey,
|
init.clientX, init.clientY, init.ctrlKey,
|
||||||
init.altKey, init.shiftKey, init.metaKey,
|
init.altKey, init.shiftKey, init.metaKey,
|
||||||
init.button, init.relatedTarget.root_ref());
|
init.button, init.relatedTarget.root_ref());
|
||||||
Ok(Temporary::from_rooted(&*ev))
|
Ok(event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue