diff options
author | Josh Matthews <josh@joshmatthews.net> | 2014-03-28 10:17:56 -0400 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2014-05-03 14:18:30 -0400 |
commit | ffdc3f5b32a345b88eed774848924e862d47c093 (patch) | |
tree | 047371062d728fecca45229a3e2cf87407410ba0 /src/components/script/dom/documentfragment.rs | |
parent | 4051a8096d7ba7e7f9c86e76d0b4bffd83e85805 (diff) | |
download | servo-ffdc3f5b32a345b88eed774848924e862d47c093.tar.gz servo-ffdc3f5b32a345b88eed774848924e862d47c093.zip |
Turn on GC all the time. Fix rooting errors during parsing and storing timers. Fix borrow errors during tracing.
Diffstat (limited to 'src/components/script/dom/documentfragment.rs')
-rw-r--r-- | src/components/script/dom/documentfragment.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/components/script/dom/documentfragment.rs b/src/components/script/dom/documentfragment.rs index 7346a5a98ef..e10e9e1204c 100644 --- a/src/components/script/dom/documentfragment.rs +++ b/src/components/script/dom/documentfragment.rs @@ -4,12 +4,12 @@ use dom::bindings::codegen::InheritTypes::{DocumentFragmentDerived, NodeCast}; use dom::bindings::codegen::BindingDeclarations::DocumentFragmentBinding; -use dom::bindings::js::JS; +use dom::bindings::js::{JS, JSRef, RootCollection}; use dom::bindings::error::Fallible; use dom::document::Document; use dom::eventtarget::{EventTarget, NodeTargetTypeId}; use dom::htmlcollection::HTMLCollection; -use dom::node::{DocumentFragmentNodeTypeId, Node}; +use dom::node::{DocumentFragmentNodeTypeId, Node, window_from_node}; use dom::window::Window; #[deriving(Encodable)] @@ -34,22 +34,26 @@ impl DocumentFragment { } } - pub fn new(document: &JS<Document>) -> JS<DocumentFragment> { - let node = DocumentFragment::new_inherited(document.clone()); + pub fn new(document: &JSRef<Document>) -> JS<DocumentFragment> { + let node = DocumentFragment::new_inherited(document.unrooted()); Node::reflect_node(~node, document, DocumentFragmentBinding::Wrap) } } impl DocumentFragment { - pub fn Constructor(owner: &JS<Window>) -> Fallible<JS<DocumentFragment>> { - Ok(DocumentFragment::new(&owner.get().Document())) + pub fn Constructor(owner: &JSRef<Window>) -> Fallible<JS<DocumentFragment>> { + let roots = RootCollection::new(); + let document = owner.get().Document(); + let document = document.root(&roots); + + Ok(DocumentFragment::new(&document.root_ref())) } } impl DocumentFragment { - pub fn Children(&self, abstract_self: &JS<DocumentFragment>) -> JS<HTMLCollection> { - let doc = self.node.owner_doc(); - let doc = doc.get(); - HTMLCollection::children(&doc.window, &NodeCast::from(abstract_self)) + pub fn Children(&self, abstract_self: &JSRef<DocumentFragment>) -> JS<HTMLCollection> { + let roots = RootCollection::new(); + let window = window_from_node(&abstract_self.unrooted()).root(&roots); + HTMLCollection::children(&window.root_ref(), NodeCast::from_ref(abstract_self)) } } |