Fix revokeEvents to reliably revoke them. Bug 284389, r=darin, sr=dbaron,

a=asa


git-svn-id: svn://10.0.0.236/trunk@172263 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bzbarsky%mit.edu
2005-04-15 03:17:13 +00:00
parent 2cb741be2f
commit ca0e40385d
5 changed files with 31 additions and 17 deletions

View File

@@ -346,13 +346,12 @@ nsEventQueueImpl::ExitMonitor()
NS_IMETHODIMP
nsEventQueueImpl::RevokeEvents(void* owner)
{
PL_RevokeEvents(mEventQueue, owner);
if (mElderQueue) {
nsCOMPtr<nsIEventQueue> elder(do_QueryInterface(mElderQueue));
if (elder)
elder->RevokeEvents(owner);
}
return NS_OK;
nsCOMPtr<nsIEventQueue> youngest;
GetYoungest(getter_AddRefs(youngest));
NS_ASSERTION(youngest, "How could we possibly not have a youngest queue?");
nsCOMPtr<nsPIEventQueueChain> youngestAsChain(do_QueryInterface(youngest));
NS_ASSERTION(youngestAsChain, "RevokeEvents won't work; expect crashes");
return youngestAsChain->RevokeEventsInternal(owner);
}
@@ -657,3 +656,12 @@ nsEventQueueImpl::GetElder(nsIEventQueue **aQueue)
return mElderQueue->QueryInterface(NS_GET_IID(nsIEventQueue), (void**)&aQueue);
}
NS_IMETHODIMP
nsEventQueueImpl::RevokeEventsInternal(void* aOwner)
{
PL_RevokeEvents(mEventQueue, aOwner);
if (mElderQueue) {
mElderQueue->RevokeEventsInternal(aOwner);
}
return NS_OK;
}

View File

@@ -64,6 +64,7 @@ public:
NS_IMETHOD GetYounger(nsIEventQueue **aQueue);
NS_IMETHOD SetElder(nsPIEventQueueChain *aQueue);
NS_IMETHOD GetElder(nsIEventQueue **aQueue);
NS_IMETHOD RevokeEventsInternal(void* aOwner);
private:
~nsEventQueueImpl();

View File

@@ -95,6 +95,10 @@ interface nsIEventQueue : nsIEventTarget
void enterMonitor();
void exitMonitor();
/**
* Revoke events in this event queue and all other event queues
* for this thread that have |owner| as the event owner.
*/
[noscript] void revokeEvents(in voidPtr owner);
[noscript] PLEventQueuePtr getPLEventQueue();

View File

@@ -74,8 +74,10 @@ public:
/**
* Fetch (and addref) the youngest member of the chain which is
* still accepting events, or at least still contains events in need
* of processing.
* still accepting events. Note that there may be still younger
* queues which still contain events in need of processing but
* have already stopped accepting new events.
*
* @param *aQueue the youngest such queue. aQueue must not be null.
* *aQueue will be returned null, if no such queue is found.
* @return error indication -- can be NS_OK even if *aQueue is 0
@@ -87,6 +89,13 @@ public:
NS_IMETHOD SetElder(nsPIEventQueueChain *aQueue) = 0;
NS_IMETHOD GetElder(nsIEventQueue **aQueue) = 0;
/**
* Revoke events for aOwner in this queue and all elder queues. This
* differs in behavior from nsIEventQueue::RevokeEvents in that that
* method revokes events in younger queues too.
*/
NS_IMETHOD RevokeEventsInternal(void* aOwner) = 0;
};
#endif /* nsPIEventQueueChain_h___ */