aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/script/dom/bindings/codegen/Bindings.conf2
-rw-r--r--src/components/script/dom/bindings/codegen/CodegenRust.py1
-rw-r--r--src/components/script/dom/bindings/codegen/HTMLCanvasElement.webidl55
-rw-r--r--src/components/script/dom/bindings/node.rs4
-rw-r--r--src/components/script/dom/bindings/utils.rs2
-rw-r--r--src/components/script/dom/element.rs6
-rw-r--r--src/components/script/dom/htmlcanvaselement.rs26
-rw-r--r--src/components/script/html/hubbub_html_parser.rs4
-rw-r--r--src/components/script/script.rc2
-rw-r--r--src/test/html/test_bindings.html1
-rw-r--r--src/test/html/test_bindings.js7
11 files changed, 105 insertions, 5 deletions
diff --git a/src/components/script/dom/bindings/codegen/Bindings.conf b/src/components/script/dom/bindings/codegen/Bindings.conf
index a26b2d22c5f..05770570fd9 100644
--- a/src/components/script/dom/bindings/codegen/Bindings.conf
+++ b/src/components/script/dom/bindings/codegen/Bindings.conf
@@ -548,6 +548,7 @@ def addHTMLElement(element):
addHTMLElement('HTMLAnchorElement')
addHTMLElement('HTMLBodyElement')
addHTMLElement('HTMLBRElement')
+addHTMLElement('HTMLCanvasElement')
addHTMLElement('HTMLDivElement')
addHTMLElement('HTMLElement')
addHTMLElement('HTMLHeadElement')
@@ -575,7 +576,6 @@ def addExternalHTMLElement(element):
addExternalIface(element, nativeType=nativeElement,
headerFile=nativeElement + '.h')
-addExternalHTMLElement('HTMLCanvasElement')
addExternalHTMLElement('HTMLOptionElement')
addExternalHTMLElement('HTMLOptGroupElement')
addExternalHTMLElement('HTMLVideoElement')
diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py
index 5af91832b24..140a712b950 100644
--- a/src/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/src/components/script/dom/bindings/codegen/CodegenRust.py
@@ -4620,6 +4620,7 @@ class CGBindingRoot(CGThing):
'dom::htmlanchorelement::HTMLAnchorElement', #XXXjdm
'dom::htmlbodyelement::HTMLBodyElement',
'dom::htmlbrelement::HTMLBRElement', #XXXrecrack
+ 'dom::htmlcanvaselement::HTMLCanvasElement',
'dom::htmlelement::HTMLElement', #XXXjdm
'dom::htmldocument::HTMLDocument', #XXXjdm
'dom::htmlhrelement::HTMLHRElement',
diff --git a/src/components/script/dom/bindings/codegen/HTMLCanvasElement.webidl b/src/components/script/dom/bindings/codegen/HTMLCanvasElement.webidl
new file mode 100644
index 00000000000..d2413381daa
--- /dev/null
+++ b/src/components/script/dom/bindings/codegen/HTMLCanvasElement.webidl
@@ -0,0 +1,55 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/.
+ *
+ * The origin of this IDL file is
+ * http://www.whatwg.org/specs/web-apps/current-work/#the-canvas-element
+ * © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
+ * Opera Software ASA. You are granted a license to use, reproduce
+ * and create derivative works of this document.
+ */
+
+// import from http://mxr.mozilla.org/mozilla-central/source/dom/webidl/HTMLCanvasElement.webidl
+
+/*
+interface Blob;
+interface FileCallback;
+interface nsIInputStreamCallback;
+interface nsISupports;
+interface PrintCallback;
+interface Variant;
+*/
+
+interface HTMLCanvasElement : HTMLElement {
+ [Pure, SetterThrows]
+ attribute unsigned long width;
+ [Pure, SetterThrows]
+ attribute unsigned long height;
+/*
+ [Throws]
+ nsISupports? getContext(DOMString contextId, optional any contextOptions = null);
+
+ [Throws]
+ DOMString toDataURL(optional DOMString type = "",
+ optional any encoderOptions);
+ [Throws]
+ void toBlob(FileCallback _callback,
+ optional DOMString type = "",
+ optional any encoderOptions);
+*/
+};
+/*
+// Mozilla specific bits
+partial interface HTMLCanvasElement {
+ [Pure, SetterThrows]
+ attribute boolean mozOpaque;
+ [Throws]
+ File mozGetAsFile(DOMString name, optional DOMString? type = null);
+ [ChromeOnly, Throws]
+ nsISupports? MozGetIPCContext(DOMString contextId);
+ [ChromeOnly]
+ void mozFetchAsStream(nsIInputStreamCallback callback, optional DOMString? type = null);
+ attribute PrintCallback? mozPrintCallback;
+};
+*/
diff --git a/src/components/script/dom/bindings/node.rs b/src/components/script/dom/bindings/node.rs
index 3c824a07e24..95c69667f46 100644
--- a/src/components/script/dom/bindings/node.rs
+++ b/src/components/script/dom/bindings/node.rs
@@ -7,7 +7,7 @@ use dom::bindings::text;
use dom::bindings::utils;
use dom::bindings::utils::{CacheableWrapper, WrapperCache, DerivedWrapper};
use dom::element::{HTMLElementTypeId};
-use dom::element::{HTMLHeadElementTypeId, HTMLHtmlElementTypeId, HTMLAnchorElementTypeId};
+use dom::element::{HTMLHeadElementTypeId, HTMLHtmlElementTypeId, HTMLAnchorElementTypeId, HTMLCanvasElementTypeId};
use dom::element::{HTMLDivElementTypeId, HTMLImageElementTypeId, HTMLSpanElementTypeId};
use dom::element::{HTMLBodyElementTypeId, HTMLHRElementTypeId, HTMLIframeElementTypeId};
use dom::element::{HTMLBRElementTypeId, HTMLTitleElementTypeId};
@@ -22,6 +22,7 @@ use dom::htmlanchorelement::HTMLAnchorElement;
use dom::htmlbodyelement::HTMLBodyElement;
use dom::htmlhrelement::HTMLHRElement;
use dom::htmlbrelement::HTMLBRElement;
+use dom::htmlcanvaselement::HTMLCanvasElement;
use dom::htmliframeelement::HTMLIFrameElement;
use dom::htmlimageelement::HTMLImageElement;
use dom::htmlmetaelement::HTMLMetaElement;
@@ -103,6 +104,7 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> *JSObject
ElementNodeTypeId(HTMLAnchorElementTypeId) => generate_element!(HTMLAnchorElement),
ElementNodeTypeId(HTMLBodyElementTypeId) => generate_element!(HTMLBodyElement),
ElementNodeTypeId(HTMLBRElementTypeId) => generate_element!(HTMLBRElement),
+ ElementNodeTypeId(HTMLCanvasElementTypeId) => generate_element!(HTMLCanvasElement),
ElementNodeTypeId(HTMLDivElementTypeId) => generate_element!(HTMLDivElement),
ElementNodeTypeId(HTMLHeadElementTypeId) => generate_element!(HTMLHeadElement),
ElementNodeTypeId(HTMLHRElementTypeId) => generate_element!(HTMLHRElement),
diff --git a/src/components/script/dom/bindings/utils.rs b/src/components/script/dom/bindings/utils.rs
index 43bffa6d750..47d02a3c944 100644
--- a/src/components/script/dom/bindings/utils.rs
+++ b/src/components/script/dom/bindings/utils.rs
@@ -617,7 +617,7 @@ pub extern fn ThrowingConstructor(_cx: *JSContext, _argc: uint, _vp: *JSVal) ->
}
pub fn initialize_global(global: *JSObject) {
- let protoArray = @mut ([0 as *JSObject, ..51]);
+ let protoArray = @mut ([0 as *JSObject, ..52]);
assert!(protoArray.len() == PrototypeList::id::_ID_Count as uint);
unsafe {
//XXXjdm we should be storing the box pointer instead of the inner
diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs
index 5ba5db7b61d..8bd457ac029 100644
--- a/src/components/script/dom/element.rs
+++ b/src/components/script/dom/element.rs
@@ -6,7 +6,7 @@
use dom::bindings::codegen::{HTMLHeadElementBinding, HTMLHtmlElementBinding};
use dom::bindings::codegen::{HTMLAnchorElementBinding, HTMLBRElementBinding};
-use dom::bindings::codegen::{HTMLBodyElementBinding, HTMLDivElementBinding, HTMLSpanElementBinding};
+use dom::bindings::codegen::{HTMLBodyElementBinding, HTMLCanvasElementBinding, HTMLDivElementBinding, HTMLSpanElementBinding};
use dom::bindings::codegen::{HTMLHRElementBinding, HTMLIFrameElementBinding};
use dom::bindings::codegen::{HTMLParagraphElementBinding, HTMLScriptElementBinding};
use dom::bindings::codegen::{HTMLImageElementBinding, HTMLOListElementBinding};
@@ -21,6 +21,7 @@ use dom::clientrectlist::ClientRectList;
use dom::htmlanchorelement::HTMLAnchorElement;
use dom::htmlbodyelement::HTMLBodyElement;
use dom::htmlbrelement::HTMLBRElement;
+use dom::htmlcanvaselement::HTMLCanvasElement;
use dom::htmlcollection::HTMLCollection;
use dom::htmlelement::HTMLElement;
use dom::htmlhrelement::HTMLHRElement;
@@ -76,6 +77,7 @@ pub enum ElementTypeId {
HTMLAnchorElementTypeId,
HTMLBRElementTypeId,
HTMLBodyElementTypeId,
+ HTMLCanvasElementTypeId,
HTMLDivElementTypeId,
HTMLFontElementTypeId,
HTMLFormElementTypeId,
@@ -185,6 +187,8 @@ generate_cacheable_wrapper!(HTMLAnchorElement, HTMLAnchorElementBinding::Wrap)
generate_binding_object!(HTMLAnchorElement)
generate_cacheable_wrapper!(HTMLBodyElement, HTMLBodyElementBinding::Wrap)
generate_binding_object!(HTMLBodyElement)
+generate_cacheable_wrapper!(HTMLCanvasElement, HTMLCanvasElementBinding::Wrap)
+generate_binding_object!(HTMLCanvasElement)
generate_cacheable_wrapper!(HTMLBRElement, HTMLBRElementBinding::Wrap)
generate_binding_object!(HTMLBRElement)
generate_cacheable_wrapper!(HTMLHRElement, HTMLHRElementBinding::Wrap)
diff --git a/src/components/script/dom/htmlcanvaselement.rs b/src/components/script/dom/htmlcanvaselement.rs
new file mode 100644
index 00000000000..fd2caad56ce
--- /dev/null
+++ b/src/components/script/dom/htmlcanvaselement.rs
@@ -0,0 +1,26 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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::utils::{ErrorResult};
+use dom::htmlelement::HTMLElement;
+
+pub struct HTMLCanvasElement {
+ parent: HTMLElement,
+}
+
+impl HTMLCanvasElement {
+ pub fn Width(&self) -> u32 {
+ 0
+ }
+
+ pub fn SetWidth(&mut self, _width: u32, _rv: &mut ErrorResult) {
+ }
+
+ pub fn Height(&self) -> u32 {
+ 0
+ }
+
+ pub fn SetHeight(&mut self, _height: u32, _rv: &mut ErrorResult) {
+ }
+}
diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs
index 845c53a2b68..19885aafdd2 100644
--- a/src/components/script/html/hubbub_html_parser.rs
+++ b/src/components/script/html/hubbub_html_parser.rs
@@ -4,7 +4,7 @@
use dom::element::{HTMLElementTypeId,
HTMLAnchorElementTypeId, HTMLBRElementTypeId,
- HTMLBodyElementTypeId, HTMLDivElementTypeId,
+ HTMLBodyElementTypeId, HTMLCanvasElementTypeId, HTMLDivElementTypeId,
HTMLFontElementTypeId, HTMLFormElementTypeId, HTMLHRElementTypeId,
HTMLHeadElementTypeId, HTMLHtmlElementTypeId,
HTMLImageElementTypeId, HTMLIframeElementTypeId, HTMLInputElementTypeId,
@@ -28,6 +28,7 @@ use dom::element::{HTMLHeadingElementTypeId, Heading1, Heading2, Heading3, Headi
use dom::htmlbrelement::HTMLBRElement;
use dom::htmlanchorelement::HTMLAnchorElement;
use dom::htmlbodyelement::HTMLBodyElement;
+use dom::htmlcanvaselement::HTMLCanvasElement;
use dom::htmlhrelement::HTMLHRElement;
use dom::htmliframeelement::HTMLIFrameElement;
use dom::htmlimageelement::HTMLImageElement;
@@ -218,6 +219,7 @@ fn build_element_from_tag(cx: *JSContext, tag: &str) -> AbstractNode<ScriptView>
handle_element!(cx, tag, "a", HTMLAnchorElementTypeId, HTMLAnchorElement, []);
handle_element!(cx, tag, "br", HTMLBRElementTypeId, HTMLBRElement, []);
handle_element!(cx, tag, "body", HTMLBodyElementTypeId, HTMLBodyElement, []);
+ handle_element!(cx, tag, "canvas", HTMLCanvasElementTypeId, HTMLCanvasElement, []);
handle_element!(cx, tag, "div", HTMLDivElementTypeId, HTMLDivElement, []);
handle_element!(cx, tag, "font", HTMLFontElementTypeId, HTMLFontElement, []);
handle_element!(cx, tag, "form", HTMLFormElementTypeId, HTMLFormElement, []);
diff --git a/src/components/script/script.rc b/src/components/script/script.rc
index 78cc617e0dd..08b2ec8d231 100644
--- a/src/components/script/script.rc
+++ b/src/components/script/script.rc
@@ -45,6 +45,7 @@ pub mod dom {
pub mod HTMLAnchorElementBinding;
pub mod HTMLBodyElementBinding;
pub mod HTMLBRElementBinding;
+ pub mod HTMLCanvasElementBinding;
pub mod HTMLCollectionBinding;
pub mod HTMLDivElementBinding;
pub mod HTMLDocumentBinding;
@@ -89,6 +90,7 @@ pub mod dom {
pub mod htmlanchorelement;
pub mod htmlbodyelement;
pub mod htmlbrelement;
+ pub mod htmlcanvaselement;
pub mod htmlcollection;
pub mod htmldocument;
pub mod htmlelement;
diff --git a/src/test/html/test_bindings.html b/src/test/html/test_bindings.html
index b6aae39899b..e9c116c92cd 100644
--- a/src/test/html/test_bindings.html
+++ b/src/test/html/test_bindings.html
@@ -16,6 +16,7 @@
<embed></embed>
<form></form>
<hr />
+ <canvas/>
<p>pppppppppp</p>
<applet></applet>
<iframe></iframe>
diff --git a/src/test/html/test_bindings.js b/src/test/html/test_bindings.js
index dc2800a1799..d33b6c6ba83 100644
--- a/src/test/html/test_bindings.js
+++ b/src/test/html/test_bindings.js
@@ -151,6 +151,13 @@ for (let i = 0, l = tagList.length; i < l; ++i) {
window.alert(tags[0] instanceof HTMLElement);
}
+window.alert("HTMLCanvasElement:");
+let tags = document.getElementsByTagName("canvas");
+window.alert(tags);
+window.alert(tags.length);
+window.alert(tags[0].tagName);
+window.alert(tags[0] instanceof HTMLCanvasElement);
+
window.alert("HTMLTextAreaElement:");
let tags = document.getElementsByTagName("textarea");
window.alert(tags);