Make dictionaries contain Root<T> values instead of JS<T>, ensuring that they will not be collected while the dictionary is alive.

This commit is contained in:
Josh Matthews 2014-04-24 11:44:53 -04:00
parent 0f2d0b1dc3
commit 895e9ee37f
5 changed files with 20 additions and 11 deletions

View file

@ -61,13 +61,11 @@ impl MouseEvent {
type_: DOMString,
init: &MouseEventBinding::MouseEventInit) -> Fallible<Temporary<MouseEvent>> {
let mut ev = MouseEvent::new(owner).root();
let view = init.view.as_ref().map(|view| view.root());
let related_target = init.relatedTarget.as_ref().map(|relatedTarget| relatedTarget.root());
ev.InitMouseEvent(type_, init.bubbles, init.cancelable, view.root_ref(),
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, related_target.root_ref());
init.button, init.relatedTarget.root_ref());
Ok(Temporary::from_rooted(&*ev))
}
}