Bug 952324 - Don't block native events for more than 50ms [r=jimm]

This commit is contained in:
Matt Brubeck 2013-12-20 07:51:13 -08:00
parent 8ba68170dd
commit 40c57cd5b3

View File

@ -12,6 +12,7 @@
#include "nsIObserverService.h"
#include "nsServiceManagerUtils.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/TimeStamp.h"
#include "WinUtils.h"
#include "nsIAppStartup.h"
#include "nsToolkitCompsCID.h"
@ -49,6 +50,7 @@ static ComPtr<ICoreWindowStatic> sCoreStatic;
static bool sIsDispatching = false;
static bool sShouldPurgeThreadQueue = false;
static bool sBlockNativeEvents = false;
static TimeStamp sPurgeThreadQueueStart;
MetroAppShell::~MetroAppShell()
{
@ -283,6 +285,7 @@ MetroAppShell::DispatchAllGeckoEvents()
NS_ASSERTION(NS_IsMainThread(), "DispatchAllGeckoEvents should be called on the main thread");
sShouldPurgeThreadQueue = false;
sPurgeThreadQueueStart = TimeStamp::Now();
sBlockNativeEvents = true;
nsIThread *thread = NS_GetCurrentThread();
@ -341,8 +344,12 @@ MetroAppShell::ProcessNextNativeEvent(bool mayWait)
// to dispatch pending input in DispatchAllGeckoEvents since a native
// event may be a UIA Automation call coming in to check focus.
if (sBlockNativeEvents) {
if ((TimeStamp::Now() - sPurgeThreadQueueStart).ToMilliseconds()
< PURGE_MAX_TIMEOUT) {
return false;
}
sBlockNativeEvents = false;
}
if (ProcessOneNativeEventIfPresent()) {
return true;