Ensure expected DOM tree operations when calling insertBefore.

This commit is contained in:
Olli Pettay
2016-11-16 23:37:41 +01:00
committed by roytam1
parent fededbf905
commit 5e9bcb348a
12 changed files with 33 additions and 17 deletions
+5 -3
View File
@@ -379,7 +379,8 @@ HTMLTableElement::CreateTHead()
}
ErrorResult rv;
nsINode::InsertBefore(*head, nsINode::GetFirstChild(), rv);
nsCOMPtr<nsINode> refNode = nsINode::GetFirstChild();
nsINode::InsertBefore(*head, refNode, rv);
}
return head.forget();
}
@@ -470,7 +471,7 @@ HTMLTableElement::CreateTBody()
NS_NewHTMLTableSectionElement(nodeInfo.forget());
MOZ_ASSERT(newBody);
nsIContent* referenceNode = nullptr;
nsCOMPtr<nsIContent> referenceNode = nullptr;
for (nsIContent* child = nsINode::GetLastChild();
child;
child = child->GetPreviousSibling()) {
@@ -582,7 +583,8 @@ HTMLTableElement::InsertRow(int32_t aIndex, ErrorResult& aError)
HTMLTableSectionElement* section =
static_cast<HTMLTableSectionElement*>(rowGroup.get());
nsIHTMLCollection* rows = section->Rows();
rowGroup->InsertBefore(*newRow, rows->Item(0), aError);
nsCOMPtr<nsINode> refNode = rows->Item(0);
rowGroup->InsertBefore(*newRow, refNode, aError);
}
}
}