Return a Temporary from *Binding::Wrap.

Returning a JS<T> is GC-unsafe.

This commit also includes some cleanup around Node and Document reflection.
This commit is contained in:
Ms2ger 2014-07-10 16:40:41 +02:00
parent 360d5d01d8
commit 439bc78cab
5 changed files with 16 additions and 28 deletions

View file

@ -907,13 +907,10 @@ impl Node {
pub fn reflect_node<N: Reflectable+NodeBase>
(node: Box<N>,
document: &JSRef<Document>,
wrap_fn: extern "Rust" fn(*mut JSContext, &JSRef<Window>, Box<N>) -> JS<N>)
wrap_fn: extern "Rust" fn(*mut JSContext, &JSRef<Window>, Box<N>) -> Temporary<N>)
-> Temporary<N> {
assert!(node.reflector().get_jsobject().is_null());
let window = document.deref().window.root();
let node = reflect_dom_object(node, &window.root_ref(), wrap_fn).root();
assert!(node.deref().reflector().get_jsobject().is_not_null());
Temporary::from_rooted(&*node)
let window = document.window.root();
reflect_dom_object(node, &*window, wrap_fn)
}
pub fn new_inherited(type_id: NodeTypeId, doc: &JSRef<Document>) -> Node {