Bug 1318479 part 4. Remove use of nsIDOMNode::AppendChild from NS_NewDOMDocument. r=ehsan
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 18 Nov 2016 16:38:29 -0500
changeset 368488 333df199df73279ecb5b1243c9f6c4350a2f5250
parent 368487 8b6abb058e6aefd51cb0629fc4a9e896684f10c6
child 368489 53efc7ed9314bdbed46e718185394a4a2e4d9e25
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1318479
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1318479 part 4. Remove use of nsIDOMNode::AppendChild from NS_NewDOMDocument. r=ehsan
dom/xml/XMLDocument.cpp
--- a/dom/xml/XMLDocument.cpp
+++ b/dom/xml/XMLDocument.cpp
@@ -149,31 +149,37 @@ NS_NewDOMDocument(nsIDOMDocument** aInst
     d->SetScopeObject(aEventObject);
   }
 
   // XMLDocuments and documents "created in memory" get to be UTF-8 by default,
   // unlike the legacy HTML mess
   doc->SetDocumentCharacterSet(NS_LITERAL_CSTRING("UTF-8"));
   
   if (aDoctype) {
-    nsCOMPtr<nsIDOMNode> tmpNode;
-    rv = doc->AppendChild(aDoctype, getter_AddRefs(tmpNode));
-    NS_ENSURE_SUCCESS(rv, rv);
+    nsCOMPtr<nsINode> doctypeAsNode = do_QueryInterface(aDoctype);
+    ErrorResult result;
+    d->AppendChild(*doctypeAsNode, result);
+    if (NS_WARN_IF(result.Failed())) {
+      return result.StealNSResult();
+    }
   }
   
   if (!aQualifiedName.IsEmpty()) {
-    nsCOMPtr<nsIDOMElement> root;
-    rv = doc->CreateElementNS(aNamespaceURI, aQualifiedName,
-                              getter_AddRefs(root));
-    NS_ENSURE_SUCCESS(rv, rv);
+    ErrorResult result;
+    nsCOMPtr<Element> root =
+      doc->CreateElementNS(aNamespaceURI, aQualifiedName,
+                           ElementCreationOptions(), result);
+    if (NS_WARN_IF(result.Failed())) {
+      return result.StealNSResult();
+    }
 
-    nsCOMPtr<nsIDOMNode> tmpNode;
-
-    rv = doc->AppendChild(root, getter_AddRefs(tmpNode));
-    NS_ENSURE_SUCCESS(rv, rv);
+    d->AppendChild(*root, result);
+    if (NS_WARN_IF(result.Failed())) {
+      return result.StealNSResult();
+    }
   }
 
   *aInstancePtrResult = doc;
   NS_ADDREF(*aInstancePtrResult);
 
   return NS_OK;
 }