From 8796ca5c0250c11d6a6ca03c0982b2484179f7bb Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 2 Nov 2013 18:26:39 +0100 Subject: [PATCH] Introduce HTMLBodyElement::new. --- src/components/script/dom/htmlbodyelement.rs | 17 +++++++++++++++++ .../script/html/hubbub_html_parser.rs | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/components/script/dom/htmlbodyelement.rs b/src/components/script/dom/htmlbodyelement.rs index 3f409a23789..2dea5fdcbfa 100644 --- a/src/components/script/dom/htmlbodyelement.rs +++ b/src/components/script/dom/htmlbodyelement.rs @@ -2,13 +2,30 @@ * 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::HTMLBodyElementBinding; use dom::bindings::utils::{DOMString, ErrorResult}; +use dom::document::AbstractDocument; +use dom::element::HTMLBodyElementTypeId; use dom::htmlelement::HTMLElement; +use dom::node::{AbstractNode, Node, ScriptView}; pub struct HTMLBodyElement { htmlelement: HTMLElement } +impl HTMLBodyElement { + pub fn new_inherited(localName: ~str, document: AbstractDocument) -> HTMLBodyElement { + HTMLBodyElement { + htmlelement: HTMLElement::new(HTMLBodyElementTypeId, localName, document) + } + } + + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + let element = HTMLBodyElement::new_inherited(localName, document); + Node::reflect_node(@mut element, document, HTMLBodyElementBinding::Wrap) + } +} + impl HTMLBodyElement { pub fn Text(&self) -> DOMString { None diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs index 07983994c74..593a17ff56f 100644 --- a/src/components/script/html/hubbub_html_parser.rs +++ b/src/components/script/html/hubbub_html_parser.rs @@ -214,7 +214,6 @@ pub fn build_element_from_tag(cx: *JSContext, tag: &str, document: AbstractDocum handle_element!(cx, document, tag, "area", HTMLAreaElementTypeId, HTMLAreaElement, []); handle_element!(cx, document, tag, "base", HTMLBaseElementTypeId, HTMLBaseElement, []); handle_element!(cx, document, tag, "br", HTMLBRElementTypeId, HTMLBRElement, []); - handle_element!(cx, document, tag, "body", HTMLBodyElementTypeId, HTMLBodyElement, []); handle_htmlelement!(cx, document, tag, "aside", HTMLElementTypeId, HTMLElement); handle_htmlelement!(cx, document, tag, "b", HTMLElementTypeId, HTMLElement); @@ -223,6 +222,7 @@ pub fn build_element_from_tag(cx: *JSContext, tag: &str, document: AbstractDocum handle_htmlelement!(cx, document, tag, "small", HTMLElementTypeId, HTMLElement); handle_newable_element!(document, tag, "audio", HTMLAudioElement); + handle_newable_element!(document, tag, "body", HTMLBodyElement); handle_newable_element!(document, tag, "button", HTMLButtonElement); handle_newable_element!(document, tag, "canvas", HTMLCanvasElement); handle_newable_element!(document, tag, "caption", HTMLTableCaptionElement);