diff --git a/src/components/script/dom/htmlcanvaselement.rs b/src/components/script/dom/htmlcanvaselement.rs
index dba29030bfa..81adc4550f1 100644
--- a/src/components/script/dom/htmlcanvaselement.rs
+++ b/src/components/script/dom/htmlcanvaselement.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::HTMLCanvasElementBinding;
use dom::bindings::utils::{ErrorResult};
+use dom::document::AbstractDocument;
+use dom::element::HTMLCanvasElementTypeId;
use dom::htmlelement::HTMLElement;
+use dom::node::{AbstractNode, Node, ScriptView};
pub struct HTMLCanvasElement {
htmlelement: HTMLElement,
}
+impl HTMLCanvasElement {
+ pub fn new_inherited(localName: ~str, document: AbstractDocument) -> HTMLCanvasElement {
+ HTMLCanvasElement {
+ htmlelement: HTMLElement::new(HTMLCanvasElementTypeId, localName, document)
+ }
+ }
+
+ pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode {
+ let element = HTMLCanvasElement::new_inherited(localName, document);
+ Node::reflect_node(@mut element, document, HTMLCanvasElementBinding::Wrap)
+ }
+}
+
impl HTMLCanvasElement {
pub fn Width(&self) -> u32 {
0
diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs
index 03c6e30d1e4..61f5b38a2b8 100644
--- a/src/components/script/html/hubbub_html_parser.rs
+++ b/src/components/script/html/hubbub_html_parser.rs
@@ -216,7 +216,6 @@ pub fn build_element_from_tag(cx: *JSContext, tag: &str, document: AbstractDocum
handle_element!(cx, document, tag, "br", HTMLBRElementTypeId, HTMLBRElement, []);
handle_element!(cx, document, tag, "body", HTMLBodyElementTypeId, HTMLBodyElement, []);
handle_element!(cx, document, tag, "button", HTMLButtonElementTypeId, HTMLButtonElement, []);
- handle_element!(cx, document, tag, "canvas", HTMLCanvasElementTypeId, HTMLCanvasElement, []);
handle_htmlelement!(cx, document, tag, "aside", HTMLElementTypeId, HTMLElement);
handle_htmlelement!(cx, document, tag, "b", HTMLElementTypeId, HTMLElement);
@@ -225,6 +224,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, "canvas", HTMLCanvasElement);
handle_newable_element!(document, tag, "caption", HTMLTableCaptionElement);
handle_newable_element!(document, tag, "col", HTMLTableColElement);
handle_newable_element!(document, tag, "colgroup", HTMLTableColElement);