From 6648ee5590673c7b6b6fcd7b5bb4abe8b1b8cfb0 Mon Sep 17 00:00:00 2001 From: Marc Jessome Date: Tue, 4 Dec 2012 00:04:30 -0500 Subject: [PATCH] Bug 813034 - Implement table.createTBody(); r=mounir sr=smaug --- content/html/content/src/HTMLTableElement.cpp | 29 +++++++++++++++++++ content/html/content/src/HTMLTableElement.h | 3 ++ .../the-table-element/Makefile.in | 1 - .../test_createTBody.html.json | 16 ---------- dom/webidl/HTMLTableElement.webidl | 2 +- 5 files changed, 33 insertions(+), 18 deletions(-) delete mode 100644 dom/imptests/failures/html/html/semantics/tabular-data/the-table-element/test_createTBody.html.json diff --git a/content/html/content/src/HTMLTableElement.cpp b/content/html/content/src/HTMLTableElement.cpp index 1b21a9f2fb4f..71350a9bf286 100644 --- a/content/html/content/src/HTMLTableElement.cpp +++ b/content/html/content/src/HTMLTableElement.cpp @@ -711,6 +711,35 @@ HTMLTableElement::DeleteCaption() return NS_OK; } +already_AddRefed +HTMLTableElement::CreateTBody() +{ + nsCOMPtr nodeInfo = + OwnerDoc()->NodeInfoManager()->GetNodeInfo(nsGkAtoms::tbody, nullptr, + kNameSpaceID_XHTML, + nsIDOMNode::ELEMENT_NODE); + MOZ_ASSERT(nodeInfo); + + nsCOMPtr 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 HTMLTableElement::InsertRow(int32_t aIndex, ErrorResult& aError) { diff --git a/content/html/content/src/HTMLTableElement.h b/content/html/content/src/HTMLTableElement.h index e81891549348..0ec90d127de4 100644 --- a/content/html/content/src/HTMLTableElement.h +++ b/content/html/content/src/HTMLTableElement.h @@ -93,6 +93,9 @@ public: already_AddRefed CreateTFoot(); nsIHTMLCollection* TBodies(); + + already_AddRefed CreateTBody(); + nsIHTMLCollection* Rows(); already_AddRefed InsertRow(int32_t aIndex, diff --git a/dom/imptests/failures/html/html/semantics/tabular-data/the-table-element/Makefile.in b/dom/imptests/failures/html/html/semantics/tabular-data/the-table-element/Makefile.in index 8782fdb0fbd2..4ea8cb30c748 100644 --- a/dom/imptests/failures/html/html/semantics/tabular-data/the-table-element/Makefile.in +++ b/dom/imptests/failures/html/html/semantics/tabular-data/the-table-element/Makefile.in @@ -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) diff --git a/dom/imptests/failures/html/html/semantics/tabular-data/the-table-element/test_createTBody.html.json b/dom/imptests/failures/html/html/semantics/tabular-data/the-table-element/test_createTBody.html.json deleted file mode 100644 index 9460313273b1..000000000000 --- a/dom/imptests/failures/html/html/semantics/tabular-data/the-table-element/test_createTBody.html.json +++ /dev/null @@ -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 -} diff --git a/dom/webidl/HTMLTableElement.webidl b/dom/webidl/HTMLTableElement.webidl index 7a6e357ce389..5a7464468ce1 100644 --- a/dom/webidl/HTMLTableElement.webidl +++ b/dom/webidl/HTMLTableElement.webidl @@ -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);