From 8c388f6bd4650858faedf19ed90262507447b00d Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 2 Nov 2013 21:34:44 +0100 Subject: [PATCH] Rewrite DocumentType::new to current standards. --- src/components/script/dom/documenttype.rs | 29 ++++++++++++++----- .../script/html/hubbub_html_parser.rs | 12 ++++---- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/components/script/dom/documenttype.rs b/src/components/script/dom/documenttype.rs index 97d339f797e..463ddcfa239 100644 --- a/src/components/script/dom/documenttype.rs +++ b/src/components/script/dom/documenttype.rs @@ -2,9 +2,10 @@ * 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::DocumentTypeBinding; use dom::bindings::utils::DOMString; use dom::document::AbstractDocument; -use dom::node::{ScriptView, Node, DoctypeNodeTypeId}; +use dom::node::{AbstractNode, ScriptView, Node, DoctypeNodeTypeId}; /// The `DOCTYPE` tag. pub struct DocumentType { @@ -16,12 +17,11 @@ pub struct DocumentType { } impl DocumentType { - /// Creates a new `DOCTYPE` tag. - pub fn new(name: ~str, - public_id: Option<~str>, - system_id: Option<~str>, - force_quirks: bool, - document: AbstractDocument) + pub fn new_inherited(name: ~str, + public_id: Option<~str>, + system_id: Option<~str>, + force_quirks: bool, + document: AbstractDocument) -> DocumentType { DocumentType { node: Node::new(DoctypeNodeTypeId, document), @@ -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 { + 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 { Some(self.name.clone()) } diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs index f1622d8215e..d9813d502f4 100644 --- a/src/components/script/html/hubbub_html_parser.rs +++ b/src/components/script/html/hubbub_html_parser.rs @@ -325,13 +325,13 @@ pub fn parse_html(cx: *JSContext, public_id: public_id, system_id: system_id, force_quirks: force_quirks } = doctype; - let node = @DocumentType::new(name, - public_id, - system_id, - force_quirks, - document); + let node = DocumentType::new(name, + public_id, + system_id, + force_quirks, + document); unsafe { - Node::as_abstract_node(cx, node).to_hubbub_node() + node.to_hubbub_node() } }, create_element: |tag: ~hubbub::Tag| {