Auto merge of #7750 - frewsxcv:html-table-section-element-rows, r=nox

HTMLTableSectionElement improvements

'thead' and 'tfoot' now create instances of HTMLTableSectionElement

HTMLTableSectionElement.rows has been implemented

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7750)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-10-04 11:57:10 -06:00
commit 9eb0effaf6
10 changed files with 108 additions and 42 deletions

View file

@ -223,7 +223,11 @@ pub fn create_element(name: QualName, prefix: Option<Atom>,
atom!("td") => make!(HTMLTableDataCellElement),
atom!("template") => make!(HTMLTemplateElement),
atom!("textarea") => make!(HTMLTextAreaElement),
// https://html.spec.whatwg.org/multipage/#the-tfoot-element:concept-element-dom
atom!("tfoot") => make!(HTMLTableSectionElement),
atom!("th") => make!(HTMLTableHeaderCellElement),
// https://html.spec.whatwg.org/multipage/#the-thead-element:concept-element-dom
atom!("thead") => make!(HTMLTableSectionElement),
atom!("time") => make!(HTMLTimeElement),
atom!("title") => make!(HTMLTitleElement),
atom!("tr") => make!(HTMLTableRowElement),

View file

@ -4,14 +4,17 @@
use cssparser::RGBA;
use dom::attr::Attr;
use dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding;
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLTableSectionElementDerived};
use dom::bindings::js::Root;
use dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::{self, HTMLTableSectionElementMethods};
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::codegen::InheritTypes::NodeCast;
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLTableRowElementDerived, HTMLTableSectionElementDerived};
use dom::bindings::js::{Root, RootedReference};
use dom::document::Document;
use dom::element::{AttributeMutation, ElementTypeId};
use dom::element::{AttributeMutation, Element, ElementTypeId};
use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlcollection::{CollectionFilter, HTMLCollection};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::node::{Node, NodeTypeId};
use dom::node::{Node, NodeTypeId, window_from_node};
use dom::virtualmethods::VirtualMethods;
use std::cell::Cell;
use util::str::{self, DOMString};
@ -54,6 +57,22 @@ impl HTMLTableSectionElement {
}
}
#[derive(JSTraceable)]
struct RowsFilter;
impl CollectionFilter for RowsFilter {
fn filter(&self, elem: &Element, root: &Node) -> bool {
elem.is_htmltablerowelement()
&& NodeCast::from_ref(elem).GetParentNode().r() == Some(root)
}
}
impl HTMLTableSectionElementMethods for HTMLTableSectionElement {
// https://html.spec.whatwg.org/multipage/#dom-tbody-rows
fn Rows(&self) -> Root<HTMLCollection> {
HTMLCollection::create(&window_from_node(self), NodeCast::from_ref(self), box RowsFilter)
}
}
impl VirtualMethods for HTMLTableSectionElement {
fn super_type<'b>(&'b self) -> Option<&'b VirtualMethods> {
let htmlelement: &HTMLElement = HTMLElementCast::from_ref(self);

View file

@ -5,7 +5,7 @@
// https://www.whatwg.org/html/#htmltablesectionelement
interface HTMLTableSectionElement : HTMLElement {
//readonly attribute HTMLCollection rows;
readonly attribute HTMLCollection rows;
//HTMLElement insertRow(optional long index = -1);
//void deleteRow(long index);