Bug 1393806 part 2. Remove the XPCOM version of Document.adoptNode/importNode. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 13 Sep 2017 13:34:55 -0400
changeset 430296 25ba920b0c5ae53d58961601114d0c60b914d377
parent 430295 3105c934288537f39fc0a29bfc941d21bc1c3e8c
child 430297 1ca7ea3ba0fe32afd748eac1f73dfec54f4d80ae
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1393806
milestone57.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 1393806 part 2. Remove the XPCOM version of Document.adoptNode/importNode. r=peterv These don't play nice with ErrorResult error propagation, and don't really have a reason to exist anyway. MozReview-Commit-ID: DlEs19LA4dT
dom/base/nsDocument.cpp
dom/base/nsINode.cpp
dom/interfaces/core/nsIDOMDocument.idl
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -6825,41 +6825,16 @@ nsDocument::GetCharacterSet(nsAString& a
 void
 nsIDocument::GetCharacterSet(nsAString& aCharacterSet) const
 {
   nsAutoCString charset;
   GetDocumentCharacterSet()->Name(charset);
   CopyASCIItoUTF16(charset, aCharacterSet);
 }
 
-NS_IMETHODIMP
-nsDocument::ImportNode(nsIDOMNode* aImportedNode,
-                       bool aDeep,
-                       uint8_t aArgc,
-                       nsIDOMNode** aResult)
-{
-  if (aArgc == 0) {
-    aDeep = true;
-  }
-
-  *aResult = nullptr;
-
-  nsCOMPtr<nsINode> imported = do_QueryInterface(aImportedNode);
-  NS_ENSURE_TRUE(imported, NS_ERROR_UNEXPECTED);
-
-  ErrorResult rv;
-  nsCOMPtr<nsINode> result = nsIDocument::ImportNode(*imported, aDeep, rv);
-  if (rv.Failed()) {
-    return rv.StealNSResult();
-  }
-
-  NS_ADDREF(*aResult = result->AsDOMNode());
-  return NS_OK;
-}
-
 already_AddRefed<nsINode>
 nsIDocument::ImportNode(nsINode& aNode, bool aDeep, ErrorResult& rv) const
 {
   nsINode* imported = &aNode;
 
   switch (imported->NodeType()) {
     case nsIDOMNode::DOCUMENT_NODE:
     {
@@ -7834,34 +7809,16 @@ nsDOMAttributeMap::BlastSubtreeToPieces(
 
   uint32_t count = aNode->GetChildCount();
   for (uint32_t i = 0; i < count; ++i) {
     BlastSubtreeToPieces(aNode->GetFirstChild());
     aNode->RemoveChildAt(0, false);
   }
 }
 
-NS_IMETHODIMP
-nsDocument::AdoptNode(nsIDOMNode *aAdoptedNode, nsIDOMNode **aResult)
-{
-  *aResult = nullptr;
-
-  nsCOMPtr<nsINode> adoptedNode = do_QueryInterface(aAdoptedNode);
-  NS_ENSURE_TRUE(adoptedNode, NS_ERROR_UNEXPECTED);
-
-  ErrorResult rv;
-  nsINode* result = nsIDocument::AdoptNode(*adoptedNode, rv);
-  if (rv.Failed()) {
-    return rv.StealNSResult();
-  }
-
-  NS_ADDREF(*aResult = result->AsDOMNode());
-  return NS_OK;
-}
-
 nsINode*
 nsIDocument::AdoptNode(nsINode& aAdoptedNode, ErrorResult& rv)
 {
   nsINode* adoptedNode = &aAdoptedNode;
 
   // Scope firing mutation events so that we don't carry any state that
   // might be stale
   {
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -1516,30 +1516,26 @@ nsINode::Unlink(nsINode* tmp)
 static nsresult
 AdoptNodeIntoOwnerDoc(nsINode *aParent, nsINode *aNode)
 {
   NS_ASSERTION(!aNode->GetParentNode(),
                "Should have removed from parent already");
 
   nsIDocument *doc = aParent->OwnerDoc();
 
-  nsresult rv;
-  nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(doc, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsCOMPtr<nsIDOMNode> adoptedNode;
-  rv = domDoc->AdoptNode(node, getter_AddRefs(adoptedNode));
-  NS_ENSURE_SUCCESS(rv, rv);
+  ErrorResult rv;
+  nsINode* adoptedNode = doc->AdoptNode(*aNode, rv);
+  rv.WouldReportJSException();
+  if (NS_WARN_IF(rv.Failed())) {
+    return rv.StealNSResult();
+  }
 
   NS_ASSERTION(aParent->OwnerDoc() == doc,
                "ownerDoc chainged while adopting");
-  NS_ASSERTION(adoptedNode == node, "Uh, adopt node changed nodes?");
+  NS_ASSERTION(adoptedNode == aNode, "Uh, adopt node changed nodes?");
   NS_ASSERTION(aParent->OwnerDoc() == aNode->OwnerDoc(),
                "ownerDocument changed again after adopting!");
 
   return NS_OK;
 }
 
 static nsresult
 CheckForOutdatedParent(nsINode* aParent, nsINode* aNode)
--- a/dom/interfaces/core/nsIDOMDocument.idl
+++ b/dom/interfaces/core/nsIDOMDocument.idl
@@ -48,20 +48,16 @@ interface nsIDOMDocument : nsIDOMNode
   nsIDOMProcessingInstruction   createProcessingInstruction(in DOMString target, 
                                                             in DOMString data)
                                   raises(DOMException);
   nsIDOMAttr                    createAttribute(in DOMString name)
                                   raises(DOMException);
   nsIDOMNodeList                getElementsByTagName(in DOMString tagname);
 
   // Introduced in DOM Level 2:
-  [optional_argc] nsIDOMNode    importNode(in nsIDOMNode importedNode,
-                                           [optional] in boolean deep)
-                                  raises(DOMException);
-  // Introduced in DOM Level 2:
   nsIDOMElement                 createElementNS(in DOMString namespaceURI,
                                                 [Null(Stringify)] in DOMString qualifiedName)
                                   raises(DOMException);
   // Introduced in DOM Level 2:
   nsIDOMAttr                    createAttributeNS(in DOMString namespaceURI,
                                                   in DOMString qualifiedName)
                                   raises(DOMException);
   // Introduced in DOM Level 2:
@@ -70,19 +66,16 @@ interface nsIDOMDocument : nsIDOMNode
   // Introduced in DOM Level 2:
   nsIDOMElement                 getElementById(in DOMString elementId);
   // Introduced in DOM Level 3:
   readonly attribute DOMString       inputEncoding;
   // Introduced in DOM Level 3:
   readonly attribute DOMString       documentURI;
   // Alias introduced for all documents in recent DOM standards
   readonly attribute DOMString       URL;
-  // Introduced in DOM Level 3:
-  nsIDOMNode         adoptNode(in nsIDOMNode source)
-                                        raises(DOMException);
 
   /**
    * Create a range
    *
    * @see http://html5.org/specs/dom-range.html#dom-document-createrange
    */
   nsIDOMRange              createRange();