mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Implement Event::new_initialized and initialize the event in Event::new.
This commit is contained in:
parent
d7cac61d9c
commit
d896442a4a
4 changed files with 22 additions and 13 deletions
|
@ -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))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue