mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Convert nsTransactionManager's mListeners from nsVoidArray* to nsCOMArray<nsITransactionListener>. (Bug 488799) r+sr=peterv
This commit is contained in:
parent
a8fbab994c
commit
34e7f57d3f
@ -51,28 +51,13 @@
|
||||
|
||||
|
||||
nsTransactionManager::nsTransactionManager(PRInt32 aMaxTransactionCount)
|
||||
: mMaxTransactionCount(aMaxTransactionCount), mListeners(0)
|
||||
: mMaxTransactionCount(aMaxTransactionCount)
|
||||
{
|
||||
mMonitor = ::PR_NewMonitor();
|
||||
}
|
||||
|
||||
nsTransactionManager::~nsTransactionManager()
|
||||
{
|
||||
if (mListeners)
|
||||
{
|
||||
PRInt32 i;
|
||||
nsITransactionListener *listener;
|
||||
|
||||
for (i = 0; i < mListeners->Count(); i++)
|
||||
{
|
||||
listener = (nsITransactionListener *)mListeners->ElementAt(i);
|
||||
NS_IF_RELEASE(listener);
|
||||
}
|
||||
|
||||
delete mListeners;
|
||||
mListeners = 0;
|
||||
}
|
||||
|
||||
if (mMonitor)
|
||||
{
|
||||
::PR_DestroyMonitor(mMonitor);
|
||||
@ -653,25 +638,11 @@ nsTransactionManager::AddListener(nsITransactionListener *aListener)
|
||||
|
||||
LOCK_TX_MANAGER(this);
|
||||
|
||||
if (!mListeners) {
|
||||
mListeners = new nsAutoVoidArray();
|
||||
|
||||
if (!mListeners) {
|
||||
UNLOCK_TX_MANAGER(this);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mListeners->AppendElement((void *)aListener)) {
|
||||
UNLOCK_TX_MANAGER(this);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_ADDREF(aListener);
|
||||
nsresult rv = mListeners.AppendObject(aListener) ? NS_OK : NS_ERROR_FAILURE;
|
||||
|
||||
UNLOCK_TX_MANAGER(this);
|
||||
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -680,28 +651,13 @@ nsTransactionManager::RemoveListener(nsITransactionListener *aListener)
|
||||
if (!aListener)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (!mListeners)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
LOCK_TX_MANAGER(this);
|
||||
|
||||
if (!mListeners->RemoveElement((void *)aListener))
|
||||
{
|
||||
UNLOCK_TX_MANAGER(this);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(aListener);
|
||||
|
||||
if (mListeners->Count() < 1)
|
||||
{
|
||||
delete mListeners;
|
||||
mListeners = 0;
|
||||
}
|
||||
nsresult rv = mListeners.RemoveObject(aListener) ? NS_OK : NS_ERROR_FAILURE;
|
||||
|
||||
UNLOCK_TX_MANAGER(this);
|
||||
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -731,15 +687,10 @@ nsTransactionManager::ClearRedoStack()
|
||||
nsresult
|
||||
nsTransactionManager::WillDoNotify(nsITransaction *aTransaction, PRBool *aInterrupt)
|
||||
{
|
||||
if (!mListeners)
|
||||
return NS_OK;
|
||||
|
||||
nsresult result = NS_OK;
|
||||
PRInt32 i, lcount = mListeners->Count();
|
||||
|
||||
for (i = 0; i < lcount; i++)
|
||||
for (PRInt32 i = 0, lcount = mListeners.Count(); i < lcount; i++)
|
||||
{
|
||||
nsITransactionListener *listener = (nsITransactionListener *)mListeners->ElementAt(i);
|
||||
nsITransactionListener *listener = mListeners[i];
|
||||
|
||||
if (!listener)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -756,15 +707,10 @@ nsTransactionManager::WillDoNotify(nsITransaction *aTransaction, PRBool *aInterr
|
||||
nsresult
|
||||
nsTransactionManager::DidDoNotify(nsITransaction *aTransaction, nsresult aDoResult)
|
||||
{
|
||||
if (!mListeners)
|
||||
return NS_OK;
|
||||
|
||||
nsresult result = NS_OK;
|
||||
PRInt32 i, lcount = mListeners->Count();
|
||||
|
||||
for (i = 0; i < lcount; i++)
|
||||
for (PRInt32 i = 0, lcount = mListeners.Count(); i < lcount; i++)
|
||||
{
|
||||
nsITransactionListener *listener = (nsITransactionListener *)mListeners->ElementAt(i);
|
||||
nsITransactionListener *listener = mListeners[i];
|
||||
|
||||
if (!listener)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -781,15 +727,10 @@ nsTransactionManager::DidDoNotify(nsITransaction *aTransaction, nsresult aDoResu
|
||||
nsresult
|
||||
nsTransactionManager::WillUndoNotify(nsITransaction *aTransaction, PRBool *aInterrupt)
|
||||
{
|
||||
if (!mListeners)
|
||||
return NS_OK;
|
||||
|
||||
nsresult result = NS_OK;
|
||||
PRInt32 i, lcount = mListeners->Count();
|
||||
|
||||
for (i = 0; i < lcount; i++)
|
||||
for (PRInt32 i = 0, lcount = mListeners.Count(); i < lcount; i++)
|
||||
{
|
||||
nsITransactionListener *listener = (nsITransactionListener *)mListeners->ElementAt(i);
|
||||
nsITransactionListener *listener = mListeners[i];
|
||||
|
||||
if (!listener)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -806,15 +747,10 @@ nsTransactionManager::WillUndoNotify(nsITransaction *aTransaction, PRBool *aInte
|
||||
nsresult
|
||||
nsTransactionManager::DidUndoNotify(nsITransaction *aTransaction, nsresult aUndoResult)
|
||||
{
|
||||
if (!mListeners)
|
||||
return NS_OK;
|
||||
|
||||
nsresult result = NS_OK;
|
||||
PRInt32 i, lcount = mListeners->Count();
|
||||
|
||||
for (i = 0; i < lcount; i++)
|
||||
for (PRInt32 i = 0, lcount = mListeners.Count(); i < lcount; i++)
|
||||
{
|
||||
nsITransactionListener *listener = (nsITransactionListener *)mListeners->ElementAt(i);
|
||||
nsITransactionListener *listener = mListeners[i];
|
||||
|
||||
if (!listener)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -831,15 +767,10 @@ nsTransactionManager::DidUndoNotify(nsITransaction *aTransaction, nsresult aUndo
|
||||
nsresult
|
||||
nsTransactionManager::WillRedoNotify(nsITransaction *aTransaction, PRBool *aInterrupt)
|
||||
{
|
||||
if (!mListeners)
|
||||
return NS_OK;
|
||||
|
||||
nsresult result = NS_OK;
|
||||
PRInt32 i, lcount = mListeners->Count();
|
||||
|
||||
for (i = 0; i < lcount; i++)
|
||||
for (PRInt32 i = 0, lcount = mListeners.Count(); i < lcount; i++)
|
||||
{
|
||||
nsITransactionListener *listener = (nsITransactionListener *)mListeners->ElementAt(i);
|
||||
nsITransactionListener *listener = mListeners[i];
|
||||
|
||||
if (!listener)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -856,15 +787,10 @@ nsTransactionManager::WillRedoNotify(nsITransaction *aTransaction, PRBool *aInte
|
||||
nsresult
|
||||
nsTransactionManager::DidRedoNotify(nsITransaction *aTransaction, nsresult aRedoResult)
|
||||
{
|
||||
if (!mListeners)
|
||||
return NS_OK;
|
||||
|
||||
nsresult result = NS_OK;
|
||||
PRInt32 i, lcount = mListeners->Count();
|
||||
|
||||
for (i = 0; i < lcount; i++)
|
||||
for (PRInt32 i = 0, lcount = mListeners.Count(); i < lcount; i++)
|
||||
{
|
||||
nsITransactionListener *listener = (nsITransactionListener *)mListeners->ElementAt(i);
|
||||
nsITransactionListener *listener = mListeners[i];
|
||||
|
||||
if (!listener)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -881,15 +807,10 @@ nsTransactionManager::DidRedoNotify(nsITransaction *aTransaction, nsresult aRedo
|
||||
nsresult
|
||||
nsTransactionManager::WillBeginBatchNotify(PRBool *aInterrupt)
|
||||
{
|
||||
if (!mListeners)
|
||||
return NS_OK;
|
||||
|
||||
nsresult result = NS_OK;
|
||||
PRInt32 i, lcount = mListeners->Count();
|
||||
|
||||
for (i = 0; i < lcount; i++)
|
||||
for (PRInt32 i = 0, lcount = mListeners.Count(); i < lcount; i++)
|
||||
{
|
||||
nsITransactionListener *listener = (nsITransactionListener *)mListeners->ElementAt(i);
|
||||
nsITransactionListener *listener = mListeners[i];
|
||||
|
||||
if (!listener)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -906,15 +827,10 @@ nsTransactionManager::WillBeginBatchNotify(PRBool *aInterrupt)
|
||||
nsresult
|
||||
nsTransactionManager::DidBeginBatchNotify(nsresult aResult)
|
||||
{
|
||||
if (!mListeners)
|
||||
return NS_OK;
|
||||
|
||||
nsresult result = NS_OK;
|
||||
PRInt32 i, lcount = mListeners->Count();
|
||||
|
||||
for (i = 0; i < lcount; i++)
|
||||
for (PRInt32 i = 0, lcount = mListeners.Count(); i < lcount; i++)
|
||||
{
|
||||
nsITransactionListener *listener = (nsITransactionListener *)mListeners->ElementAt(i);
|
||||
nsITransactionListener *listener = mListeners[i];
|
||||
|
||||
if (!listener)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -931,15 +847,10 @@ nsTransactionManager::DidBeginBatchNotify(nsresult aResult)
|
||||
nsresult
|
||||
nsTransactionManager::WillEndBatchNotify(PRBool *aInterrupt)
|
||||
{
|
||||
if (!mListeners)
|
||||
return NS_OK;
|
||||
|
||||
nsresult result = NS_OK;
|
||||
PRInt32 i, lcount = mListeners->Count();
|
||||
|
||||
for (i = 0; i < lcount; i++)
|
||||
for (PRInt32 i = 0, lcount = mListeners.Count(); i < lcount; i++)
|
||||
{
|
||||
nsITransactionListener *listener = (nsITransactionListener *)mListeners->ElementAt(i);
|
||||
nsITransactionListener *listener = mListeners[i];
|
||||
|
||||
if (!listener)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -956,15 +867,10 @@ nsTransactionManager::WillEndBatchNotify(PRBool *aInterrupt)
|
||||
nsresult
|
||||
nsTransactionManager::DidEndBatchNotify(nsresult aResult)
|
||||
{
|
||||
if (!mListeners)
|
||||
return NS_OK;
|
||||
|
||||
nsresult result = NS_OK;
|
||||
PRInt32 i, lcount = mListeners->Count();
|
||||
|
||||
for (i = 0; i < lcount; i++)
|
||||
for (PRInt32 i = 0, lcount = mListeners.Count(); i < lcount; i++)
|
||||
{
|
||||
nsITransactionListener *listener = (nsITransactionListener *)mListeners->ElementAt(i);
|
||||
nsITransactionListener *listener = mListeners[i];
|
||||
|
||||
if (!listener)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -981,15 +887,10 @@ nsTransactionManager::DidEndBatchNotify(nsresult aResult)
|
||||
nsresult
|
||||
nsTransactionManager::WillMergeNotify(nsITransaction *aTop, nsITransaction *aTransaction, PRBool *aInterrupt)
|
||||
{
|
||||
if (!mListeners)
|
||||
return NS_OK;
|
||||
|
||||
nsresult result = NS_OK;
|
||||
PRInt32 i, lcount = mListeners->Count();
|
||||
|
||||
for (i = 0; i < lcount; i++)
|
||||
for (PRInt32 i = 0, lcount = mListeners.Count(); i < lcount; i++)
|
||||
{
|
||||
nsITransactionListener *listener = (nsITransactionListener *)mListeners->ElementAt(i);
|
||||
nsITransactionListener *listener = mListeners[i];
|
||||
|
||||
if (!listener)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -1009,15 +910,10 @@ nsTransactionManager::DidMergeNotify(nsITransaction *aTop,
|
||||
PRBool aDidMerge,
|
||||
nsresult aMergeResult)
|
||||
{
|
||||
if (!mListeners)
|
||||
return NS_OK;
|
||||
|
||||
nsresult result = NS_OK;
|
||||
PRInt32 i, lcount = mListeners->Count();
|
||||
|
||||
for (i = 0; i < lcount; i++)
|
||||
for (PRInt32 i = 0, lcount = mListeners.Count(); i < lcount; i++)
|
||||
{
|
||||
nsITransactionListener *listener = (nsITransactionListener *)mListeners->ElementAt(i);
|
||||
nsITransactionListener *listener = mListeners[i];
|
||||
|
||||
if (!listener)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -41,13 +41,14 @@
|
||||
#include "prmon.h"
|
||||
#include "nsWeakReference.h"
|
||||
#include "nsITransactionManager.h"
|
||||
#include "nsCOMArray.h"
|
||||
#include "nsITransactionListener.h"
|
||||
|
||||
class nsITransaction;
|
||||
class nsITransactionListener;
|
||||
class nsTransactionItem;
|
||||
class nsTransactionStack;
|
||||
class nsTransactionRedoStack;
|
||||
class nsVoidArray;
|
||||
|
||||
/** implementation of a transaction manager object.
|
||||
*
|
||||
@ -61,7 +62,7 @@ private:
|
||||
nsTransactionStack mDoStack;
|
||||
nsTransactionStack mUndoStack;
|
||||
nsTransactionRedoStack mRedoStack;
|
||||
nsVoidArray *mListeners;
|
||||
nsCOMArray<nsITransactionListener> mListeners;
|
||||
|
||||
PRMonitor *mMonitor;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user