Bug 1519554 - Port bug 181137, part 1 and 8: Changes to nsIContentIterator. rs=bustage-fix
authorJorg K <jorgk@jorgk.com>
Sat, 12 Jan 2019 00:37:05 +0100
changeset 34170 37983d049d22566a6fe7e6f00b258d86a4660f05
parent 34169 95215e0170b63d49e9a0d626b62b8eda17acb6cd
child 34171 0fb460d27117da21b5ee2bb36d51ab9c321be263
push id389
push userclokep@gmail.com
push dateMon, 18 Mar 2019 19:01:53 +0000
reviewersbustage-fix
bugs1519554, 181137
Bug 1519554 - Port bug 181137, part 1 and 8: Changes to nsIContentIterator. rs=bustage-fix
mailnews/compose/src/nsMsgCompUtils.cpp
--- a/mailnews/compose/src/nsMsgCompUtils.cpp
+++ b/mailnews/compose/src/nsMsgCompUtils.cpp
@@ -28,17 +28,17 @@
 #include "nsComponentManagerUtils.h"
 #include "nsMemory.h"
 #include "nsCRTGlue.h"
 #include <ctype.h>
 #include "mozilla/dom/Element.h"
 #include "mozilla/mailnews/Services.h"
 #include "mozilla/Services.h"
 #include "mozilla/Unused.h"
-#include "nsIContentIterator.h"
+#include "mozilla/ContentIterator.h"
 #include "mozilla/dom/Document.h"
 #include "nsIMIMEInfo.h"
 #include "nsIMsgHeaderParser.h"
 #include "nsIMutableArray.h"
 #include "nsIRandomGenerator.h"
 #include "nsID.h"
 
 NS_IMPL_ISUPPORTS(nsMsgCompUtils, nsIMsgCompUtils)
@@ -1776,30 +1776,33 @@ void GetSerialiserFlags(const char* char
 already_AddRefed<nsIArray>
 GetEmbeddedObjects(mozilla::dom::Document* aDocument)
 {
   nsCOMPtr<nsIMutableArray> nodes = do_CreateInstance(NS_ARRAY_CONTRACTID);
   if (NS_WARN_IF(!nodes)) {
     return nullptr;
   }
 
-  nsCOMPtr<nsIContentIterator> iter = NS_NewContentIterator();
-  iter->Init(aDocument->GetRootElement());
+  mozilla::PostContentIterator iter;
+  nsresult rv = iter.Init(aDocument->GetRootElement());
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return nullptr;
+  }
 
   // Loop through the content iterator for each content node.
-  while (!iter->IsDone()) {
-    nsINode* node = iter->GetCurrentNode();
+  while (!iter.IsDone()) {
+    nsINode* node = iter.GetCurrentNode();
     if (node->IsElement()) {
       mozilla::dom::Element* element = node->AsElement();
 
       // See if it's an image or also include all links.
       // Let mail decide which link to send or not
       if (element->IsAnyOfHTMLElements(nsGkAtoms::img, nsGkAtoms::a) ||
           (element->IsHTMLElement(nsGkAtoms::body) &&
            element->HasAttr(kNameSpaceID_None, nsGkAtoms::background))) {
         nodes->AppendElement(node);
       }
     }
-    iter->Next();
+    iter.Next();
   }
 
   return nodes.forget();
 }