Bug 322985, Remove aScriptOnly parameter from the nsIEventListenerManager::RemoveAllListeners r+sr=jst
This commit is contained in:
Родитель
5451a0fc37
Коммит
91b6c36998
|
@ -54,8 +54,9 @@ struct JSObject;
|
|||
* Event listener manager interface.
|
||||
*/
|
||||
#define NS_IEVENTLISTENERMANAGER_IID \
|
||||
{0xc23b877c, 0xb396, 0x11d9, \
|
||||
{0x86, 0xbd, 0x00, 0x11, 0x24, 0x78, 0xd6, 0x26} }
|
||||
{ 0xec4df50f, 0x3f1d, 0x479c, \
|
||||
{ 0x80, 0xad, 0x9c, 0x0e, 0x4b, 0x90, 0x61, 0x57 } }
|
||||
|
||||
|
||||
class nsIEventListenerManager : public nsISupports {
|
||||
|
||||
|
@ -168,7 +169,7 @@ public:
|
|||
* Removes all event listeners registered by this instance of the listener
|
||||
* manager.
|
||||
*/
|
||||
NS_IMETHOD RemoveAllListeners(PRBool aScriptOnly) = 0;
|
||||
NS_IMETHOD RemoveAllListeners() = 0;
|
||||
|
||||
/**
|
||||
* Removes all event listeners registered by this instance of the listener
|
||||
|
|
|
@ -413,32 +413,20 @@ GenericListenersHashEnum(nsHashKey *aKey, void *aData, void* closure)
|
|||
if (listeners) {
|
||||
PRInt32 i, count = listeners->Count();
|
||||
nsListenerStruct *ls;
|
||||
PRBool* scriptOnly = NS_STATIC_CAST(PRBool*, closure);
|
||||
for (i = count-1; i >= 0; --i) {
|
||||
ls = (nsListenerStruct*)listeners->ElementAt(i);
|
||||
if (ls) {
|
||||
if (*scriptOnly) {
|
||||
if (ls->mFlags & NS_PRIV_EVENT_FLAG_SCRIPT) {
|
||||
listeners->RemoveElement(ls);
|
||||
delete ls;
|
||||
}
|
||||
}
|
||||
else {
|
||||
delete ls;
|
||||
}
|
||||
delete ls;
|
||||
}
|
||||
}
|
||||
//Only delete if we were removing all listeners
|
||||
if (!*scriptOnly) {
|
||||
delete listeners;
|
||||
}
|
||||
delete listeners;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsEventListenerManager::~nsEventListenerManager()
|
||||
{
|
||||
RemoveAllListeners(PR_FALSE);
|
||||
RemoveAllListeners();
|
||||
|
||||
--mInstanceCount;
|
||||
if(mInstanceCount == 0) {
|
||||
|
@ -448,13 +436,11 @@ nsEventListenerManager::~nsEventListenerManager()
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsEventListenerManager::RemoveAllListeners(PRBool aScriptOnly)
|
||||
nsEventListenerManager::RemoveAllListeners()
|
||||
{
|
||||
if (!aScriptOnly) {
|
||||
mListenersRemoved = PR_TRUE;
|
||||
}
|
||||
mListenersRemoved = PR_TRUE;
|
||||
|
||||
ReleaseListeners(&mSingleListener, aScriptOnly);
|
||||
ReleaseListeners(&mSingleListener);
|
||||
if (!mSingleListener) {
|
||||
mSingleListenerType = eEventArrayType_None;
|
||||
mManagerType &= ~NS_ELM_SINGLE;
|
||||
|
@ -465,24 +451,19 @@ nsEventListenerManager::RemoveAllListeners(PRBool aScriptOnly)
|
|||
for (PRInt32 i=0; i<EVENT_ARRAY_TYPE_LENGTH && i < mMultiListeners->Count(); i++) {
|
||||
nsVoidArray* listeners;
|
||||
listeners = NS_STATIC_CAST(nsVoidArray*, mMultiListeners->ElementAt(i));
|
||||
ReleaseListeners(&listeners, aScriptOnly);
|
||||
}
|
||||
if (!aScriptOnly) {
|
||||
delete mMultiListeners;
|
||||
mMultiListeners = nsnull;
|
||||
mManagerType &= ~NS_ELM_MULTI;
|
||||
ReleaseListeners(&listeners);
|
||||
}
|
||||
delete mMultiListeners;
|
||||
mMultiListeners = nsnull;
|
||||
mManagerType &= ~NS_ELM_MULTI;
|
||||
}
|
||||
|
||||
if (mGenericListeners) {
|
||||
PRBool scriptOnly = aScriptOnly;
|
||||
mGenericListeners->Enumerate(GenericListenersHashEnum, &scriptOnly);
|
||||
mGenericListeners->Enumerate(GenericListenersHashEnum, nsnull);
|
||||
//hash destructor
|
||||
if (!aScriptOnly) {
|
||||
delete mGenericListeners;
|
||||
mGenericListeners = nsnull;
|
||||
mManagerType &= ~NS_ELM_HASH;
|
||||
}
|
||||
delete mGenericListeners;
|
||||
mGenericListeners = nsnull;
|
||||
mManagerType &= ~NS_ELM_HASH;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -673,8 +654,7 @@ nsEventListenerManager::GetTypeForIID(const nsIID& aIID)
|
|||
}
|
||||
|
||||
void
|
||||
nsEventListenerManager::ReleaseListeners(nsVoidArray** aListeners,
|
||||
PRBool aScriptOnly)
|
||||
nsEventListenerManager::ReleaseListeners(nsVoidArray** aListeners)
|
||||
{
|
||||
if (nsnull != *aListeners) {
|
||||
PRInt32 i, count = (*aListeners)->Count();
|
||||
|
@ -682,22 +662,11 @@ nsEventListenerManager::ReleaseListeners(nsVoidArray** aListeners,
|
|||
for (i = 0; i < count; i++) {
|
||||
ls = (nsListenerStruct*)(*aListeners)->ElementAt(i);
|
||||
if (ls) {
|
||||
if (aScriptOnly) {
|
||||
if (ls->mFlags & NS_PRIV_EVENT_FLAG_SCRIPT) {
|
||||
(*aListeners)->RemoveElement(ls);
|
||||
delete ls;
|
||||
}
|
||||
}
|
||||
else {
|
||||
delete ls;
|
||||
}
|
||||
delete ls;
|
||||
}
|
||||
}
|
||||
//Only delete if we were removing all listeners
|
||||
if (!aScriptOnly) {
|
||||
delete *aListeners;
|
||||
*aListeners = nsnull;
|
||||
}
|
||||
delete *aListeners;
|
||||
*aListeners = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ public:
|
|||
const nsAString& aEventType,
|
||||
nsIDOMEvent** aDOMEvent);
|
||||
|
||||
NS_IMETHOD RemoveAllListeners(PRBool aScriptOnly);
|
||||
NS_IMETHOD RemoveAllListeners();
|
||||
|
||||
NS_IMETHOD SetListenerTarget(nsISupports* aTarget);
|
||||
|
||||
|
@ -235,7 +235,7 @@ protected:
|
|||
nsHashKey* aKey,
|
||||
PRInt32 aFlags,
|
||||
nsIDOMEventGroup* aEvtGrp);
|
||||
void ReleaseListeners(nsVoidArray** aListeners, PRBool aScriptOnly);
|
||||
void ReleaseListeners(nsVoidArray** aListeners);
|
||||
nsresult FlipCaptureBit(PRInt32 aEventTypes, PRBool aInitCapture);
|
||||
nsVoidArray* GetListenersByType(EventArrayType aType, nsHashKey* aKey, PRBool aCreate);
|
||||
EventArrayType GetTypeForIID(const nsIID& aIID);
|
||||
|
|
|
@ -474,7 +474,7 @@ nsGlobalWindow::FreeInnerObjects(JSContext *cx)
|
|||
mChromeEventHandler = nsnull;
|
||||
|
||||
if (mListenerManager) {
|
||||
mListenerManager->RemoveAllListeners(PR_FALSE);
|
||||
mListenerManager->RemoveAllListeners();
|
||||
mListenerManager = nsnull;
|
||||
}
|
||||
|
||||
|
@ -1002,7 +1002,7 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
|||
}
|
||||
|
||||
if (!reUseInnerWindow && currentInner->mListenerManager) {
|
||||
currentInner->mListenerManager->RemoveAllListeners(PR_FALSE);
|
||||
currentInner->mListenerManager->RemoveAllListeners();
|
||||
currentInner->mListenerManager = nsnull;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче