Introduce HTMLTable{Data,Header}CellElement::new.

This commit is contained in:
Ms2ger 2013-10-31 15:31:15 +01:00
parent 618447445f
commit a972c470a7
4 changed files with 37 additions and 15 deletions

View file

@ -12,7 +12,7 @@ pub struct HTMLTableCellElement {
} }
impl HTMLTableCellElement { impl HTMLTableCellElement {
pub fn new(type_id: ElementTypeId, tag_name: ~str, document: AbstractDocument) -> HTMLTableCellElement { pub fn new_inherited(type_id: ElementTypeId, tag_name: ~str, document: AbstractDocument) -> HTMLTableCellElement {
HTMLTableCellElement { HTMLTableCellElement {
htmlelement: HTMLElement::new(type_id, tag_name, document) htmlelement: HTMLElement::new(type_id, tag_name, document)
} }

View file

@ -2,8 +2,25 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::HTMLTableDataCellElementBinding;
use dom::document::AbstractDocument;
use dom::element::HTMLTableDataCellElementTypeId;
use dom::htmltablecellelement::HTMLTableCellElement; use dom::htmltablecellelement::HTMLTableCellElement;
use dom::node::{AbstractNode, Node, ScriptView};
pub struct HTMLTableDataCellElement { pub struct HTMLTableDataCellElement {
htmltablecellelement: HTMLTableCellElement, htmltablecellelement: HTMLTableCellElement,
} }
impl HTMLTableDataCellElement {
pub fn new_inherited(localName: ~str, document: AbstractDocument) -> HTMLTableDataCellElement {
HTMLTableDataCellElement {
htmltablecellelement: HTMLTableCellElement::new_inherited(HTMLTableDataCellElementTypeId, localName, document)
}
}
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> {
let element = HTMLTableDataCellElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLTableDataCellElementBinding::Wrap)
}
}

View file

@ -2,8 +2,25 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::HTMLTableHeaderCellElementBinding;
use dom::document::AbstractDocument;
use dom::element::HTMLTableHeaderCellElementTypeId;
use dom::htmltablecellelement::HTMLTableCellElement; use dom::htmltablecellelement::HTMLTableCellElement;
use dom::node::{AbstractNode, Node, ScriptView};
pub struct HTMLTableHeaderCellElement { pub struct HTMLTableHeaderCellElement {
htmltablecellelement: HTMLTableCellElement, htmltablecellelement: HTMLTableCellElement,
} }
impl HTMLTableHeaderCellElement {
pub fn new_inherited(localName: ~str, document: AbstractDocument) -> HTMLTableHeaderCellElement {
HTMLTableHeaderCellElement {
htmltablecellelement: HTMLTableCellElement::new_inherited(HTMLTableHeaderCellElementTypeId, localName, document)
}
}
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> {
let element = HTMLTableHeaderCellElement::new_inherited(localName, document);
Node::reflect_node(@mut element, document, HTMLTableHeaderCellElementBinding::Wrap)
}
}

View file

@ -67,17 +67,6 @@ macro_rules! handle_newable_element(
} }
) )
) )
macro_rules! handle_htmltablecellelement(
($cx: expr,
$document: expr,
$tag: expr,
$string: expr,
$type_id: expr,
$ctor: ident) => (
handle_element_base!(htmltablecellelement, HTMLTableCellElement,
$cx, $document, $tag, $string, $type_id, $ctor, []);
)
)
macro_rules! handle_element_base( macro_rules! handle_element_base(
($parent: ident, ($parent: ident,
$parent_init: ident, $parent_init: ident,
@ -299,11 +288,10 @@ pub fn build_element_from_tag(cx: *JSContext, tag: &str, document: AbstractDocum
handle_htmlelement!(cx, document, tag, "small", HTMLElementTypeId, HTMLElement); handle_htmlelement!(cx, document, tag, "small", HTMLElementTypeId, HTMLElement);
handle_newable_element!(document, tag, "audio", HTMLAudioElement); handle_newable_element!(document, tag, "audio", HTMLAudioElement);
handle_newable_element!(document, tag, "td", HTMLTableDataCellElement);
handle_newable_element!(document, tag, "th", HTMLTableHeaderCellElement);
handle_newable_element!(document, tag, "video", HTMLVideoElement); handle_newable_element!(document, tag, "video", HTMLVideoElement);
handle_htmltablecellelement!(cx, document, tag, "td", HTMLTableDataCellElementTypeId, HTMLTableDataCellElement);
handle_htmltablecellelement!(cx, document, tag, "th", HTMLTableHeaderCellElementTypeId, HTMLTableHeaderCellElement);
return HTMLUnknownElement::new(tag.to_str(), document); return HTMLUnknownElement::new(tag.to_str(), document);
} }