Bug 1432603 - replace some nsIDOMNode methods with nsINode methods (part 1). r=bz
authorJorg K <jorgk@jorgk.com>
Thu, 25 Jan 2018 00:11:31 +0100
changeset 30965 49cc2b43c34ff0e1354cf243da5652d4d9ba16ad
parent 30964 2b56d89a8792fc1af6ae66be5f38cd9d26ecb7e1
child 30966 cde38eb25eba56a89cbd4afd4d757db567065f92
push id383
push userclokep@gmail.com
push dateMon, 07 May 2018 21:52:48 +0000
reviewersbz
bugs1432603
Bug 1432603 - replace some nsIDOMNode methods with nsINode methods (part 1). r=bz
mailnews/compose/src/nsMsgSend.cpp
mailnews/import/winlivemail/nsWMUtils.cpp
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -1320,46 +1320,33 @@ nsMsgComposeAndSend::GetEmbeddedObjectIn
       return NS_OK;
 
     nsAutoCString turlC;
     CopyUTF16toUTF8(tUrl, turlC);
     if (NS_FAILED(nsMsgNewURL(getter_AddRefs(attachment->m_url), turlC)))
     {
       // Well, the first time failed...which means we probably didn't get
       // the full path name...
-      //
-      nsIDOMDocument    *ownerDocument = nullptr;
-      node->GetOwnerDocument(&ownerDocument);
-      if (ownerDocument)
-      {
-        nsIDocument     *doc = nullptr;
-        if (NS_FAILED(ownerDocument->QueryInterface(NS_GET_IID(nsIDocument),(void**)&doc)) || !doc)
-          return NS_ERROR_OUT_OF_MEMORY;
-
-        nsAutoCString spec;
-        nsIURI *uri = doc->GetDocumentURI();
-
-        if (!uri)
-          return NS_ERROR_OUT_OF_MEMORY;
-
-        rv = uri->GetSpec(spec);
-        NS_ENSURE_SUCCESS(rv, rv);
-
-        // Ok, now get the path to the root doc and tack on the name we
-        // got from the GetSrc() call....
-        NS_ConvertUTF8toUTF16 workURL(spec);
-
-        int32_t loc = workURL.RFindChar('/');
-        if (loc >= 0)
-          workURL.SetLength(loc+1);
-        workURL.Append(tUrl);
-        NS_ConvertUTF16toUTF8 workurlC(workURL);
-        if (NS_FAILED(nsMsgNewURL(getter_AddRefs(attachment->m_url), workurlC)))
-          return NS_OK; // Continue and send it without this image.
-      }
+      nsCOMPtr<nsINode> node2 = do_QueryInterface(node);
+
+      nsAutoCString spec;
+      rv = node2->OwnerDoc()->GetDocumentURI()->GetSpec(spec);
+      NS_ENSURE_SUCCESS(rv, rv);
+
+      // Ok, now get the path to the root doc and tack on the name we
+      // got from the GetSrc() call....
+      NS_ConvertUTF8toUTF16 workURL(spec);
+
+      int32_t loc = workURL.RFindChar('/');
+      if (loc >= 0)
+        workURL.SetLength(loc+1);
+      workURL.Append(tUrl);
+      NS_ConvertUTF16toUTF8 workurlC(workURL);
+      if (NS_FAILED(nsMsgNewURL(getter_AddRefs(attachment->m_url), workurlC)))
+        return NS_OK; // Continue and send it without this image.
     }
     isImage = true;
 
     image->GetName(tName);
 
     LossyCopyUTF16toASCII(tName, attachment->m_realName);
     image->GetLongDesc(tDesc);
     attachment->m_description = NS_LossyConvertUTF16toASCII(tDesc); // XXX i18n
@@ -1698,17 +1685,18 @@ nsMsgComposeAndSend::ProcessMultipartRel
     if (node)
     {
       bool acceptObject = false;
       rv = GetEmbeddedObjectInfo(node, attachment, &acceptObject);
       NS_ENSURE_SUCCESS(rv, NS_ERROR_MIME_MPART_ATTACHMENT_ERROR);
       if (!acceptObject)
         continue;
       nsString nodeValue;
-      node->GetNodeValue(nodeValue);
+      nsCOMPtr<nsINode> node2 = do_QueryInterface(node);
+      node2->GetNodeValue(nodeValue);
       LossyCopyUTF16toASCII(nodeValue, m_attachments[i]->m_contentId);
     }
     else
     {
       nsCOMPtr<nsIMsgEmbeddedImageData> imageData = do_QueryElementAt(mEmbeddedObjectList, locCount, &rv);
       if (!imageData)
         return NS_ERROR_MIME_MPART_ATTACHMENT_ERROR;
       imageData->GetUri(getter_AddRefs(attachment->m_url));
--- a/mailnews/import/winlivemail/nsWMUtils.cpp
+++ b/mailnews/import/winlivemail/nsWMUtils.cpp
@@ -6,21 +6,23 @@
 #include "nsCOMPtr.h"
 #include "nsComponentManagerUtils.h"
 #include "nsNetCID.h"
 #include "nsString.h"
 #include "nsWMUtils.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMParser.h"
+#include "nsINode.h"
 #include "nsIFileStreams.h"
 #include "nsIFile.h"
 #include "nsISimpleEnumerator.h"
 #include "ImportDebug.h"
 #include "prio.h"
+#include "mozilla/ErrorResult.h"
 
 nsresult
 nsWMUtils::FindWMKey(nsIWindowsRegKey **aKey)
 {
   nsresult rv;
   nsCOMPtr<nsIWindowsRegKey> key =
     do_CreateInstance("@mozilla.org/windows-registry-key;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -154,11 +156,14 @@ nsWMUtils::GetValueForTag(nsIDOMDocument
   tagName.AssignASCII(aTagName);
   nsCOMPtr<nsIDOMNodeList> list;
   if (NS_FAILED(aXmlDoc->GetElementsByTagName(tagName, getter_AddRefs(list))))
     return NS_ERROR_FAILURE;
   nsCOMPtr<nsIDOMNode> domNode;
   list->Item(0, getter_AddRefs(domNode));
   if (!domNode)
     return NS_ERROR_FAILURE;
-  return domNode->GetTextContent(aValue);
+  nsCOMPtr<nsINode> node = do_QueryInterface(domNode);
+  mozilla::ErrorResult rv2;
+  node->GetTextContent(aValue, rv2);
+  return rv2.StealNSResult();
 }