Implement safe rooting strategy via Unrooted, Root, JSRef, and JS.

This commit is contained in:
Josh Matthews 2014-03-31 18:41:28 -04:00
parent ffdc3f5b32
commit d7b96db33c
109 changed files with 1568 additions and 1326 deletions

View file

@ -4,7 +4,7 @@
use dom::bindings::codegen::BindingDeclarations::HTMLFormElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLFormElementDerived;
use dom::bindings::js::{JS, JSRef, RootCollection};
use dom::bindings::js::{JS, JSRef, RootCollection, Unrooted};
use dom::bindings::error::ErrorResult;
use dom::document::Document;
use dom::element::{Element, HTMLFormElementTypeId};
@ -35,7 +35,7 @@ impl HTMLFormElement {
}
}
pub fn new(localName: DOMString, document: &JSRef<Document>) -> JS<HTMLFormElement> {
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Unrooted<HTMLFormElement> {
let element = HTMLFormElement::new_inherited(localName, document.unrooted());
Node::reflect_node(~element, document, HTMLFormElementBinding::Wrap)
}
@ -114,13 +114,12 @@ impl HTMLFormElement {
Ok(())
}
pub fn Elements(&self) -> JS<HTMLCollection> {
pub fn Elements(&self) -> Unrooted<HTMLCollection> {
// FIXME: https://github.com/mozilla/servo/issues/1844
let roots = RootCollection::new();
let doc = self.htmlelement.element.node.owner_doc();
let doc = doc.get();
let window = doc.window.root(&roots);
HTMLCollection::new(&window.root_ref(), Static(vec!()))
let doc = self.htmlelement.element.node.owner_doc().root(&roots);
let window = doc.deref().window.root(&roots);
HTMLCollection::new(&*window, Static(vec!()))
}
pub fn Length(&self) -> i32 {
@ -138,7 +137,7 @@ impl HTMLFormElement {
false
}
pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> JS<Element> {
pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Unrooted<Element> {
fail!("Not implemented.")
}
}