Bug 1464784 - Hold a strong ref to the document in callers of ConvertNodesOrStringsIntoNode. r=smaug, a=abillings
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 31 May 2018 12:43:01 -0400
changeset 357188 ad5a53a1d2b19b2962044cab30825718f3b2229e
parent 357187 28f4fc0a5141cf8bfc5b3d4ee3669b958647ec85
child 357189 14a626e0487dff5e4c6979743c86682b5d325945
push id7716
push userryanvm@gmail.com
push dateSun, 03 Jun 2018 00:33:23 +0000
treeherdermozilla-esr52@ad5a53a1d2b1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, abillings
bugs1464784
milestone52.8.1
Bug 1464784 - Hold a strong ref to the document in callers of ConvertNodesOrStringsIntoNode. r=smaug, a=abillings
dom/base/nsINode.cpp
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -1772,18 +1772,18 @@ nsINode::Before(const Sequence<OwningNod
   nsCOMPtr<nsINode> parent = GetParentNode();
   if (!parent) {
     return;
   }
 
   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;
   }
 
   viablePreviousSibling = viablePreviousSibling ?
     viablePreviousSibling->GetNextSibling() : parent->GetFirstChild();
 
   parent->InsertBefore(*node, viablePreviousSibling, aRv);
@@ -1795,18 +1795,18 @@ nsINode::After(const Sequence<OwningNode
 {
   nsCOMPtr<nsINode> parent = GetParentNode();
   if (!parent) {
     return;
   }
 
   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;
   }
 
   parent->InsertBefore(*node, viableNextSibling, aRv);
 }
 
 void
@@ -1815,18 +1815,18 @@ nsINode::ReplaceWith(const Sequence<Owni
 {
   nsCOMPtr<nsINode> parent = GetParentNode();
   if (!parent) {
     return;
   }
 
   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;
   }
 
   if (parent == GetParentNode()) {
     parent->ReplaceChild(*node, *this, aRv);
   } else {
     parent->InsertBefore(*node, viableNextSibling, aRv);
@@ -1875,32 +1875,32 @@ nsINode::GetLastElementChild() const
 
   return nullptr;
 }
 
 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;
   }
 
   nsCOMPtr<nsINode> refNode = mFirstChild;
   InsertBefore(*node, refNode, aRv);
 }
 
 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;
   }
 
   AppendChild(*node, aRv);
 }
 
 void