mirror of
https://github.com/servo/servo.git
synced 2025-06-11 01:50:10 +00:00
Generate bindings for HTMLCanvasElement.
This commit is contained in:
parent
0f957c9e22
commit
b44d4346df
11 changed files with 105 additions and 5 deletions
|
@ -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')
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
*/
|
|
@ -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),
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
26
src/components/script/dom/htmlcanvaselement.rs
Normal file
26
src/components/script/dom/htmlcanvaselement.rs
Normal file
|
@ -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) {
|
||||
}
|
||||
}
|
|
@ -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, []);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<embed></embed>
|
||||
<form></form>
|
||||
<hr />
|
||||
<canvas/>
|
||||
<p>pppppppppp</p>
|
||||
<applet></applet>
|
||||
<iframe></iframe>
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue