diff options
Diffstat (limited to 'dom/base/nsINode.cpp')
-rw-r--r-- | dom/base/nsINode.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp index 3a649a61d..09e848710 100644 --- a/dom/base/nsINode.cpp +++ b/dom/base/nsINode.cpp @@ -1777,8 +1777,8 @@ nsINode::Before(const Sequence<OwningNodeOrString>& aNodes, nsCOMPtr<nsINode> viablePreviousSibling = FindViablePreviousSibling(*this, aNodes); - nsCOMPtr<nsINode> node = - ConvertNodesOrStringsIntoNode(aNodes, OwnerDoc(), aRv); + nsCOMPtr<nsIDocument> doc = OwnerDoc(); + nsCOMPtr<nsINode> node = ConvertNodesOrStringsIntoNode(aNodes, doc, aRv); if (aRv.Failed()) { return; } @@ -1800,8 +1800,8 @@ nsINode::After(const Sequence<OwningNodeOrString>& aNodes, nsCOMPtr<nsINode> viableNextSibling = FindViableNextSibling(*this, aNodes); - nsCOMPtr<nsINode> node = - ConvertNodesOrStringsIntoNode(aNodes, OwnerDoc(), aRv); + nsCOMPtr<nsIDocument> doc = OwnerDoc(); + nsCOMPtr<nsINode> node = ConvertNodesOrStringsIntoNode(aNodes, doc, aRv); if (aRv.Failed()) { return; } @@ -1820,8 +1820,8 @@ nsINode::ReplaceWith(const Sequence<OwningNodeOrString>& aNodes, nsCOMPtr<nsINode> viableNextSibling = FindViableNextSibling(*this, aNodes); - nsCOMPtr<nsINode> node = - ConvertNodesOrStringsIntoNode(aNodes, OwnerDoc(), aRv); + nsCOMPtr<nsIDocument> doc = OwnerDoc(); + nsCOMPtr<nsINode> node = ConvertNodesOrStringsIntoNode(aNodes, doc, aRv); if (aRv.Failed()) { return; } @@ -1880,8 +1880,8 @@ void nsINode::Prepend(const Sequence<OwningNodeOrString>& aNodes, ErrorResult& aRv) { - nsCOMPtr<nsINode> node = - ConvertNodesOrStringsIntoNode(aNodes, OwnerDoc(), aRv); + nsCOMPtr<nsIDocument> doc = OwnerDoc(); + nsCOMPtr<nsINode> node = ConvertNodesOrStringsIntoNode(aNodes, doc, aRv); if (aRv.Failed()) { return; } @@ -1894,8 +1894,8 @@ void nsINode::Append(const Sequence<OwningNodeOrString>& aNodes, ErrorResult& aRv) { - nsCOMPtr<nsINode> node = - ConvertNodesOrStringsIntoNode(aNodes, OwnerDoc(), aRv); + nsCOMPtr<nsIDocument> doc = OwnerDoc(); + nsCOMPtr<nsINode> node = ConvertNodesOrStringsIntoNode(aNodes, doc, aRv); if (aRv.Failed()) { return; } @@ -1907,6 +1907,10 @@ void nsINode::doRemoveChildAt(uint32_t aIndex, bool aNotify, nsIContent* aKid, nsAttrAndChildArray& aChildArray) { + // NOTE: This function must not trigger any calls to + // nsIDocument::GetRootElement() calls until *after* it has removed aKid from + // aChildArray. Any calls before then could potentially restore a stale + // value for our cached root element, per note in nsDocument::RemoveChildAt(). NS_PRECONDITION(aKid && aKid->GetParentNode() == this && aKid == GetChildAt(aIndex) && IndexOf(aKid) == (int32_t)aIndex, "Bogus aKid"); |