mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Auto merge of #7089 - dzbarsky:createtbody, r=Ms2ger
Implement HTMLTableElement#createTBody <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7089) <!-- Reviewable:end -->
This commit is contained in:
commit
44d93bc37a
5 changed files with 32 additions and 54 deletions
|
@ -6,14 +6,16 @@ use dom::attr::{Attr, AttrHelpers, AttrValue};
|
||||||
use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods;
|
||||||
use dom::bindings::codegen::Bindings::HTMLTableElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLTableElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLTableCaptionElementCast};
|
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, HTMLTableCaptionElementCast};
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLTableElementDerived, NodeCast};
|
use dom::bindings::codegen::InheritTypes::{HTMLTableElementDerived, NodeCast};
|
||||||
use dom::bindings::js::Root;
|
use dom::bindings::codegen::InheritTypes::HTMLTableSectionElementDerived;
|
||||||
|
use dom::bindings::js::{Root, RootedReference};
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||||
use dom::element::ElementTypeId;
|
use dom::element::{ElementHelpers, ElementTypeId};
|
||||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||||
use dom::htmltablecaptionelement::HTMLTableCaptionElement;
|
use dom::htmltablecaptionelement::HTMLTableCaptionElement;
|
||||||
|
use dom::htmltablesectionelement::HTMLTableSectionElement;
|
||||||
use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node};
|
use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node};
|
||||||
use dom::virtualmethods::VirtualMethods;
|
use dom::virtualmethods::VirtualMethods;
|
||||||
|
|
||||||
|
@ -110,6 +112,24 @@ impl<'a> HTMLTableElementMethods for &'a HTMLTableElement {
|
||||||
NodeCast::from_ref(caption.r()).remove_self();
|
NodeCast::from_ref(caption.r()).remove_self();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/#dom-table-createtbody
|
||||||
|
fn CreateTBody(self) -> Root<HTMLTableSectionElement> {
|
||||||
|
let tbody = HTMLTableSectionElement::new("tbody".to_owned(),
|
||||||
|
None,
|
||||||
|
document_from_node(self).r());
|
||||||
|
let node = NodeCast::from_ref(self);
|
||||||
|
let last_tbody =
|
||||||
|
node.rev_children()
|
||||||
|
.filter_map(ElementCast::to_root)
|
||||||
|
.find(|n| n.is_htmltablesectionelement() && n.local_name() == &atom!("tbody"));
|
||||||
|
let reference_element =
|
||||||
|
last_tbody.and_then(|t| NodeCast::from_root(t).GetNextSibling());
|
||||||
|
|
||||||
|
assert!(node.InsertBefore(NodeCast::from_ref(tbody.r()),
|
||||||
|
reference_element.r()).is_ok());
|
||||||
|
tbody
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait HTMLTableElementHelpers {
|
pub trait HTMLTableElementHelpers {
|
||||||
|
|
|
@ -15,7 +15,7 @@ interface HTMLTableElement : HTMLElement {
|
||||||
//HTMLElement createTFoot();
|
//HTMLElement createTFoot();
|
||||||
//void deleteTFoot();
|
//void deleteTFoot();
|
||||||
//readonly attribute HTMLCollection tBodies;
|
//readonly attribute HTMLCollection tBodies;
|
||||||
//HTMLElement createTBody();
|
HTMLTableSectionElement createTBody();
|
||||||
//readonly attribute HTMLCollection rows;
|
//readonly attribute HTMLCollection rows;
|
||||||
//HTMLElement insertRow(optional long index = -1);
|
//HTMLElement insertRow(optional long index = -1);
|
||||||
//void deleteRow(long index);
|
//void deleteRow(long index);
|
||||||
|
|
|
@ -4587,9 +4587,6 @@
|
||||||
[HTMLTableElement interface: attribute tBodies]
|
[HTMLTableElement interface: attribute tBodies]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLTableElement interface: operation createTBody()]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLTableElement interface: attribute rows]
|
[HTMLTableElement interface: attribute rows]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
@ -4653,9 +4650,6 @@
|
||||||
[HTMLTableElement interface: document.createElement("table") must inherit property "tBodies" with the proper type (9)]
|
[HTMLTableElement interface: document.createElement("table") must inherit property "tBodies" with the proper type (9)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[HTMLTableElement interface: document.createElement("table") must inherit property "createTBody" with the proper type (10)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[HTMLTableElement interface: document.createElement("table") must inherit property "rows" with the proper type (11)]
|
[HTMLTableElement interface: document.createElement("table") must inherit property "rows" with the proper type (11)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
[createTBody.html]
|
|
||||||
type: testharness
|
|
||||||
[No child nodes]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[One tbody child node]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Two tbody child nodes]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[A thead and a tbody child node]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[A tfoot and a tbody child node]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[A tbody and a thead child node]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[A tbody and a tfoot child node]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Two tbody child nodes and a div]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[One HTML and one namespaced tbody child node]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[Two nested tbody child nodes]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[A tbody node inside a thead child node]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[A tbody node inside a tfoot child node]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[A tbody node inside a thead child node after a tbody child node]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[A tbody node inside a tfoot child node after a tbody child node]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
|
@ -162,4 +162,12 @@ test(function() {
|
||||||
assert_array_equals(table.childNodes, [before, tbody, after1]);
|
assert_array_equals(table.childNodes, [before, tbody, after1]);
|
||||||
assert_tbody(tbody);
|
assert_tbody(tbody);
|
||||||
}, "A tbody node inside a tfoot child node after a tbody child node");
|
}, "A tbody node inside a tfoot child node after a tbody child node");
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var table = document.createElementNS(htmlNS, "foo:table");
|
||||||
|
var tbody = table.createTBody();
|
||||||
|
|
||||||
|
assert_equals(tbody.prefix, null);
|
||||||
|
}, "A prefixed table creates tbody without prefix");
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue