зеркало из https://github.com/mozilla/gecko-dev.git
Fix revokeEvents to reliably revoke them. Bug 284389, r=darin, sr=dbaron,
a=asa
This commit is contained in:
Родитель
bfc3f7e1b6
Коммит
c5cc24631e
|
@ -358,14 +358,6 @@ static void* PR_CALLBACK HandlePLEvent(PLEvent* aEvent)
|
|||
NS_ASSERTION(nsnull != aEvent,"Event is null");
|
||||
nsViewManagerEvent *event = NS_STATIC_CAST(nsViewManagerEvent*, aEvent);
|
||||
|
||||
// Search for valid view manager before trying to access it. This
|
||||
// is working around a bug in RevokeEvents.
|
||||
const nsVoidArray *vmArray = nsViewManager::GetViewManagerArray();
|
||||
if (!vmArray || vmArray->IndexOf(event->ViewManager()) == -1) {
|
||||
NS_ERROR("RevokeEvents is buggy. Fix it!");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
event->HandleEvent();
|
||||
return nsnull;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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___ */
|
||||
|
|
Загрузка…
Ссылка в новой задаче