Bug 1154701 part 4 - Switch nsHTMLEditor::mContentFilters to nsTArray; r=ehsan

This commit is contained in:
Aryeh Gregor 2015-04-22 14:27:17 +03:00
parent 30ee50d5a4
commit 5b43d87861
2 changed files with 15 additions and 18 deletions

View File

@ -694,26 +694,25 @@ nsHTMLEditor::DoInsertHTMLWithContext(const nsAString & aInputString,
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;
}
@ -733,17 +732,15 @@ nsHTMLEditor::DoContentFilterCallback(const nsAString &aFlavor,
{
*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;

View File

@ -760,7 +760,7 @@ protected:
// Data members
protected:
nsCOMArray<nsIContentFilter> mContentFilters;
nsTArray<mozilla::dom::OwningNonNull<nsIContentFilter>> mContentFilters;
nsRefPtr<TypeInState> mTypeInState;