Bug 1154701 part 11 - Switch nsEditor::mEditorObservers to nsTArray; r=ehsan

This commit is contained in:
Aryeh Gregor 2015-04-22 14:27:18 +03:00
Родитель 9195507155
Коммит 48afd5614f
2 изменённых файлов: 11 добавлений и 13 удалений

Просмотреть файл

@ -1733,10 +1733,8 @@ nsEditor::AddEditorObserver(nsIEditorObserver *aObserver)
NS_ENSURE_TRUE(aObserver, NS_ERROR_NULL_POINTER);
// Make sure the listener isn't already on the list
if (mEditorObservers.IndexOf(aObserver) == -1)
{
if (!mEditorObservers.AppendObject(aObserver))
return NS_ERROR_FAILURE;
if (!mEditorObservers.Contains(aObserver)) {
mEditorObservers.AppendElement(*aObserver);
}
return NS_OK;
@ -1748,8 +1746,7 @@ nsEditor::RemoveEditorObserver(nsIEditorObserver *aObserver)
{
NS_ENSURE_TRUE(aObserver, NS_ERROR_FAILURE);
if (!mEditorObservers.RemoveObject(aObserver))
return NS_ERROR_FAILURE;
mEditorObservers.RemoveElement(aObserver);
return NS_OK;
}
@ -1809,8 +1806,8 @@ nsEditor::NotifyEditorObservers(NotificationForEditorObservers aNotification)
switch (aNotification) {
case eNotifyEditorObserversOfEnd:
mIsInEditAction = false;
for (int32_t i = 0; i < mEditorObservers.Count(); i++) {
mEditorObservers[i]->EditAction();
for (auto& observer : mEditorObservers) {
observer->EditAction();
}
if (!mDispatchInputEvent) {
@ -1821,14 +1818,14 @@ nsEditor::NotifyEditorObservers(NotificationForEditorObservers aNotification)
break;
case eNotifyEditorObserversOfBefore:
mIsInEditAction = true;
for (int32_t i = 0; i < mEditorObservers.Count(); i++) {
mEditorObservers[i]->BeforeEditAction();
for (auto& observer : mEditorObservers) {
observer->BeforeEditAction();
}
break;
case eNotifyEditorObserversOfCancel:
mIsInEditAction = false;
for (int32_t i = 0; i < mEditorObservers.Count(); i++) {
mEditorObservers[i]->CancelEditAction();
for (auto& observer : mEditorObservers) {
observer->CancelEditAction();
}
break;
default:

Просмотреть файл

@ -833,7 +833,8 @@ protected:
// various listeners
// Listens to all low level actions on the doc
nsTArray<mozilla::dom::OwningNonNull<nsIEditActionListener>> mActionListeners;
nsCOMArray<nsIEditorObserver> mEditorObservers; // just notify once per high level change
// Just notify once per high level change
nsTArray<mozilla::dom::OwningNonNull<nsIEditorObserver>> mEditorObservers;
nsCOMArray<nsIDocumentStateListener> mDocStateListeners;// listen to overall doc state (dirty or not, just created, etc)
nsSelectionState mSavedSel; // cached selection for nsAutoSelectionReset