mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Generate bindings for HTMLImageElement.
This commit is contained in:
parent
65a33f60e5
commit
8e2c39d2dd
10 changed files with 184 additions and 10 deletions
|
@ -550,6 +550,7 @@ addHTMLElement('HTMLDivElement')
|
|||
addHTMLElement('HTMLElement')
|
||||
addHTMLElement('HTMLHeadElement')
|
||||
addHTMLElement('HTMLHtmlElement')
|
||||
addHTMLElement('HTMLImageElement')
|
||||
|
||||
# If you add one of these, you need to make sure nsDOMQS.h has the relevant
|
||||
# macros added for it
|
||||
|
@ -559,7 +560,6 @@ def addExternalHTMLElement(element):
|
|||
headerFile=nativeElement + '.h')
|
||||
|
||||
addExternalHTMLElement('HTMLCanvasElement')
|
||||
addExternalHTMLElement('HTMLImageElement')
|
||||
addExternalHTMLElement('HTMLOptionElement')
|
||||
addExternalHTMLElement('HTMLOptGroupElement')
|
||||
addExternalHTMLElement('HTMLVideoElement')
|
||||
|
|
|
@ -4620,6 +4620,7 @@ class CGBindingRoot(CGThing):
|
|||
'dom::htmlanchorelement::HTMLAnchorElement', #XXXjdm
|
||||
'dom::htmlelement::HTMLElement', #XXXjdm
|
||||
'dom::htmldocument::HTMLDocument', #XXXjdm
|
||||
'dom::htmlimageelement::HTMLImageElement', #XXXjdm
|
||||
'dom::bindings::utils::*',
|
||||
'dom::bindings::conversions::*',
|
||||
'dom::blob::*', #XXXjdm
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/* -*- 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/#htmlimageelement
|
||||
* http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
|
||||
* © 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.
|
||||
*/
|
||||
|
||||
[NamedConstructor=Image(optional unsigned long width, optional unsigned long height)]
|
||||
interface HTMLImageElement : HTMLElement {
|
||||
[SetterThrows]
|
||||
attribute DOMString alt;
|
||||
[SetterThrows]
|
||||
attribute DOMString src;
|
||||
// attribute DOMString srcset;
|
||||
[SetterThrows]
|
||||
attribute DOMString crossOrigin;
|
||||
[SetterThrows]
|
||||
attribute DOMString useMap;
|
||||
[SetterThrows]
|
||||
attribute boolean isMap;
|
||||
[SetterThrows]
|
||||
attribute unsigned long width;
|
||||
[SetterThrows]
|
||||
attribute unsigned long height;
|
||||
readonly attribute unsigned long naturalWidth;
|
||||
readonly attribute unsigned long naturalHeight;
|
||||
readonly attribute boolean complete;
|
||||
};
|
||||
|
||||
// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
|
||||
partial interface HTMLImageElement {
|
||||
[SetterThrows]
|
||||
attribute DOMString name;
|
||||
[SetterThrows]
|
||||
attribute DOMString align;
|
||||
[SetterThrows]
|
||||
attribute unsigned long hspace;
|
||||
[SetterThrows]
|
||||
attribute unsigned long vspace;
|
||||
[SetterThrows]
|
||||
attribute DOMString longDesc;
|
||||
|
||||
[TreatNullAs=EmptyString,SetterThrows] attribute DOMString border;
|
||||
};
|
|
@ -7,9 +7,10 @@ use dom::bindings::text;
|
|||
use dom::bindings::utils;
|
||||
use dom::bindings::utils::{CacheableWrapper, WrapperCache, DerivedWrapper};
|
||||
use dom::element::{HTMLHeadElementTypeId, HTMLHtmlElementTypeId, HTMLAnchorElementTypeId};
|
||||
use dom::element::{HTMLDivElementTypeId};
|
||||
use dom::element::{HTMLDivElementTypeId, HTMLImageElementTypeId};
|
||||
use dom::element::{HTMLHeadElement, HTMLHtmlElement, HTMLDivElement};
|
||||
use dom::htmlanchorelement::HTMLAnchorElement;
|
||||
use dom::htmlimageelement::HTMLImageElement;
|
||||
use dom::node::{AbstractNode, Node, ElementNodeTypeId, TextNodeTypeId, CommentNodeTypeId};
|
||||
use dom::node::{DoctypeNodeTypeId, ScriptView, Text};
|
||||
|
||||
|
@ -79,6 +80,7 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> *JSObject
|
|||
ElementNodeTypeId(HTMLDivElementTypeId) => generate_element!(HTMLDivElement),
|
||||
ElementNodeTypeId(HTMLHeadElementTypeId) => generate_element!(HTMLHeadElement),
|
||||
ElementNodeTypeId(HTMLHtmlElementTypeId) => generate_element!(HTMLHtmlElement),
|
||||
ElementNodeTypeId(HTMLImageElementTypeId) => generate_element!(HTMLImageElement),
|
||||
ElementNodeTypeId(_) => element::create(cx, node).ptr,
|
||||
CommentNodeTypeId |
|
||||
DoctypeNodeTypeId => text::create(cx, node).ptr,
|
||||
|
|
|
@ -617,7 +617,8 @@ pub extern fn ThrowingConstructor(_cx: *JSContext, _argc: uint, _vp: *JSVal) ->
|
|||
}
|
||||
|
||||
pub fn initialize_global(global: *JSObject) {
|
||||
let protoArray = @mut ([0 as *JSObject, ..34]); //XXXjdm PrototyepList::id::_ID_Count
|
||||
let protoArray = @mut ([0 as *JSObject, ..35]);
|
||||
assert!(protoArray.len() == PrototypeList::id::_ID_Count as uint);
|
||||
unsafe {
|
||||
//XXXjdm we should be storing the box pointer instead of the inner
|
||||
let box = squirrel_away(protoArray);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
use dom::bindings::codegen::{HTMLHeadElementBinding, HTMLHtmlElementBinding};
|
||||
use dom::bindings::codegen::{HTMLAnchorElementBinding, HTMLDivElementBinding};
|
||||
use dom::bindings::codegen::{HTMLImageElementBinding};
|
||||
use dom::bindings::utils::{DOMString, null_string, ErrorResult};
|
||||
use dom::bindings::utils::{CacheableWrapper, BindingObject, WrapperCache};
|
||||
use dom::clientrect::ClientRect;
|
||||
|
@ -13,6 +14,7 @@ use dom::clientrectlist::ClientRectList;
|
|||
use dom::htmlanchorelement::HTMLAnchorElement;
|
||||
use dom::htmlcollection::HTMLCollection;
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::htmlimageelement::HTMLImageElement;
|
||||
use dom::node::{ElementNodeTypeId, Node, ScriptView, AbstractNode};
|
||||
use layout_interface::{ContentBoxQuery, ContentBoxResponse, ContentBoxesQuery};
|
||||
use layout_interface::{ContentBoxesResponse};
|
||||
|
@ -176,6 +178,8 @@ generate_cacheable_wrapper!(HTMLAnchorElement, HTMLAnchorElementBinding::Wrap)
|
|||
generate_binding_object!(HTMLAnchorElement)
|
||||
generate_cacheable_wrapper!(HTMLDivElement, HTMLDivElementBinding::Wrap)
|
||||
generate_binding_object!(HTMLDivElement)
|
||||
generate_cacheable_wrapper!(HTMLImageElement, HTMLImageElementBinding::Wrap)
|
||||
generate_binding_object!(HTMLImageElement)
|
||||
|
||||
//
|
||||
// Fancier elements
|
||||
|
@ -193,11 +197,6 @@ pub struct HTMLIframeElement {
|
|||
size_future_chan: Option<ChanOne<Size2D<uint>>>,
|
||||
}
|
||||
|
||||
pub struct HTMLImageElement {
|
||||
parent: HTMLElement,
|
||||
image: Option<Url>,
|
||||
}
|
||||
|
||||
//
|
||||
// Element methods
|
||||
//
|
||||
|
|
117
src/components/script/dom/htmlimageelement.rs
Normal file
117
src/components/script/dom/htmlimageelement.rs
Normal file
|
@ -0,0 +1,117 @@
|
|||
/* 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::{DOMString, null_string, ErrorResult};
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use extra::net::url::Url;
|
||||
|
||||
pub struct HTMLImageElement {
|
||||
parent: HTMLElement,
|
||||
image: Option<Url>,
|
||||
}
|
||||
|
||||
impl HTMLImageElement {
|
||||
pub fn Alt(&self) -> DOMString {
|
||||
null_string
|
||||
}
|
||||
|
||||
pub fn SetAlt(&mut self, _alt: &DOMString, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn Src(&self) -> DOMString {
|
||||
null_string
|
||||
}
|
||||
|
||||
pub fn SetSrc(&mut self, _src: &DOMString, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn CrossOrigin(&self) -> DOMString {
|
||||
null_string
|
||||
}
|
||||
|
||||
pub fn SetCrossOrigin(&mut self, _cross_origin: &DOMString, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn UseMap(&self) -> DOMString {
|
||||
null_string
|
||||
}
|
||||
|
||||
pub fn SetUseMap(&mut self, _use_map: &DOMString, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn IsMap(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn SetIsMap(&self, _is_map: bool, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
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) {
|
||||
}
|
||||
|
||||
pub fn NaturalWidth(&self) -> u32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn NaturalHeight(&self) -> u32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn Complete(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn Name(&self) -> DOMString {
|
||||
null_string
|
||||
}
|
||||
|
||||
pub fn SetName(&mut self, _name: &DOMString, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn Align(&self) -> DOMString {
|
||||
null_string
|
||||
}
|
||||
|
||||
pub fn SetAlign(&mut self, _align: &DOMString, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn Hspace(&self) -> u32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn SetHspace(&mut self, _hspace: u32, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn Vspace(&self) -> u32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn SetVspace(&mut self, _vspace: u32, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn LongDesc(&self) -> DOMString {
|
||||
null_string
|
||||
}
|
||||
|
||||
pub fn SetLongDesc(&mut self, _longdesc: &DOMString, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn Border(&self) -> DOMString {
|
||||
null_string
|
||||
}
|
||||
|
||||
pub fn SetBorder(&mut self, _border: &DOMString, _rv: &mut ErrorResult) {
|
||||
}
|
||||
}
|
|
@ -11,8 +11,9 @@ use dom::bindings::utils::{BindingObject, CacheableWrapper, rust_box};
|
|||
use dom::bindings;
|
||||
use dom::characterdata::CharacterData;
|
||||
use dom::document::AbstractDocument;
|
||||
use dom::element::{Element, ElementTypeId, HTMLImageElement, HTMLImageElementTypeId, HTMLIframeElementTypeId, HTMLIframeElement};
|
||||
use dom::element::{Element, ElementTypeId, HTMLImageElementTypeId, HTMLIframeElementTypeId, HTMLIframeElement};
|
||||
use dom::element::{HTMLStyleElementTypeId};
|
||||
use dom::htmlimageelement::HTMLImageElement;
|
||||
use dom::window::Window;
|
||||
|
||||
use std::cast;
|
||||
|
|
|
@ -18,7 +18,7 @@ use dom::element::{HTMLAnchorElementTypeId, HTMLAsideElementTypeId, HTMLBRElemen
|
|||
use dom::element::{HTMLAsideElement, HTMLBRElement, HTMLBodyElement,
|
||||
HTMLBoldElement, HTMLDivElement, HTMLFontElement, HTMLFormElement,
|
||||
HTMLHRElement, HTMLHeadElement, HTMLHeadingElement, HTMLHtmlElement,
|
||||
HTMLInputElement, HTMLImageElement, HTMLIframeElement,
|
||||
HTMLInputElement, HTMLIframeElement,
|
||||
HTMLItalicElement, HTMLLinkElement, HTMLListItemElement, HTMLMetaElement,
|
||||
HTMLOListElement, HTMLOptionElement, HTMLParagraphElement,
|
||||
HTMLScriptElement, HTMLSectionElement, HTMLSelectElement, HTMLSmallElement,
|
||||
|
@ -28,6 +28,7 @@ use dom::element::{HTMLAsideElement, HTMLBRElement, HTMLBodyElement,
|
|||
use dom::element::{HTMLHeadingElementTypeId, Heading1, Heading2, Heading3, Heading4, Heading5,
|
||||
Heading6};
|
||||
use dom::htmlanchorelement::HTMLAnchorElement;
|
||||
use dom::htmlimageelement::HTMLImageElement;
|
||||
use dom::element::{Element, Attr};
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::node::{AbstractNode, Comment, Doctype, ElementNodeTypeId, Node, ScriptView};
|
||||
|
|
|
@ -49,6 +49,7 @@ pub mod dom {
|
|||
pub mod HTMLElementBinding;
|
||||
pub mod HTMLHeadElementBinding;
|
||||
pub mod HTMLHtmlElementBinding;
|
||||
pub mod HTMLImageElementBinding;
|
||||
pub mod MouseEventBinding;
|
||||
pub mod NodeBinding;
|
||||
pub mod PrototypeList;
|
||||
|
@ -73,6 +74,7 @@ pub mod dom {
|
|||
pub mod htmlcollection;
|
||||
pub mod htmldocument;
|
||||
pub mod htmlelement;
|
||||
pub mod htmlimageelement;
|
||||
pub mod mouseevent;
|
||||
pub mod node;
|
||||
pub mod uievent;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue