diff options
author | Corey Farwell <coreyf@rwell.org> | 2015-09-26 14:57:25 -0400 |
---|---|---|
committer | Corey Farwell <coreyf@rwell.org> | 2015-10-03 12:23:22 -0400 |
commit | adbcb5345c6d87a4ebdf6763de4b4ff4a059cf47 (patch) | |
tree | 4ddef03ca322aa14bd76495b6178388b946a817c /components/script/dom/htmltablesectionelement.rs | |
parent | e40dd3843f9abb9a8a0908159edfa0c69b90b1ab (diff) | |
download | servo-adbcb5345c6d87a4ebdf6763de4b4ff4a059cf47.tar.gz servo-adbcb5345c6d87a4ebdf6763de4b4ff4a059cf47.zip |
HTMLTableSectionElement improvements
'thead' and 'tfoot' now create instances of HTMLTableSectionElement
HTMLTableSectionElement.rows has been implemented
Diffstat (limited to 'components/script/dom/htmltablesectionelement.rs')
-rw-r--r-- | components/script/dom/htmltablesectionelement.rs | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/components/script/dom/htmltablesectionelement.rs b/components/script/dom/htmltablesectionelement.rs index 8c1eddaa389..03e83f3d3ed 100644 --- a/components/script/dom/htmltablesectionelement.rs +++ b/components/script/dom/htmltablesectionelement.rs @@ -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); |