Skip to content

Commit

Permalink
Generate bindings for HTMLTableColElement.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tetsuharu OHZEKI committed Aug 23, 2013
1 parent ce647eb commit c2391fe
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/components/script/dom/bindings/codegen/Bindings.conf
Expand Up @@ -573,6 +573,7 @@ addHTMLElement('HTMLStyleElement')
addHTMLElement('HTMLTableCaptionElement')
addHTMLElement('HTMLTableElement')
addHTMLElement('HTMLTableCellElement')
addHTMLElement('HTMLTableColElement')
addHTMLElement('HTMLTableRowElement')
addHTMLElement('HTMLTableSectionElement')
addHTMLElement('HTMLTextAreaElement')
Expand Down
1 change: 1 addition & 0 deletions src/components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -4641,6 +4641,7 @@ def makeEnumTypedef(e):
'dom::htmltablecaptionelement::HTMLTableCaptionElement',
'dom::htmltableelement::HTMLTableElement',
'dom::htmltablecellelement::HTMLTableCellElement',
'dom::htmltablecolelement::HTMLTableColElement',
'dom::htmltablerowelement::HTMLTableRowElement',
'dom::htmltablesectionelement::HTMLTableSectionElement',
'dom::htmltextareaelement::HTMLTextAreaElement',
Expand Down
@@ -0,0 +1,30 @@
/* -*- 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/
*
* © 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 HTMLTableColElement : HTMLElement {
[SetterThrows]
attribute unsigned long span;
};

partial interface HTMLTableColElement {
[SetterThrows]
attribute DOMString align;
[SetterThrows]
attribute DOMString ch;
[SetterThrows]
attribute DOMString chOff;
[SetterThrows]
attribute DOMString vAlign;
[SetterThrows]
attribute DOMString width;
};
3 changes: 3 additions & 0 deletions src/components/script/dom/bindings/node.rs
Expand Up @@ -19,6 +19,7 @@ use dom::element::{HTMLElementTypeId,
HTMLSpanElementTypeId, HTMLSourceElementTypeId,
HTMLStyleElementTypeId, HTMLTextAreaElementTypeId,
HTMLTableElementTypeId, HTMLTableCaptionElementTypeId, HTMLTableCellElementTypeId,
HTMLTableColElementTypeId,
HTMLTableRowElementTypeId, HTMLTableSectionElementTypeId, HTMLTimeElementTypeId,
HTMLTitleElementTypeId, HTMLUListElementTypeId, HTMLDListElementTypeId};
use dom::element::{HTMLHeadElement,HTMLHtmlElement, HTMLDivElement, HTMLParagraphElement, HTMLSpanElement};
Expand All @@ -45,6 +46,7 @@ use dom::htmlstyleelement::HTMLStyleElement;
use dom::htmltableelement::HTMLTableElement;
use dom::htmltablecaptionelement::HTMLTableCaptionElement;
use dom::htmltablecellelement::HTMLTableCellElement;
use dom::htmltablecolelement::HTMLTableColElement;
use dom::htmltablerowelement::HTMLTableRowElement;
use dom::htmltablesectionelement::HTMLTableSectionElement;
use dom::htmltextareaelement::HTMLTextAreaElement;
Expand Down Expand Up @@ -143,6 +145,7 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> *JSObject
ElementNodeTypeId(HTMLTableElementTypeId) => generate_element!(HTMLTableElement),
ElementNodeTypeId(HTMLTableCellElementTypeId) => generate_element!(HTMLTableCellElement),
ElementNodeTypeId(HTMLTableCaptionElementTypeId) => generate_element!(HTMLTableCaptionElement),
ElementNodeTypeId(HTMLTableColElementTypeId) => generate_element!(HTMLTableColElement),
ElementNodeTypeId(HTMLTableRowElementTypeId) => generate_element!(HTMLTableRowElement),
ElementNodeTypeId(HTMLTableSectionElementTypeId) => generate_element!(HTMLTableSectionElement),
ElementNodeTypeId(HTMLTextAreaElementTypeId) => generate_element!(HTMLTextAreaElement),
Expand Down
8 changes: 6 additions & 2 deletions src/components/script/dom/element.rs
Expand Up @@ -18,7 +18,7 @@ use dom::bindings::codegen::{HTMLAnchorElementBinding, HTMLAppletElementBinding,
HTMLScriptElementBinding, HTMLSourceElementBinding, HTMLSpanElementBinding,
HTMLStyleElementBinding, HTMLTableElementBinding,
HTMLTableCaptionElementBinding, HTMLTableCellElementBinding,
HTMLTableRowElementBinding,
HTMLTableColElementBinding, HTMLTableRowElementBinding,
HTMLTableSectionElementBinding, HTMLTextAreaElementBinding,
HTMLTimeElementBinding, HTMLTitleElementBinding, HTMLUListElementBinding};
use dom::bindings::utils::{null_string, str};
Expand Down Expand Up @@ -49,6 +49,7 @@ use dom::htmlstyleelement::HTMLStyleElement;
use dom::htmltableelement::HTMLTableElement;
use dom::htmltablecaptionelement::HTMLTableCaptionElement;
use dom::htmltablecellelement::HTMLTableCellElement;
use dom::htmltablecolelement::HTMLTableColElement;
use dom::htmltablerowelement::HTMLTableRowElement;
use dom::htmltablesectionelement::HTMLTableSectionElement;
use dom::htmltextareaelement::HTMLTextAreaElement;
Expand Down Expand Up @@ -125,9 +126,10 @@ pub enum ElementTypeId {
HTMLSourceElementTypeId,
HTMLSpanElementTypeId,
HTMLStyleElementTypeId,
HTMLTableElementTypeId,
HTMLTableCaptionElementTypeId,
HTMLTableCellElementTypeId,
HTMLTableElementTypeId,
HTMLTableColElementTypeId,
HTMLTableRowElementTypeId,
HTMLTableSectionElementTypeId,
HTMLTextAreaElementTypeId,
Expand Down Expand Up @@ -261,6 +263,8 @@ generate_cacheable_wrapper!(HTMLTableCaptionElement, HTMLTableCaptionElementBind
generate_binding_object!(HTMLTableCaptionElement)
generate_cacheable_wrapper!(HTMLTableCellElement, HTMLTableCellElementBinding::Wrap)
generate_binding_object!(HTMLTableCellElement)
generate_cacheable_wrapper!(HTMLTableColElement, HTMLTableColElementBinding::Wrap)
generate_binding_object!(HTMLTableColElement)
generate_cacheable_wrapper!(HTMLTableRowElement, HTMLTableRowElementBinding::Wrap)
generate_binding_object!(HTMLTableRowElement)
generate_cacheable_wrapper!(HTMLTableSectionElement, HTMLTableSectionElementBinding::Wrap)
Expand Down
54 changes: 54 additions & 0 deletions src/components/script/dom/htmltablecolelement.rs
@@ -0,0 +1,54 @@
/* 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 HTMLTableColElement {
parent: HTMLElement,
}

impl HTMLTableColElement {
pub fn Span(&self) -> u32 {
0
}

pub fn SetSpan(&mut self, _span: u32, _rv: &mut ErrorResult) {
}

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

pub fn SetAlign(&mut self, _align: &DOMString, _rv: &mut ErrorResult) {
}

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

pub fn SetCh(&mut self, _ch: &DOMString, _rv: &mut ErrorResult) {
}

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

pub fn SetChOff(&mut self, _ch_off: &DOMString, _rv: &mut ErrorResult) {
}

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

pub fn SetVAlign(&mut self, _v_align: &DOMString, _rv: &mut ErrorResult) {
}

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

pub fn SetWidth(&mut self, _width: &DOMString, _rv: &mut ErrorResult) {
}
}
8 changes: 6 additions & 2 deletions src/components/script/html/hubbub_html_parser.rs
Expand Up @@ -16,7 +16,8 @@ use dom::element::{HTMLElementTypeId,
HTMLSelectElementTypeId, HTMLSmallElementTypeId, HTMLSourceElementTypeId,
HTMLSpanElementTypeId, HTMLStyleElementTypeId, HTMLTableSectionElementTypeId,
HTMLTableCellElementTypeId, HTMLTableElementTypeId,
HTMLTableCaptionElementTypeId, HTMLTableRowElementTypeId, HTMLTextAreaElementTypeId,
HTMLTableCaptionElementTypeId, HTMLTableColElementTypeId,
HTMLTableRowElementTypeId, HTMLTextAreaElementTypeId,
HTMLTimeElementTypeId, HTMLTitleElementTypeId, HTMLUListElementTypeId,
UnknownElementTypeId};
use dom::element::{HTMLDivElement, HTMLFontElement, HTMLFormElement,
Expand Down Expand Up @@ -49,6 +50,7 @@ use dom::htmlstyleelement::HTMLStyleElement;
use dom::htmltableelement::HTMLTableElement;
use dom::htmltablecaptionelement::HTMLTableCaptionElement;
use dom::htmltablecellelement::HTMLTableCellElement;
use dom::htmltablecolelement::HTMLTableColElement;
use dom::htmltablerowelement::HTMLTableRowElement;
use dom::htmltablesectionelement::HTMLTableSectionElement;
use dom::htmltextareaelement::HTMLTextAreaElement;
Expand Down Expand Up @@ -264,9 +266,11 @@ fn build_element_from_tag(cx: *JSContext, tag: &str) -> AbstractNode<ScriptView>
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, "table", HTMLTableElementTypeId, HTMLTableElement, []);
handle_element!(cx, tag, "caption", HTMLTableCaptionElementTypeId, HTMLTableCaptionElement, []);
handle_element!(cx, tag, "td", HTMLTableCellElementTypeId, HTMLTableCellElement, []);
handle_element!(cx, tag, "table", HTMLTableElementTypeId, HTMLTableElement, []);
handle_element!(cx, tag, "col", HTMLTableColElementTypeId, HTMLTableColElement, []);
handle_element!(cx, tag, "colgroup",HTMLTableColElementTypeId, HTMLTableColElement, []);
handle_element!(cx, tag, "tbody", HTMLTableSectionElementTypeId, HTMLTableSectionElement, []);
handle_element!(cx, tag, "textarea",HTMLTextAreaElementTypeId, HTMLTextAreaElement, []);
handle_element!(cx, tag, "time", HTMLTimeElementTypeId, HTMLTimeElement, []);
Expand Down
4 changes: 3 additions & 1 deletion src/components/script/script.rc
Expand Up @@ -70,8 +70,9 @@ pub mod dom {
pub mod HTMLSpanElementBinding;
pub mod HTMLStyleElementBinding;
pub mod HTMLTableElementBinding;
pub mod HTMLTableCellElementBinding;
pub mod HTMLTableCaptionElementBinding;
pub mod HTMLTableCellElementBinding;
pub mod HTMLTableColElementBinding;
pub mod HTMLTableRowElementBinding;
pub mod HTMLTableSectionElementBinding;
pub mod HTMLTextAreaElementBinding;
Expand Down Expand Up @@ -123,6 +124,7 @@ pub mod dom {
pub mod htmltableelement;
pub mod htmltablecaptionelement;
pub mod htmltablecellelement;
pub mod htmltablecolelement;
pub mod htmltablerowelement;
pub mod htmltablesectionelement;
pub mod htmltextareaelement;
Expand Down
3 changes: 3 additions & 0 deletions src/test/html/test_bindings.html
Expand Up @@ -25,6 +25,9 @@
<ol type="1"></ol>
<table>
<caption>sample table</caption>
<colgroup>
<col/>
</colgroup>
<tbody>
<tr><td>head</td></tr>
<tr><td>data</td></tr>
Expand Down
10 changes: 10 additions & 0 deletions src/test/html/test_bindings.js
Expand Up @@ -210,6 +210,16 @@ window.alert(tags.length);
window.alert(tags[0].tagName);
window.alert(tags[0] instanceof HTMLTableCellElement);

window.alert("HTMLTableColElement");
let tagList = ["col", "colgroup"];
for (let i = 0, l = tagList.length; i < l; ++i) {
let tags = document.getElementsByTagName(tagList[i]);
window.alert(tags);
window.alert(tags.length);
window.alert(tags[0].tagName);
window.alert(tags[0] instanceof HTMLTableColElement);
}

//TODO: Doesn't work until we throw proper exceptions instead of returning 0 on
// unwrap failure.
/*try {
Expand Down

0 comments on commit c2391fe

Please sign in to comment.