Bug 1335356 - Part 1: Insert caption and thead in the right order. r=smaug

This commit is contained in:
Jessica Jong 2017-02-20 22:43:00 -05:00
parent a4109eb8fa
commit 3c26f56f0b
5 changed files with 31 additions and 26 deletions

View File

@ -411,8 +411,19 @@ HTMLTableElement::CreateTHead()
return nullptr;
}
ErrorResult rv;
nsCOMPtr<nsINode> refNode = nsINode::GetFirstChild();
nsCOMPtr<nsIContent> refNode = nullptr;
for (refNode = nsINode::GetFirstChild();
refNode;
refNode = refNode->GetNextSibling()) {
if (refNode->IsHTMLElement() &&
!refNode->IsHTMLElement(nsGkAtoms::caption) &&
!refNode->IsHTMLElement(nsGkAtoms::colgroup)) {
break;
}
}
IgnoredErrorResult rv;
nsINode::InsertBefore(*head, refNode, rv);
}
return head.forget();
@ -475,7 +486,9 @@ HTMLTableElement::CreateCaption()
return nullptr;
}
AppendChildTo(caption, true);
IgnoredErrorResult rv;
nsCOMPtr<nsINode> firsChild = nsINode::GetFirstChild();
nsINode::InsertBefore(*caption, firsChild, rv);
}
return caption.forget();
}
@ -514,7 +527,7 @@ HTMLTableElement::CreateTBody()
}
}
ErrorResult rv;
IgnoredErrorResult rv;
nsINode::InsertBefore(*newBody, referenceNode, rv);
return newBody.forget();

View File

@ -36,7 +36,8 @@ public:
{
DeleteCaption();
if (aCaption) {
nsINode::AppendChild(*aCaption, aError);
nsCOMPtr<nsINode> firstChild = nsINode::GetFirstChild();
nsINode::InsertBefore(*aCaption, firstChild, aError);
}
}
@ -59,7 +60,18 @@ public:
DeleteTHead();
if (aTHead) {
nsCOMPtr<nsINode> refNode = nsINode::GetFirstChild();
nsCOMPtr<nsIContent> refNode = nullptr;
for (refNode = nsINode::GetFirstChild();
refNode;
refNode = refNode->GetNextSibling()) {
if (refNode->IsHTMLElement() &&
!refNode->IsHTMLElement(nsGkAtoms::caption) &&
!refNode->IsHTMLElement(nsGkAtoms::colgroup)) {
break;
}
}
nsINode::InsertBefore(*aTHead, refNode, aError);
}
}

View File

@ -1,5 +0,0 @@
[caption_001.html]
type: testharness
[setting caption on a table]
expected: FAIL

View File

@ -1,14 +1,4 @@
[caption-methods.html]
type: testharness
[createCaption method creates a new caption and inserts it as the first node of the table element]
expected: FAIL
[createCaption method creates new caption if existing caption is not in html namespace]
expected: FAIL
[createCaption will not copy table's prefix]
expected: FAIL
[Assigning a caption to table.caption]
expected: FAIL

View File

@ -1,5 +0,0 @@
[tHead.html]
type: testharness
[tHead tests]
expected: FAIL