Bug 1154701 part 4 - Switch nsHTMLEditor::mContentFilters to nsTArray; r=ehsan
☠☠ backed out by 329dd852c06b ☠ ☠
authorAryeh Gregor <ayg@aryeh.name>
Wed, 22 Apr 2015 14:27:17 +0300
changeset 240520 31281738003d8a8a938167706ec68e35543d4a53
parent 240519 5ad34b482c254293f1773dee7fcd967d2564b95c
child 240521 1ab63df2b8eb262ef43b5ce226a6e5287541c1e5
push id28636
push userkwierso@gmail.com
push dateThu, 23 Apr 2015 00:16:12 +0000
treeherdermozilla-central@a5af73b32ac8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1154701
milestone40.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 1154701 part 4 - Switch nsHTMLEditor::mContentFilters to nsTArray; r=ehsan
editor/libeditor/nsHTMLDataTransfer.cpp
editor/libeditor/nsHTMLEditor.h
--- a/editor/libeditor/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/nsHTMLDataTransfer.cpp
@@ -689,36 +689,35 @@ nsHTMLEditor::DoInsertHTMLWithContext(co
         }
       }
     }
   }
 
   return mRules->DidDoAction(selection, &ruleInfo, rv);
 }
 
-nsresult
+NS_IMETHODIMP
 nsHTMLEditor::AddInsertionListener(nsIContentFilter *aListener)
 {
   NS_ENSURE_TRUE(aListener, NS_ERROR_NULL_POINTER);
 
   // don't let a listener be added more than once
-  if (mContentFilters.IndexOfObject(aListener) == -1)
-  {
-    NS_ENSURE_TRUE(mContentFilters.AppendObject(aListener), NS_ERROR_FAILURE);
+  if (!mContentFilters.Contains(aListener)) {
+    mContentFilters.AppendElement(*aListener);
   }
 
   return NS_OK;
 }
 
-nsresult
+NS_IMETHODIMP
 nsHTMLEditor::RemoveInsertionListener(nsIContentFilter *aListener)
 {
   NS_ENSURE_TRUE(aListener, NS_ERROR_FAILURE);
 
-  NS_ENSURE_TRUE(mContentFilters.RemoveObject(aListener), NS_ERROR_FAILURE);
+  mContentFilters.RemoveElement(aListener);
 
   return NS_OK;
 }
  
 nsresult
 nsHTMLEditor::DoContentFilterCallback(const nsAString &aFlavor, 
                                       nsIDOMDocument *sourceDoc,
                                       bool aWillDeleteSelection,
@@ -728,27 +727,25 @@ nsHTMLEditor::DoContentFilterCallback(co
                                       nsIDOMNode **aFragEndNode, 
                                       int32_t *aFragEndOffset,
                                       nsIDOMNode **aTargetNode,
                                       int32_t *aTargetOffset,
                                       bool *aDoContinue)
 {
   *aDoContinue = true;
 
-  int32_t i;
-  nsIContentFilter *listener;
-  for (i=0; i < mContentFilters.Count() && *aDoContinue; i++)
-  {
-    listener = (nsIContentFilter *)mContentFilters[i];
-    if (listener)
-      listener->NotifyOfInsertion(aFlavor, nullptr, sourceDoc,
-                                  aWillDeleteSelection, aFragmentAsNode,
-                                  aFragStartNode, aFragStartOffset, 
-                                  aFragEndNode, aFragEndOffset,
-                                  aTargetNode, aTargetOffset, aDoContinue);
+  for (auto& listener : mContentFilters) {
+    if (!*aDoContinue) {
+      break;
+    }
+    listener->NotifyOfInsertion(aFlavor, nullptr, sourceDoc,
+                                aWillDeleteSelection, aFragmentAsNode,
+                                aFragStartNode, aFragStartOffset,
+                                aFragEndNode, aFragEndOffset, aTargetNode,
+                                aTargetOffset, aDoContinue);
   }
 
   return NS_OK;
 }
 
 bool
 nsHTMLEditor::IsInLink(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *outLink)
 {
--- a/editor/libeditor/nsHTMLEditor.h
+++ b/editor/libeditor/nsHTMLEditor.h
@@ -755,17 +755,17 @@ protected:
                                    bool aClearStyle = true);
 
   nsresult ClearStyle(nsCOMPtr<nsIDOMNode>* aNode, int32_t* aOffset,
                       nsIAtom* aProperty, const nsAString* aAttribute);
 
 // Data members
 protected:
 
-  nsCOMArray<nsIContentFilter> mContentFilters;
+  nsTArray<mozilla::dom::OwningNonNull<nsIContentFilter>> mContentFilters;
 
   nsRefPtr<TypeInState>        mTypeInState;
 
   bool mCRInParagraphCreatesParagraph;
 
   bool mCSSAware;
   nsAutoPtr<nsHTMLCSSUtils> mHTMLCSSUtils;