aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmltablesectionelement.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/htmltablesectionelement.rs')
-rw-r--r--components/script/dom/htmltablesectionelement.rs29
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);