Bug 1434515 - Port bug 1434318: Replace various uses of IDOMDocument. r=bz
authorJorg K <jorgk@jorgk.com>
Thu, 01 Feb 2018 00:26:30 +0100
changeset 31016 50b6d12405049bee66fb6dbde52d62ee783ec8fb
parent 31015 850b32c6652c3b669154a068534dd1537e52efaa
child 31017 173984b4516a0d3b16870b6dd321d8c0a2f4ee1f
push id383
push userclokep@gmail.com
push dateMon, 07 May 2018 21:52:48 +0000
reviewersbz
bugs1434515, 1434318
Bug 1434515 - Port bug 1434318: Replace various uses of IDOMDocument. r=bz
chat/components/public/prplIConversation.idl
mailnews/base/src/nsMsgMailSession.cpp
mailnews/compose/src/moz.build
mailnews/compose/src/nsMsgCompose.cpp
mailnews/compose/src/nsMsgComposeContentHandler.cpp
mailnews/compose/src/nsMsgComposeService.cpp
mailnews/compose/src/nsMsgSend.cpp
mailnews/import/winlivemail/nsWMUtils.cpp
--- a/chat/components/public/prplIConversation.idl
+++ b/chat/components/public/prplIConversation.idl
@@ -7,17 +7,16 @@
 #include "nsISimpleEnumerator.idl"
 #include "nsIObserver.idl"
 
 interface prplIAccountBuddy;
 interface imIAccount;
 interface imIOutgoingMessage;
 interface imIMessage;
 interface nsIURI;
-interface nsIDOMDocument;
 interface prplIChatRoomFieldValues;
 
 /*
  * This is the XPCOM purple conversation component, a proxy for PurpleConversation.
  */
 
 [scriptable, uuid(f71c58d6-2c47-4468-934b-b1c61462c01a)]
 interface prplIConversation: nsISupports {
--- a/mailnews/base/src/nsMsgMailSession.cpp
+++ b/mailnews/base/src/nsMsgMailSession.cpp
@@ -10,17 +10,16 @@
 #include "nsMsgUtils.h"
 #include "nsIMsgAccountManager.h"
 #include "nsIChromeRegistry.h"
 #include "nsIDirectoryService.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDocShell.h"
 #include "nsIDocument.h"
-#include "nsIDOMDocument.h"
 #include "nsIDOMElement.h"
 #include "nsIObserverService.h"
 #include "nsIAppStartup.h"
 #include "nsToolkitCompsCID.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIAppShellService.h"
 #include "nsAppShellCID.h"
 #include "nsIWindowMediator.h"
--- a/mailnews/compose/src/moz.build
+++ b/mailnews/compose/src/moz.build
@@ -46,10 +46,14 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'coco
         'nsMsgAppleDouble.h',
     ]
 
 EXTRA_COMPONENTS += [
     'nsSMTPProtocolHandler.js',
     'nsSMTPProtocolHandler.manifest',
 ]
 
+LOCAL_INCLUDES += [
+  '/%s/dom/base' % CONFIG['mozreltopsrcdir'],
+]
+
 FINAL_LIBRARY = 'mail'
 
--- a/mailnews/compose/src/nsMsgCompose.cpp
+++ b/mailnews/compose/src/nsMsgCompose.cpp
@@ -77,16 +77,17 @@
 #include "mozilla/dom/HTMLLinkElement.h"
 #include "nsStreamConverter.h"
 #include "nsISelection.h"
 #include "nsJSEnvironment.h"
 #include "nsIObserverService.h"
 #include "nsIProtocolHandler.h"
 #include "nsContentUtils.h"
 #include "nsIFileURL.h"
+#include "nsTextNode.h" // from dom/base
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::mailnews;
 
 static nsresult GetReplyHeaderInfo(int32_t* reply_header_type,
                                    nsString& reply_header_authorwrote,
                                    nsString& reply_header_ondateauthorwrote,
@@ -543,25 +544,23 @@ nsMsgCompose::InsertDivWrappedTextAtSele
   int32_t end = aText.Length();
 
   for (;;)
   {
     int32_t delimiter = aText.FindChar('\n', start);
     if (delimiter == kNotFound)
       delimiter = end;
 
-    nsCOMPtr<nsIDOMText> textNode;
-    rv = doc->CreateTextNode(Substring(aText, start, delimiter - start), getter_AddRefs(textNode));
-    NS_ENSURE_SUCCESS_VOID(rv);
-
-    nsCOMPtr<nsIDOMNode> newTextNode = do_QueryInterface(textNode);
+    nsCOMPtr<nsIDocument> doc2 = do_QueryInterface(doc);
+    RefPtr<nsTextNode> textNode =
+      doc2->CreateTextNode(Substring(aText, start, delimiter - start));
+
     nsCOMPtr<nsINode> divElem2 = do_QueryInterface(divElem);
-    nsCOMPtr<nsINode> newTextNode2 = do_QueryInterface(newTextNode);
     IgnoredErrorResult rv2;
-    divElem2->AppendChild(*newTextNode2, rv2);
+    divElem2->AppendChild(*textNode, rv2);
     if (rv2.Failed()) {
       return;
     }
 
     // Now create and insert a BR
     nsCOMPtr<nsIDOMElement> brElem;
     rv = htmlEditor->CreateElementWithDefaults(NS_LITERAL_STRING("br"),
                                                getter_AddRefs(brElem));
--- a/mailnews/compose/src/nsMsgComposeContentHandler.cpp
+++ b/mailnews/compose/src/nsMsgComposeContentHandler.cpp
@@ -10,17 +10,16 @@
 #include "nsIChannel.h"
 #include "nsIURI.h"
 #include "plstr.h"
 #include "nsServiceManagerUtils.h"
 #include "nsCOMPtr.h"
 #include "nsPIDOMWindow.h"
 #include "mozIDOMWindow.h"
 #include "nsIDocument.h"
-#include "nsIDOMDocument.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIMsgMailNewsUrl.h"
 #include "nsNetUtil.h"
 #include "nsIMsgFolder.h"
 #include "nsIMsgIncomingServer.h"
 #include "nsIMsgAccountManager.h"
 
--- a/mailnews/compose/src/nsMsgComposeService.cpp
+++ b/mailnews/compose/src/nsMsgComposeService.cpp
@@ -17,16 +17,17 @@
 #include "nsISupportsPrimitives.h"
 #include "nsIWindowWatcher.h"
 #include "mozIDOMWindow.h"
 #include "nsIContentViewer.h"
 #include "nsIMsgWindow.h"
 #include "nsIDocShell.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMDocument.h"
+#include "nsIDocument.h"
 #include "nsIDOMElement.h"
 #include "nsIXULWindow.h"
 #include "nsIWindowMediator.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIBaseWindow.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
@@ -321,19 +322,17 @@ nsMsgComposeService::GetOrigWindowSelect
         return NS_ERROR_ABORT;
     }
   }
 
   nsCOMPtr<nsIContentViewer> contentViewer;
   rv = docShell->GetContentViewer(getter_AddRefs(contentViewer));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsCOMPtr<nsIDOMDocument> domDocument;
-  rv = contentViewer->GetDOMDocument(getter_AddRefs(domDocument));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIDOMDocument> domDocument = do_QueryInterface(contentViewer->GetDocument());
 
   nsCOMPtr<nsIDocumentEncoder> docEncoder(do_CreateInstance(NS_HTMLCOPY_ENCODER_CONTRACTID, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = docEncoder->Init(domDocument, NS_LITERAL_STRING("text/html"), 0);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = docEncoder->SetSelection(sel);
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -25,17 +25,16 @@
 #include "nsNetUtil.h"
 #include "nsIFileURL.h"
 #include "nsMsgCopy.h"
 #include "nsUnicharUtils.h"
 #include "nsMsgPrompts.h"
 #include "nsCExternalHandlerService.h"
 #include "nsIMIMEService.h"
 #include "nsIDocument.h"
-#include "nsIDOMDocument.h"
 #include "nsMsgCompCID.h"
 #include "nsIAbAddressCollector.h"
 #include "nsAbBaseCID.h"
 #include "nsCOMPtr.h"
 #include "mozITXTToHTMLConv.h"
 #include "nsIMsgStatusFeedback.h"
 #include "nsIMsgWindow.h"
 #include "nsTextFormatter.h"
--- a/mailnews/import/winlivemail/nsWMUtils.cpp
+++ b/mailnews/import/winlivemail/nsWMUtils.cpp
@@ -4,17 +4,19 @@
 
 #include "nsCOMArray.h"
 #include "nsCOMPtr.h"
 #include "nsComponentManagerUtils.h"
 #include "nsNetCID.h"
 #include "nsString.h"
 #include "nsWMUtils.h"
 #include "nsIDOMDocument.h"
-#include "nsIDOMNodeList.h"
+#include "nsIDocument.h"
+#include "nsINodeList.h"
+#include "nsContentList.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"
@@ -149,21 +151,18 @@ nsWMUtils::MakeXMLdoc(nsIDOMDocument **a
 
 nsresult
 nsWMUtils::GetValueForTag(nsIDOMDocument *aXmlDoc,
                           const char *aTagName,
                           nsAString &aValue)
 {
   nsAutoString tagName;
   tagName.AssignASCII(aTagName);
-  nsCOMPtr<nsIDOMNodeList> list;
-  if (NS_FAILED(aXmlDoc->GetElementsByTagName(tagName, getter_AddRefs(list))))
+  nsCOMPtr<nsIDocument> domDocument = do_QueryInterface(aXmlDoc);
+  nsCOMPtr<nsINodeList> list = domDocument->GetElementsByTagName(tagName);
+  nsCOMPtr<nsINode> node = list->Item(0);
+  if (!node)
     return NS_ERROR_FAILURE;
-  nsCOMPtr<nsIDOMNode> domNode;
-  list->Item(0, getter_AddRefs(domNode));
-  if (!domNode)
-    return NS_ERROR_FAILURE;
-  nsCOMPtr<nsINode> node = do_QueryInterface(domNode);
   mozilla::ErrorResult rv2;
   node->GetTextContent(aValue, rv2);
   return rv2.StealNSResult();
 }