Implement JSManaged for DOM objects.

This commit is contained in:
Josh Matthews 2013-11-30 21:04:49 +01:00
parent 061269f963
commit 625325434b
137 changed files with 3644 additions and 2778 deletions

View file

@ -2,32 +2,45 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::InheritTypes::DocumentFragmentDerived;
use dom::bindings::codegen::DocumentFragmentBinding;
use dom::bindings::js::JS;
use dom::bindings::utils::Fallible;
use dom::document::AbstractDocument;
use dom::node::{AbstractNode, DocumentFragmentNodeTypeId, Node};
use dom::document::Document;
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::node::{DocumentFragmentNodeTypeId, Node};
use dom::window::Window;
#[deriving(Encodable)]
pub struct DocumentFragment {
node: Node,
}
impl DocumentFragmentDerived for EventTarget {
fn is_documentfragment(&self) -> bool {
match self.type_id {
NodeTargetTypeId(DocumentFragmentNodeTypeId) => true,
_ => false
}
}
}
impl DocumentFragment {
/// Creates a new DocumentFragment.
pub fn new_inherited(document: AbstractDocument) -> DocumentFragment {
pub fn new_inherited(document: JS<Document>) -> DocumentFragment {
DocumentFragment {
node: Node::new_inherited(DocumentFragmentNodeTypeId, document),
}
}
pub fn new(document: AbstractDocument) -> AbstractNode {
let node = DocumentFragment::new_inherited(document);
Node::reflect_node(@mut node, document, DocumentFragmentBinding::Wrap)
pub fn new(document: &JS<Document>) -> JS<DocumentFragment> {
let node = DocumentFragment::new_inherited(document.clone());
Node::reflect_node(~node, document, DocumentFragmentBinding::Wrap)
}
}
impl DocumentFragment {
pub fn Constructor(owner: @mut Window) -> Fallible<AbstractNode> {
Ok(DocumentFragment::new(owner.Document()))
pub fn Constructor(owner: &JS<Window>) -> Fallible<JS<DocumentFragment>> {
Ok(DocumentFragment::new(&owner.get().Document()))
}
}