Generate HTMLIFrameElement bindings.

This commit is contained in:
Josh Matthews 2013-08-07 17:04:47 -04:00
parent c8be8edbb2
commit ddf4bee6df
13 changed files with 217 additions and 24 deletions

View file

@ -552,6 +552,7 @@ addHTMLElement('HTMLElement')
addHTMLElement('HTMLHeadElement') addHTMLElement('HTMLHeadElement')
addHTMLElement('HTMLHtmlElement') addHTMLElement('HTMLHtmlElement')
addHTMLElement('HTMLHRElement') addHTMLElement('HTMLHRElement')
addHTMLElement('HTMLIFrameElement')
addHTMLElement('HTMLImageElement') addHTMLElement('HTMLImageElement')
addHTMLElement('HTMLParagraphElement') addHTMLElement('HTMLParagraphElement')
addHTMLElement('HTMLScriptElement') addHTMLElement('HTMLScriptElement')

View file

@ -4622,6 +4622,7 @@ class CGBindingRoot(CGThing):
'dom::htmlelement::HTMLElement', #XXXjdm 'dom::htmlelement::HTMLElement', #XXXjdm
'dom::htmldocument::HTMLDocument', #XXXjdm 'dom::htmldocument::HTMLDocument', #XXXjdm
'dom::htmlhrelement::HTMLHRElement', 'dom::htmlhrelement::HTMLHRElement',
'dom::htmliframeelement::HTMLIFrameElement', #XXXjdm
'dom::htmlimageelement::HTMLImageElement', #XXXjdm 'dom::htmlimageelement::HTMLImageElement', #XXXjdm
'dom::htmlscriptelement::HTMLScriptElement', 'dom::htmlscriptelement::HTMLScriptElement',
'dom::bindings::utils::*', 'dom::bindings::utils::*',

View file

@ -10,8 +10,6 @@
* liability, trademark and document use rules apply. * liability, trademark and document use rules apply.
*/ */
interface Element;
interface HTMLCollection { interface HTMLCollection {
readonly attribute unsigned long length; readonly attribute unsigned long length;
getter Element? item(unsigned long index); getter Element? item(unsigned long index);

View file

@ -0,0 +1,67 @@
/* -*- 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-iframe-element
* 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.
*/
interface HTMLIFrameElement : HTMLElement {
[SetterThrows, Pure]
attribute DOMString src;
[SetterThrows, Pure]
attribute DOMString srcdoc;
[SetterThrows, Pure]
attribute DOMString name;
// [PutForwards=value] readonly attribute DOMSettableTokenList sandbox;
// We're implementing sandbox as a string for now, see bug 845057.
attribute DOMString sandbox;
// attribute boolean seamless;
[SetterThrows, Pure]
attribute boolean allowFullscreen;
[SetterThrows, Pure]
attribute DOMString width;
[SetterThrows, Pure]
attribute DOMString height;
readonly attribute Document? contentDocument;
readonly attribute WindowProxy? contentWindow;
};
// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
partial interface HTMLIFrameElement {
[SetterThrows, Pure]
attribute DOMString align;
[SetterThrows, Pure]
attribute DOMString scrolling;
[SetterThrows, Pure]
attribute DOMString frameBorder;
[SetterThrows, Pure]
attribute DOMString longDesc;
[TreatNullAs=EmptyString,SetterThrows,Pure] attribute DOMString marginHeight;
[TreatNullAs=EmptyString,SetterThrows,Pure] attribute DOMString marginWidth;
};
partial interface HTMLIFrameElement {
// GetSVGDocument
Document? getSVGDocument();
};
/*partial interface HTMLIFrameElement {
// nsIDOMMozBrowserFrame
[ChromeOnly,SetterThrows]
attribute boolean mozbrowser;
};
partial interface HTMLIFrameElement {
// nsIMozBrowserFrame
[ChromeOnly]
readonly attribute DOMString appManifestURL;
};
HTMLIFrameElement implements MozFrameLoaderOwner;*/

View file

@ -8,13 +8,14 @@ use dom::bindings::utils;
use dom::bindings::utils::{CacheableWrapper, WrapperCache, DerivedWrapper}; use dom::bindings::utils::{CacheableWrapper, WrapperCache, DerivedWrapper};
use dom::element::{HTMLHeadElementTypeId, HTMLHtmlElementTypeId, HTMLAnchorElementTypeId}; use dom::element::{HTMLHeadElementTypeId, HTMLHtmlElementTypeId, HTMLAnchorElementTypeId};
use dom::element::{HTMLDivElementTypeId, HTMLImageElementTypeId, HTMLSpanElementTypeId}; use dom::element::{HTMLDivElementTypeId, HTMLImageElementTypeId, HTMLSpanElementTypeId};
use dom::element::{HTMLBodyElementTypeId, HTMLHRElementTypeId}; use dom::element::{HTMLBodyElementTypeId, HTMLHRElementTypeId, HTMLIframeElementTypeId};
use dom::element::{HTMLParagraphElementTypeId, HTMLScriptElementTypeId}; use dom::element::{HTMLParagraphElementTypeId, HTMLScriptElementTypeId};
use dom::element::{HTMLHeadElement, HTMLHtmlElement, HTMLDivElement, HTMLSpanElement}; use dom::element::{HTMLHeadElement, HTMLHtmlElement, HTMLDivElement, HTMLSpanElement};
use dom::element::{HTMLParagraphElement}; use dom::element::{HTMLParagraphElement};
use dom::htmlanchorelement::HTMLAnchorElement; use dom::htmlanchorelement::HTMLAnchorElement;
use dom::htmlbodyelement::HTMLBodyElement; use dom::htmlbodyelement::HTMLBodyElement;
use dom::htmlhrelement::HTMLHRElement; use dom::htmlhrelement::HTMLHRElement;
use dom::htmliframeelement::HTMLIFrameElement;
use dom::htmlimageelement::HTMLImageElement; use dom::htmlimageelement::HTMLImageElement;
use dom::htmlscriptelement::HTMLScriptElement; use dom::htmlscriptelement::HTMLScriptElement;
use dom::node::{AbstractNode, Node, ElementNodeTypeId, TextNodeTypeId, CommentNodeTypeId}; use dom::node::{AbstractNode, Node, ElementNodeTypeId, TextNodeTypeId, CommentNodeTypeId};
@ -88,6 +89,7 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> *JSObject
ElementNodeTypeId(HTMLHeadElementTypeId) => generate_element!(HTMLHeadElement), ElementNodeTypeId(HTMLHeadElementTypeId) => generate_element!(HTMLHeadElement),
ElementNodeTypeId(HTMLHRElementTypeId) => generate_element!(HTMLHRElement), ElementNodeTypeId(HTMLHRElementTypeId) => generate_element!(HTMLHRElement),
ElementNodeTypeId(HTMLHtmlElementTypeId) => generate_element!(HTMLHtmlElement), ElementNodeTypeId(HTMLHtmlElementTypeId) => generate_element!(HTMLHtmlElement),
ElementNodeTypeId(HTMLIframeElementTypeId) => generate_element!(HTMLIFrameElement),
ElementNodeTypeId(HTMLImageElementTypeId) => generate_element!(HTMLImageElement), ElementNodeTypeId(HTMLImageElementTypeId) => generate_element!(HTMLImageElement),
ElementNodeTypeId(HTMLParagraphElementTypeId) => generate_element!(HTMLParagraphElement), ElementNodeTypeId(HTMLParagraphElementTypeId) => generate_element!(HTMLParagraphElement),
ElementNodeTypeId(HTMLScriptElementTypeId) => generate_element!(HTMLScriptElement), ElementNodeTypeId(HTMLScriptElementTypeId) => generate_element!(HTMLScriptElement),

View file

@ -617,7 +617,7 @@ pub extern fn ThrowingConstructor(_cx: *JSContext, _argc: uint, _vp: *JSVal) ->
} }
pub fn initialize_global(global: *JSObject) { pub fn initialize_global(global: *JSObject) {
let protoArray = @mut ([0 as *JSObject, ..40]); let protoArray = @mut ([0 as *JSObject, ..41]);
assert!(protoArray.len() == PrototypeList::id::_ID_Count as uint); assert!(protoArray.len() == PrototypeList::id::_ID_Count as uint);
unsafe { unsafe {
//XXXjdm we should be storing the box pointer instead of the inner //XXXjdm we should be storing the box pointer instead of the inner

View file

@ -5,9 +5,10 @@
//! Element nodes. //! Element nodes.
use dom::bindings::codegen::{HTMLHeadElementBinding, HTMLHtmlElementBinding}; use dom::bindings::codegen::{HTMLHeadElementBinding, HTMLHtmlElementBinding};
use dom::bindings::codegen::{HTMLAnchorElementBinding, HTMLBodyElementBinding, HTMLDivElementBinding, HTMLSpanElementBinding}; use dom::bindings::codegen::{HTMLAnchorElementBinding, HTMLBodyElementBinding};
use dom::bindings::codegen::{HTMLHRElementBinding}; use dom::bindings::codegen::{HTMLHRElementBinding, HTMLIFrameElementBinding};
use dom::bindings::codegen::{HTMLParagraphElementBinding, HTMLScriptElementBinding}; use dom::bindings::codegen::{HTMLParagraphElementBinding, HTMLScriptElementBinding};
use dom::bindings::codegen::{HTMLDivElementBinding, HTMLSpanElementBinding};
use dom::bindings::codegen::{HTMLImageElementBinding}; use dom::bindings::codegen::{HTMLImageElementBinding};
use dom::bindings::utils::{null_string, str}; use dom::bindings::utils::{null_string, str};
use dom::bindings::utils::{BindingObject, CacheableWrapper, DOMString, ErrorResult, WrapperCache}; use dom::bindings::utils::{BindingObject, CacheableWrapper, DOMString, ErrorResult, WrapperCache};
@ -18,6 +19,7 @@ use dom::htmlbodyelement::HTMLBodyElement;
use dom::htmlcollection::HTMLCollection; use dom::htmlcollection::HTMLCollection;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::htmlhrelement::HTMLHRElement; use dom::htmlhrelement::HTMLHRElement;
use dom::htmliframeelement::HTMLIFrameElement;
use dom::htmlimageelement::HTMLImageElement; use dom::htmlimageelement::HTMLImageElement;
use dom::htmlscriptelement::HTMLScriptElement; use dom::htmlscriptelement::HTMLScriptElement;
use dom::node::{ElementNodeTypeId, Node, ScriptView, AbstractNode}; use dom::node::{ElementNodeTypeId, Node, ScriptView, AbstractNode};
@ -28,13 +30,8 @@ use newcss::stylesheet::Stylesheet;
use js::jsapi::{JSContext, JSObject}; use js::jsapi::{JSContext, JSObject};
use std::cell::Cell; use std::cell::Cell;
use std::comm::ChanOne;
use std::comm; use std::comm;
use std::str::eq_slice; use std::str::eq_slice;
use extra::net::url::Url;
use geom::size::Size2D;
use servo_msg::constellation_msg::SubpageId;
pub struct Element { pub struct Element {
parent: Node<ScriptView>, parent: Node<ScriptView>,
@ -195,6 +192,8 @@ generate_cacheable_wrapper!(HTMLBodyElement, HTMLBodyElementBinding::Wrap)
generate_binding_object!(HTMLBodyElement) generate_binding_object!(HTMLBodyElement)
generate_cacheable_wrapper!(HTMLDivElement, HTMLDivElementBinding::Wrap) generate_cacheable_wrapper!(HTMLDivElement, HTMLDivElementBinding::Wrap)
generate_binding_object!(HTMLDivElement) generate_binding_object!(HTMLDivElement)
generate_cacheable_wrapper!(HTMLIFrameElement, HTMLIFrameElementBinding::Wrap)
generate_binding_object!(HTMLIFrameElement)
generate_cacheable_wrapper!(HTMLImageElement, HTMLImageElementBinding::Wrap) generate_cacheable_wrapper!(HTMLImageElement, HTMLImageElementBinding::Wrap)
generate_binding_object!(HTMLImageElement) generate_binding_object!(HTMLImageElement)
generate_cacheable_wrapper!(HTMLParagraphElement, HTMLParagraphElementBinding::Wrap) generate_cacheable_wrapper!(HTMLParagraphElement, HTMLParagraphElementBinding::Wrap)
@ -214,13 +213,6 @@ pub struct HTMLHeadingElement {
level: HeadingLevel, level: HeadingLevel,
} }
pub struct HTMLIframeElement {
parent: HTMLElement,
frame: Option<Url>,
subpage_id: Option<SubpageId>,
size_future_chan: Option<ChanOne<Size2D<uint>>>,
}
// //
// Element methods // Element methods
// //

View file

@ -0,0 +1,126 @@
/* 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::document::AbstractDocument;
use dom::htmlelement::HTMLElement;
use dom::windowproxy::WindowProxy;
use geom::size::Size2D;
use servo_msg::constellation_msg::SubpageId;
use std::comm::ChanOne;
use extra::net::url::Url;
pub struct HTMLIFrameElement {
parent: HTMLElement,
frame: Option<Url>,
subpage_id: Option<SubpageId>,
size_future_chan: Option<ChanOne<Size2D<uint>>>,
}
impl HTMLIFrameElement {
pub fn Src(&self) -> DOMString {
null_string
}
pub fn SetSrc(&mut self, _src: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Srcdoc(&self) -> DOMString {
null_string
}
pub fn SetSrcdoc(&mut self, _srcdoc: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Name(&self) -> DOMString {
null_string
}
pub fn SetName(&mut self, _name: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Sandbox(&self) -> DOMString {
null_string
}
pub fn SetSandbox(&self, _sandbox: &DOMString) {
}
pub fn AllowFullscreen(&self) -> bool {
false
}
pub fn SetAllowFullscreen(&mut self, _allow: bool, _rv: &mut ErrorResult) {
}
pub fn Width(&self) -> DOMString {
null_string
}
pub fn SetWidth(&mut self, _width: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Height(&self) -> DOMString {
null_string
}
pub fn SetHeight(&mut self, _height: &DOMString, _rv: &mut ErrorResult) {
}
pub fn GetContentDocument(&self) -> Option<AbstractDocument> {
None
}
pub fn GetContentWindow(&self) -> Option<@mut WindowProxy> {
None
}
pub fn Align(&self) -> DOMString {
null_string
}
pub fn SetAlign(&mut self, _align: &DOMString, _rv: &mut ErrorResult) {
}
pub fn Scrolling(&self) -> DOMString {
null_string
}
pub fn SetScrolling(&mut self, _scrolling: &DOMString, _rv: &mut ErrorResult) {
}
pub fn FrameBorder(&self) -> DOMString {
null_string
}
pub fn SetFrameBorder(&mut self, _frameborder: &DOMString, _rv: &mut ErrorResult) {
}
pub fn LongDesc(&self) -> DOMString {
null_string
}
pub fn SetLongDesc(&mut self, _longdesc: &DOMString, _rv: &mut ErrorResult) {
}
pub fn MarginHeight(&self) -> DOMString {
null_string
}
pub fn SetMarginHeight(&mut self, _marginheight: &DOMString, _rv: &mut ErrorResult) {
}
pub fn MarginWidth(&self) -> DOMString {
null_string
}
pub fn SetMarginWidth(&mut self, _marginwidth: &DOMString, _rv: &mut ErrorResult) {
}
pub fn GetSVGDocument(&self) -> Option<AbstractDocument> {
None
}
}

View file

@ -11,9 +11,10 @@ use dom::bindings::utils::{BindingObject, CacheableWrapper, rust_box};
use dom::bindings; use dom::bindings;
use dom::characterdata::CharacterData; use dom::characterdata::CharacterData;
use dom::document::AbstractDocument; use dom::document::AbstractDocument;
use dom::element::{Element, ElementTypeId, HTMLImageElementTypeId, HTMLIframeElementTypeId, HTMLIframeElement}; use dom::element::{Element, ElementTypeId, HTMLImageElementTypeId, HTMLIframeElementTypeId};
use dom::element::{HTMLStyleElementTypeId}; use dom::element::{HTMLStyleElementTypeId};
use dom::htmlimageelement::HTMLImageElement; use dom::htmlimageelement::HTMLImageElement;
use dom::htmliframeelement::HTMLIFrameElement;
use dom::window::Window; use dom::window::Window;
use std::cast; use std::cast;
@ -401,14 +402,14 @@ impl<'self, View> AbstractNode<View> {
self.type_id() == ElementNodeTypeId(HTMLIframeElementTypeId) self.type_id() == ElementNodeTypeId(HTMLIframeElementTypeId)
} }
pub fn with_imm_iframe_element<R>(self, f: &fn(&HTMLIframeElement) -> R) -> R { pub fn with_imm_iframe_element<R>(self, f: &fn(&HTMLIFrameElement) -> R) -> R {
if !self.is_iframe_element() { if !self.is_iframe_element() {
fail!(~"node is not an iframe element"); fail!(~"node is not an iframe element");
} }
self.transmute(f) self.transmute(f)
} }
pub fn with_mut_iframe_element<R>(self, f: &fn(&mut HTMLIframeElement) -> R) -> R { pub fn with_mut_iframe_element<R>(self, f: &fn(&mut HTMLIFrameElement) -> R) -> R {
if !self.is_iframe_element() { if !self.is_iframe_element() {
fail!(~"node is not an iframe element"); fail!(~"node is not an iframe element");
} }

View file

@ -18,8 +18,8 @@ use dom::element::{HTMLAnchorElementTypeId, HTMLAsideElementTypeId, HTMLBRElemen
use dom::element::{HTMLAsideElement, HTMLBRElement, use dom::element::{HTMLAsideElement, HTMLBRElement,
HTMLBoldElement, HTMLDivElement, HTMLFontElement, HTMLFormElement, HTMLBoldElement, HTMLDivElement, HTMLFontElement, HTMLFormElement,
HTMLHeadElement, HTMLHeadingElement, HTMLHtmlElement, HTMLHeadElement, HTMLHeadingElement, HTMLHtmlElement,
HTMLInputElement, HTMLIframeElement, HTMLInputElement, HTMLItalicElement, HTMLLinkElement,
HTMLItalicElement, HTMLLinkElement, HTMLListItemElement, HTMLMetaElement, HTMLListItemElement, HTMLMetaElement,
HTMLOListElement, HTMLOptionElement, HTMLParagraphElement, HTMLOListElement, HTMLOptionElement, HTMLParagraphElement,
HTMLSectionElement, HTMLSelectElement, HTMLSmallElement, HTMLSectionElement, HTMLSelectElement, HTMLSmallElement,
HTMLSpanElement, HTMLStyleElement, HTMLTableBodyElement, HTMLSpanElement, HTMLStyleElement, HTMLTableBodyElement,
@ -30,6 +30,7 @@ use dom::element::{HTMLHeadingElementTypeId, Heading1, Heading2, Heading3, Headi
use dom::htmlanchorelement::HTMLAnchorElement; use dom::htmlanchorelement::HTMLAnchorElement;
use dom::htmlbodyelement::HTMLBodyElement; use dom::htmlbodyelement::HTMLBodyElement;
use dom::htmlhrelement::HTMLHRElement; use dom::htmlhrelement::HTMLHRElement;
use dom::htmliframeelement::HTMLIFrameElement;
use dom::htmlimageelement::HTMLImageElement; use dom::htmlimageelement::HTMLImageElement;
use dom::htmlscriptelement::HTMLScriptElement; use dom::htmlscriptelement::HTMLScriptElement;
use dom::element::{Element, Attr}; use dom::element::{Element, Attr};
@ -229,7 +230,7 @@ fn build_element_from_tag(cx: *JSContext, tag: &str) -> AbstractNode<ScriptView>
handle_element!(cx, tag, "ul", HTMLUListElementTypeId, HTMLUListElement, []); handle_element!(cx, tag, "ul", HTMLUListElementTypeId, HTMLUListElement, []);
handle_element!(cx, tag, "img", HTMLImageElementTypeId, HTMLImageElement, [(image: None)]); handle_element!(cx, tag, "img", HTMLImageElementTypeId, HTMLImageElement, [(image: None)]);
handle_element!(cx, tag, "iframe", HTMLIframeElementTypeId, HTMLIframeElement, [(frame: None), (size_future_chan: None), (subpage_id: None)]); handle_element!(cx, tag, "iframe", HTMLIframeElementTypeId, HTMLIFrameElement, [(frame: None), (size_future_chan: None), (subpage_id: None)]);
handle_element!(cx, tag, "h1", HTMLHeadingElementTypeId, HTMLHeadingElement, [(level: Heading1)]); handle_element!(cx, tag, "h1", HTMLHeadingElementTypeId, HTMLHeadingElement, [(level: Heading1)]);
handle_element!(cx, tag, "h2", HTMLHeadingElementTypeId, HTMLHeadingElement, [(level: Heading2)]); handle_element!(cx, tag, "h2", HTMLHeadingElementTypeId, HTMLHeadingElement, [(level: Heading2)]);

View file

@ -51,6 +51,7 @@ pub mod dom {
pub mod HTMLHeadElementBinding; pub mod HTMLHeadElementBinding;
pub mod HTMLHRElementBinding; pub mod HTMLHRElementBinding;
pub mod HTMLHtmlElementBinding; pub mod HTMLHtmlElementBinding;
pub mod HTMLIFrameElementBinding;
pub mod HTMLImageElementBinding; pub mod HTMLImageElementBinding;
pub mod HTMLParagraphElementBinding; pub mod HTMLParagraphElementBinding;
pub mod HTMLScriptElementBinding; pub mod HTMLScriptElementBinding;
@ -81,6 +82,7 @@ pub mod dom {
pub mod htmldocument; pub mod htmldocument;
pub mod htmlelement; pub mod htmlelement;
pub mod htmlhrelement; pub mod htmlhrelement;
pub mod htmliframeelement;
pub mod htmlimageelement; pub mod htmlimageelement;
pub mod htmlscriptelement; pub mod htmlscriptelement;
pub mod mouseevent; pub mod mouseevent;

View file

@ -16,5 +16,6 @@
<embed></embed> <embed></embed>
<form></form> <form></form>
<applet></applet> <applet></applet>
<iframe></iframe>
</body> </body>
</html> </html>

View file

@ -130,6 +130,7 @@ document.title = "foo";
window.alert(document.title); window.alert(document.title);
window.alert(document.links[0]); window.alert(document.links[0]);
window.alert(document.getElementsByTagName('iframe')[0]);
window.alert(document.getElementsByTagName("body")[0]); window.alert(document.getElementsByTagName("body")[0]);
//TODO: Doesn't work until we throw proper exceptions instead of returning 0 on //TODO: Doesn't work until we throw proper exceptions instead of returning 0 on