Rewrite DocumentFragment::new to current standards.

This commit is contained in:
Ms2ger 2013-11-02 22:23:44 +01:00
parent a431202989
commit 78e51c8309
2 changed files with 12 additions and 8 deletions

View file

@ -244,9 +244,7 @@ impl Document {
}
pub fn CreateDocumentFragment(&self, abstract_self: AbstractDocument) -> AbstractNode<ScriptView> {
let cx = self.get_cx();
let fragment = @DocumentFragment::new(abstract_self);
unsafe { Node::as_abstract_node(cx, fragment) }
DocumentFragment::new(abstract_self)
}
pub fn CreateTextNode(&self, abstract_self: AbstractDocument, data: &DOMString) -> AbstractNode<ScriptView> {

View file

@ -2,6 +2,7 @@
* 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::DocumentFragmentBinding;
use dom::bindings::utils::Fallible;
use dom::document::AbstractDocument;
use dom::node::{ScriptView, Node, DocumentFragmentNodeTypeId};
@ -14,15 +15,20 @@ pub struct DocumentFragment {
impl DocumentFragment {
/// Creates a new DocumentFragment.
pub fn new(document: AbstractDocument) -> DocumentFragment {
pub fn new_inherited(document: AbstractDocument) -> DocumentFragment {
DocumentFragment {
node: Node::new(DocumentFragmentNodeTypeId, document),
}
}
pub fn new(document: AbstractDocument) -> AbstractNode<ScriptView> {
let node = DocumentFragment::new_inherited(document);
Node::reflect_node(@mut node, document, DocumentFragmentBinding::Wrap)
}
}
impl DocumentFragment {
pub fn Constructor(owner: @mut Window) -> Fallible<AbstractNode<ScriptView>> {
let cx = owner.get_cx();
let fragment = @DocumentFragment::new(owner.Document());
Ok(unsafe { Node::as_abstract_node(cx, fragment) })
Ok(DocumentFragment::new(owner.Document()))
}
}