Bug 1272893 - Remove nsISupportsArray from GetEmbeddedObjects() in editor. r=masayuki
authoraceman <acelists@atlas.sk>
Thu, 15 Sep 2016 04:33:00 +0200
changeset 355393 8c5a17252bb320c82ef5665b1640c43e7a6c8653
parent 355392 b6019891af3afaa0fa188657dd7cef4e43a784be
child 355394 2840a2d57a59c054bfa9694e7c8c9bfddc71dc28
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1272893
milestone51.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 1272893 - Remove nsISupportsArray from GetEmbeddedObjects() in editor. r=masayuki
editor/libeditor/HTMLEditor.cpp
editor/libeditor/TextEditor.cpp
editor/nsIEditorMailSupport.idl
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -38,16 +38,17 @@
 #include "nsIInlineSpellChecker.h"
 
 #include "mozilla/css/Loader.h"
 #include "nsIDOMStyleSheet.h"
 
 #include "nsIContent.h"
 #include "nsIContentIterator.h"
 #include "nsISupportsArray.h"
+#include "nsIMutableArray.h"
 #include "nsContentUtils.h"
 #include "nsIDocumentEncoder.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "nsFocusManager.h"
 #include "nsPIDOMWindow.h"
 
 // netwerk
@@ -3060,23 +3061,23 @@ HTMLEditor::GetURLForStyleSheet(StyleShe
   if (foundIndex == -1)
     return;
 
   // Found it in the list!
   aURL = mStyleSheetURLs[foundIndex];
 }
 
 NS_IMETHODIMP
-HTMLEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
+HTMLEditor::GetEmbeddedObjects(nsIArray** aNodeList)
 {
   NS_ENSURE_TRUE(aNodeList, NS_ERROR_NULL_POINTER);
 
-  nsresult rv = NS_NewISupportsArray(aNodeList);
+  nsresult rv;
+  nsCOMPtr<nsIMutableArray> nodes = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
-  NS_ENSURE_TRUE(*aNodeList, NS_ERROR_NULL_POINTER);
 
   nsCOMPtr<nsIContentIterator> iter =
       do_CreateInstance("@mozilla.org/content/post-content-iterator;1", &rv);
   NS_ENSURE_TRUE(iter, NS_ERROR_NULL_POINTER);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIDocument> doc = GetDocument();
   NS_ENSURE_TRUE(doc, NS_ERROR_UNEXPECTED);
@@ -3091,22 +3092,23 @@ HTMLEditor::GetEmbeddedObjects(nsISuppor
 
       // See if it's an image or an embed and also include all links.
       // Let mail decide which link to send or not
       if (element->IsAnyOfHTMLElements(nsGkAtoms::img, nsGkAtoms::embed,
                                        nsGkAtoms::a) ||
           (element->IsHTMLElement(nsGkAtoms::body) &&
            element->HasAttr(kNameSpaceID_None, nsGkAtoms::background))) {
         nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(node);
-        (*aNodeList)->AppendElement(domNode);
-      }
-    }
-    iter->Next();
-  }
-
+        nodes->AppendElement(domNode, false);
+       }
+     }
+     iter->Next();
+   }
+
+  nodes.forget(aNodeList);
   return rv;
 }
 
 NS_IMETHODIMP
 HTMLEditor::DeleteSelectionImpl(EDirection aAction,
                                 EStripWrappers aStripWrappers)
 {
   MOZ_ASSERT(aStripWrappers == eStrip || aStripWrappers == eNoStrip);
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -1530,19 +1530,23 @@ TextEditor::StripCites()
     rv = SelectAll();
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return InsertText(stripped);
 }
 
 NS_IMETHODIMP
-TextEditor::GetEmbeddedObjects(nsISupportsArray** aNodeList)
-{
-  *aNodeList = 0;
+TextEditor::GetEmbeddedObjects(nsIArray** aNodeList)
+ {
+  if (NS_WARN_IF(!aNodeList)) {
+    return NS_ERROR_INVALID_ARG;
+  }
+
+  *aNodeList = nullptr;
   return NS_OK;
 }
 
 /**
  * All editor operations which alter the doc should be prefaced
  * with a call to StartOperation, naming the action and direction.
  */
 NS_IMETHODIMP
--- a/editor/nsIEditorMailSupport.idl
+++ b/editor/nsIEditorMailSupport.idl
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
-interface nsISupportsArray;
+interface nsIArray;
 interface nsIDOMNode;
 
 [scriptable, uuid(fdf23301-4a94-11d3-9ce4-9960496c41bc)]
 
 interface nsIEditorMailSupport : nsISupports
 {
   /** Paste the text in the OS clipboard at the cursor position,
     * as a quotation (whose representation is dependant on the editor type),
@@ -71,11 +71,11 @@ interface nsIEditorMailSupport : nsISupp
    * Strip any citations in the selected part of the document.
    */
   void stripCites();
 
 
   /**
    * Get a list of IMG and OBJECT tags in the current document.
    */
-  nsISupportsArray getEmbeddedObjects();
+  nsIArray getEmbeddedObjects();
 };