Bug 813034 - Implement table.createTBody(); r=mounir sr=smaug

This commit is contained in:
Marc Jessome 2012-12-04 00:04:30 -05:00
parent 1a40020bdd
commit 6648ee5590
5 changed files with 33 additions and 18 deletions

View File

@ -711,6 +711,35 @@ HTMLTableElement::DeleteCaption()
return NS_OK;
}
already_AddRefed<nsGenericHTMLElement>
HTMLTableElement::CreateTBody()
{
nsCOMPtr<nsINodeInfo> nodeInfo =
OwnerDoc()->NodeInfoManager()->GetNodeInfo(nsGkAtoms::tbody, nullptr,
kNameSpaceID_XHTML,
nsIDOMNode::ELEMENT_NODE);
MOZ_ASSERT(nodeInfo);
nsCOMPtr<nsGenericHTMLElement> newBody =
NS_NewHTMLTableSectionElement(nodeInfo.forget());
MOZ_ASSERT(newBody);
nsIContent* referenceNode = nullptr;
for (nsIContent* child = nsINode::GetLastChild();
child;
child = child->GetPreviousSibling()) {
if (child->IsHTML(nsGkAtoms::tbody)) {
referenceNode = child->GetNextSibling();
break;
}
}
ErrorResult rv;
nsINode::InsertBefore(*newBody, referenceNode, rv);
return newBody.forget();
}
already_AddRefed<nsGenericHTMLElement>
HTMLTableElement::InsertRow(int32_t aIndex, ErrorResult& aError)
{

View File

@ -93,6 +93,9 @@ public:
already_AddRefed<nsGenericHTMLElement> CreateTFoot();
nsIHTMLCollection* TBodies();
already_AddRefed<nsGenericHTMLElement> CreateTBody();
nsIHTMLCollection* Rows();
already_AddRefed<nsGenericHTMLElement> InsertRow(int32_t aIndex,

View File

@ -10,7 +10,6 @@ relativesrcdir := @relativesrcdir@
include $(DEPTH)/config/autoconf.mk
MOCHITEST_FILES := \
test_createTBody.html.json \
test_table-insertRow.html.json \
test_table-rows.html.json \
$(NULL)

View File

@ -1,16 +0,0 @@
{
"No child nodes": true,
"One tbody child node": true,
"Two tbody child nodes": true,
"A thead and a tbody child node": true,
"A tfoot and a tbody child node": true,
"A tbody and a thead child node": true,
"A tbody and a tfoot child node": true,
"Two tbody child nodes and a div": true,
"One HTML and one namespaced tbody child node": true,
"Two nested tbody child nodes": true,
"A tbody node inside a thead child node": true,
"A tbody node inside a tfoot child node": true,
"A tbody node inside a thead child node after a tbody child node": true,
"A tbody node inside a tfoot child node after a tbody child node": true
}

View File

@ -24,7 +24,7 @@ interface HTMLTableElement : HTMLElement {
HTMLElement createTFoot();
void deleteTFoot();
readonly attribute HTMLCollection tBodies;
//HTMLElement createTBody();
HTMLElement createTBody();
readonly attribute HTMLCollection rows;
[Throws]
HTMLElement insertRow(optional long index = -1);