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> { pub fn CreateDocumentFragment(&self, abstract_self: AbstractDocument) -> AbstractNode<ScriptView> {
let cx = self.get_cx(); DocumentFragment::new(abstract_self)
let fragment = @DocumentFragment::new(abstract_self);
unsafe { Node::as_abstract_node(cx, fragment) }
} }
pub fn CreateTextNode(&self, abstract_self: AbstractDocument, data: &DOMString) -> AbstractNode<ScriptView> { 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 * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::DocumentFragmentBinding;
use dom::bindings::utils::Fallible; use dom::bindings::utils::Fallible;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::node::{ScriptView, Node, DocumentFragmentNodeTypeId}; use dom::node::{ScriptView, Node, DocumentFragmentNodeTypeId};
@ -14,15 +15,20 @@ pub struct DocumentFragment {
impl DocumentFragment { impl DocumentFragment {
/// Creates a new DocumentFragment. /// Creates a new DocumentFragment.
pub fn new(document: AbstractDocument) -> DocumentFragment { pub fn new_inherited(document: AbstractDocument) -> DocumentFragment {
DocumentFragment { DocumentFragment {
node: Node::new(DocumentFragmentNodeTypeId, document), node: Node::new(DocumentFragmentNodeTypeId, document),
} }
} }
pub fn Constructor(owner: @mut Window) -> Fallible<AbstractNode<ScriptView>> { pub fn new(document: AbstractDocument) -> AbstractNode<ScriptView> {
let cx = owner.get_cx(); let node = DocumentFragment::new_inherited(document);
let fragment = @DocumentFragment::new(owner.Document()); Node::reflect_node(@mut node, document, DocumentFragmentBinding::Wrap)
Ok(unsafe { Node::as_abstract_node(cx, fragment) }) }
}
impl DocumentFragment {
pub fn Constructor(owner: @mut Window) -> Fallible<AbstractNode<ScriptView>> {
Ok(DocumentFragment::new(owner.Document()))
} }
} }