From b923bcdef729f9785c23e7e85181156c3cfde072 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sat, 2 Nov 2013 11:55:54 +0100 Subject: [PATCH] Introduce HTMLFormElement::new. --- src/components/script/dom/htmlformelement.rs | 18 +++++++++++++++++- .../script/html/hubbub_html_parser.rs | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/components/script/dom/htmlformelement.rs b/src/components/script/dom/htmlformelement.rs index c6fbac85cb9..c6e5263aee2 100644 --- a/src/components/script/dom/htmlformelement.rs +++ b/src/components/script/dom/htmlformelement.rs @@ -2,15 +2,31 @@ * 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::HTMLFormElementBinding; use dom::bindings::utils::{DOMString, ErrorResult}; +use dom::document::AbstractDocument; +use dom::element::HTMLFormElementTypeId; use dom::htmlcollection::HTMLCollection; use dom::htmlelement::HTMLElement; -use dom::node::{AbstractNode, ScriptView}; +use dom::node::{AbstractNode, Node, ScriptView}; pub struct HTMLFormElement { htmlelement: HTMLElement } +impl HTMLFormElement { + pub fn new_inherited(localName: ~str, document: AbstractDocument) -> HTMLFormElement { + HTMLFormElement { + htmlelement: HTMLElement::new(HTMLFormElementTypeId, localName, document) + } + } + + pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode { + let element = HTMLFormElement::new_inherited(localName, document); + Node::reflect_node(@mut element, document, HTMLFormElementBinding::Wrap) + } +} + impl HTMLFormElement { pub fn AcceptCharset(&self) -> DOMString { None diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs index 2d0b99e8ac8..bf84d7369a5 100644 --- a/src/components/script/html/hubbub_html_parser.rs +++ b/src/components/script/html/hubbub_html_parser.rs @@ -225,7 +225,6 @@ pub fn build_element_from_tag(cx: *JSContext, tag: &str, document: AbstractDocum handle_element!(cx, document, tag, "embed", HTMLEmbedElementTypeId, HTMLEmbedElement, []); handle_element!(cx, document, tag, "fieldset",HTMLFieldSetElementTypeId, HTMLFieldSetElement, []); handle_element!(cx, document, tag, "font", HTMLFontElementTypeId, HTMLFontElement, []); - handle_element!(cx, document, tag, "form", HTMLFormElementTypeId, HTMLFormElement, []); handle_htmlelement!(cx, document, tag, "aside", HTMLElementTypeId, HTMLElement); handle_htmlelement!(cx, document, tag, "b", HTMLElementTypeId, HTMLElement); @@ -238,6 +237,7 @@ pub fn build_element_from_tag(cx: *JSContext, tag: &str, document: AbstractDocum handle_newable_element!(document, tag, "col", HTMLTableColElement); handle_newable_element!(document, tag, "colgroup", HTMLTableColElement); handle_newable_element!(document, tag, "del", HTMLModElement); + handle_newable_element!(document, tag, "form", HTMLFormElement); handle_newable_element!(document, tag, "frame", HTMLFrameElement); handle_newable_element!(document, tag, "frameset", HTMLFrameSetElement); handle_newable_element!(document, tag, "h1", HTMLHeadingElement, Heading1);