Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Generate bindings for HTMLSourceElement
  • Loading branch information
sonwow authored and jdm committed Aug 22, 2013
1 parent 57f3ce8 commit fe5b795
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/components/script/dom/bindings/codegen/Bindings.conf
Expand Up @@ -561,6 +561,7 @@ addHTMLElement('HTMLMetaElement')
addHTMLElement('HTMLOListElement')
addHTMLElement('HTMLParagraphElement')
addHTMLElement('HTMLScriptElement')
addHTMLElement('HTMLSourceElement')
addHTMLElement('HTMLSpanElement')
addHTMLElement('HTMLStyleElement')
addHTMLElement('HTMLTableCaptionElement')
Expand Down
1 change: 1 addition & 0 deletions src/components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -4630,6 +4630,7 @@ def makeEnumTypedef(e):
'dom::htmlmetaelement::HTMLMetaElement',
'dom::htmlolistelement::HTMLOListElement',
'dom::htmlscriptelement::HTMLScriptElement',
'dom::htmlsourceelement::HTMLSourceElement',
'dom::htmlstyleelement::HTMLStyleElement',
'dom::htmltablecaptionelement::HTMLTableCaptionElement',
'dom::htmltableelement::HTMLTableElement',
Expand Down
@@ -0,0 +1,21 @@
/* -*- 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-source-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.
*/

interface HTMLSourceElement : HTMLElement {
[SetterThrows]
attribute DOMString src;
[SetterThrows]
attribute DOMString type;
[SetterThrows]
attribute DOMString media;
};
5 changes: 4 additions & 1 deletion src/components/script/dom/bindings/node.rs
Expand Up @@ -13,7 +13,8 @@ use dom::element::{HTMLElementTypeId,
HTMLHtmlElementTypeId, HTMLIframeElementTypeId, HTMLImageElementTypeId,
HTMLMetaElementTypeId, HTMLOListElementTypeId,
HTMLParagraphElementTypeId, HTMLScriptElementTypeId,
HTMLSpanElementTypeId, HTMLStyleElementTypeId, HTMLTextAreaElementTypeId,
HTMLSpanElementTypeId, HTMLSourceElementTypeId,
HTMLStyleElementTypeId, HTMLTextAreaElementTypeId,
HTMLTableCaptionElementTypeId, HTMLTableElementTypeId,
HTMLTableRowElementTypeId, HTMLTableSectionElementTypeId, HTMLTimeElementTypeId,
HTMLTitleElementTypeId, HTMLUListElementTypeId, HTMLDListElementTypeId};
Expand All @@ -30,6 +31,7 @@ use dom::htmlimageelement::HTMLImageElement;
use dom::htmlmetaelement::HTMLMetaElement;
use dom::htmlolistelement::HTMLOListElement;
use dom::htmlscriptelement::HTMLScriptElement;
use dom::htmlsourceelement::HTMLSourceElement;
use dom::htmlstyleelement::HTMLStyleElement;
use dom::htmltablecaptionelement::HTMLTableCaptionElement;
use dom::htmltableelement::HTMLTableElement;
Expand Down Expand Up @@ -119,6 +121,7 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> *JSObject
ElementNodeTypeId(HTMLOListElementTypeId) => generate_element!(HTMLOListElement),
ElementNodeTypeId(HTMLParagraphElementTypeId) => generate_element!(HTMLParagraphElement),
ElementNodeTypeId(HTMLScriptElementTypeId) => generate_element!(HTMLScriptElement),
ElementNodeTypeId(HTMLSourceElementTypeId) => generate_element!(HTMLSourceElement),
ElementNodeTypeId(HTMLSpanElementTypeId) => generate_element!(HTMLSpanElement),
ElementNodeTypeId(HTMLStyleElementTypeId) => generate_element!(HTMLStyleElement),
ElementNodeTypeId(HTMLTableCaptionElementTypeId) => generate_element!(HTMLTableCaptionElement),
Expand Down
6 changes: 5 additions & 1 deletion src/components/script/dom/element.rs
Expand Up @@ -10,7 +10,7 @@ use dom::bindings::codegen::{HTMLAnchorElementBinding, HTMLBodyElementBinding, H
HTMLHtmlElementBinding, HTMLIFrameElementBinding,
HTMLImageElementBinding, HTMLMetaElementBinding,
HTMLOListElementBinding, HTMLParagraphElementBinding,
HTMLScriptElementBinding, HTMLSpanElementBinding,
HTMLScriptElementBinding, HTMLSourceElementBinding, HTMLSpanElementBinding,
HTMLStyleElementBinding, HTMLTableCaptionElementBinding,
HTMLTableElementBinding, HTMLTableRowElementBinding,
HTMLTableSectionElementBinding, HTMLTextAreaElementBinding,
Expand All @@ -32,6 +32,7 @@ use dom::htmlimageelement::HTMLImageElement;
use dom::htmlmetaelement::HTMLMetaElement;
use dom::htmlolistelement::HTMLOListElement;
use dom::htmlscriptelement::HTMLScriptElement;
use dom::htmlsourceelement::HTMLSourceElement;
use dom::htmlstyleelement::HTMLStyleElement;
use dom::htmltablecaptionelement::HTMLTableCaptionElement;
use dom::htmltableelement::HTMLTableElement;
Expand Down Expand Up @@ -103,6 +104,7 @@ pub enum ElementTypeId {
HTMLScriptElementTypeId,
HTMLSelectElementTypeId,
HTMLSmallElementTypeId,
HTMLSourceElementTypeId,
HTMLSpanElementTypeId,
HTMLStyleElementTypeId,
HTMLTableCaptionElementTypeId,
Expand Down Expand Up @@ -219,6 +221,8 @@ generate_cacheable_wrapper!(HTMLParagraphElement, HTMLParagraphElementBinding::W
generate_binding_object!(HTMLParagraphElement)
generate_cacheable_wrapper!(HTMLScriptElement, HTMLScriptElementBinding::Wrap)
generate_binding_object!(HTMLScriptElement)
generate_cacheable_wrapper!(HTMLSourceElement, HTMLSourceElementBinding::Wrap)
generate_binding_object!(HTMLSourceElement)
generate_cacheable_wrapper!(HTMLSpanElement, HTMLSpanElementBinding::Wrap)
generate_binding_object!(HTMLSpanElement)
generate_cacheable_wrapper!(HTMLStyleElement, HTMLStyleElementBinding::Wrap)
Expand Down
33 changes: 33 additions & 0 deletions src/components/script/dom/htmlsourceelement.rs
@@ -0,0 +1,33 @@
/* 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;

pub struct HTMLSourceElement {
parent: HTMLElement
}

impl HTMLSourceElement {
pub fn Src(&self) -> DOMString {
null_string
}

pub fn SetSrc(&mut self, _src: &DOMString, _rv: &mut ErrorResult) {
}

pub fn Type(&self) -> DOMString {
null_string
}

pub fn SetType(&mut self, _type: &DOMString, _rv: &mut ErrorResult) {
}

pub fn Media(&self) -> DOMString {
null_string
}

pub fn SetMedia(&mut self, _media: &DOMString, _rv: &mut ErrorResult) {
}
}
4 changes: 3 additions & 1 deletion src/components/script/html/hubbub_html_parser.rs
Expand Up @@ -12,7 +12,7 @@ use dom::element::{HTMLElementTypeId,
HTMLLinkElementTypeId, HTMLListItemElementTypeId,
HTMLMetaElementTypeId, HTMLOListElementTypeId, HTMLOptionElementTypeId,
HTMLParagraphElementTypeId, HTMLScriptElementTypeId,
HTMLSelectElementTypeId, HTMLSmallElementTypeId,
HTMLSelectElementTypeId, HTMLSmallElementTypeId, HTMLSourceElementTypeId,
HTMLSpanElementTypeId, HTMLStyleElementTypeId, HTMLTableSectionElementTypeId,
HTMLTableCellElementTypeId, HTMLTableElementTypeId,
HTMLTableCaptionElementTypeId, HTMLTableRowElementTypeId, HTMLTextAreaElementTypeId,
Expand All @@ -37,6 +37,7 @@ use dom::htmlimageelement::HTMLImageElement;
use dom::htmlmetaelement::HTMLMetaElement;
use dom::htmlolistelement::HTMLOListElement;
use dom::htmlscriptelement::HTMLScriptElement;
use dom::htmlsourceelement::HTMLSourceElement;
use dom::htmlstyleelement::HTMLStyleElement;
use dom::htmltablecaptionelement::HTMLTableCaptionElement;
use dom::htmltableelement::HTMLTableElement;
Expand Down Expand Up @@ -247,6 +248,7 @@ fn build_element_from_tag(cx: *JSContext, tag: &str) -> AbstractNode<ScriptView>
handle_element!(cx, tag, "script", HTMLScriptElementTypeId, HTMLScriptElement, []);
handle_element!(cx, tag, "select", HTMLSelectElementTypeId, HTMLSelectElement, []);
handle_element!(cx, tag, "small", HTMLSmallElementTypeId, HTMLSmallElement, []);
handle_element!(cx, tag, "source", HTMLSourceElementTypeId, HTMLSourceElement, []);
handle_element!(cx, tag, "span", HTMLSpanElementTypeId, HTMLSpanElement, []);
handle_element!(cx, tag, "style", HTMLStyleElementTypeId, HTMLStyleElement, []);
handle_element!(cx, tag, "caption", HTMLTableCaptionElementTypeId, HTMLTableCaptionElement, []);
Expand Down
2 changes: 2 additions & 0 deletions src/components/script/script.rc
Expand Up @@ -60,6 +60,7 @@ pub mod dom {
pub mod HTMLOListElementBinding;
pub mod HTMLParagraphElementBinding;
pub mod HTMLScriptElementBinding;
pub mod HTMLSourceElementBinding;
pub mod HTMLSpanElementBinding;
pub mod HTMLStyleElementBinding;
pub mod HTMLTableCaptionElementBinding;
Expand Down Expand Up @@ -104,6 +105,7 @@ pub mod dom {
pub mod htmlmetaelement;
pub mod htmlolistelement;
pub mod htmlscriptelement;
pub mod htmlsourceelement;
pub mod htmlstyleelement;
pub mod htmltablecaptionelement;
pub mod htmltableelement;
Expand Down
4 changes: 4 additions & 0 deletions src/test/html/test_bindings.html
Expand Up @@ -33,5 +33,9 @@
<i>i</i>
<textarea>textarea</textarea>
<time datetime="2014-02-14">Valentines day</time>
<audio>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
</audio>
</body>
</html>
7 changes: 7 additions & 0 deletions src/test/html/test_bindings.js
Expand Up @@ -158,6 +158,13 @@ window.alert(tags.length);
window.alert(tags[0].tagName);
window.alert(tags[0] instanceof HTMLCanvasElement);

window.alert("HTMLSourceElement:");
let tags = document.getElementsByTagName("source");
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0].tagName);
window.alert(tags[0] instanceof HTMLSourceElement);

window.alert("HTMLTimeElement:");
let tags = document.getElementsByTagName("time");
window.alert(tags);
Expand Down

0 comments on commit fe5b795

Please sign in to comment.