Rewrite DocumentType::new to current standards.

This commit is contained in:
Ms2ger 2013-11-02 21:34:44 +01:00
parent 655a2099ef
commit 8c388f6bd4
2 changed files with 28 additions and 13 deletions

View file

@ -2,9 +2,10 @@
* 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::DocumentTypeBinding;
use dom::bindings::utils::DOMString; use dom::bindings::utils::DOMString;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::node::{ScriptView, Node, DoctypeNodeTypeId}; use dom::node::{AbstractNode, ScriptView, Node, DoctypeNodeTypeId};
/// The `DOCTYPE` tag. /// The `DOCTYPE` tag.
pub struct DocumentType { pub struct DocumentType {
@ -16,8 +17,7 @@ pub struct DocumentType {
} }
impl DocumentType { impl DocumentType {
/// Creates a new `DOCTYPE` tag. pub fn new_inherited(name: ~str,
pub fn new(name: ~str,
public_id: Option<~str>, public_id: Option<~str>,
system_id: Option<~str>, system_id: Option<~str>,
force_quirks: bool, force_quirks: bool,
@ -32,6 +32,21 @@ impl DocumentType {
} }
} }
pub fn new(name: ~str,
public_id: Option<~str>,
system_id: Option<~str>,
force_quirks: bool,
document: AbstractDocument) -> AbstractNode<ScriptView> {
let documenttype = DocumentType::new_inherited(name,
public_id,
system_id,
force_quirks,
document);
Node::reflect_node(@mut documenttype, document, DocumentTypeBinding::Wrap)
}
}
impl DocumentType {
pub fn Name(&self) -> DOMString { pub fn Name(&self) -> DOMString {
Some(self.name.clone()) Some(self.name.clone())
} }

View file

@ -325,13 +325,13 @@ pub fn parse_html(cx: *JSContext,
public_id: public_id, public_id: public_id,
system_id: system_id, system_id: system_id,
force_quirks: force_quirks } = doctype; force_quirks: force_quirks } = doctype;
let node = @DocumentType::new(name, let node = DocumentType::new(name,
public_id, public_id,
system_id, system_id,
force_quirks, force_quirks,
document); document);
unsafe { unsafe {
Node::as_abstract_node(cx, node).to_hubbub_node() node.to_hubbub_node()
} }
}, },
create_element: |tag: ~hubbub::Tag| { create_element: |tag: ~hubbub::Tag| {