зеркало из https://github.com/mozilla/gecko-dev.git
Bug 627084 - Add an app shell native event starvation timeout for cases where our native event pump messages get dropped by 3rd party code. r=roc
This commit is contained in:
Родитель
d6059627f3
Коммит
5df8248e6a
|
@ -54,6 +54,9 @@
|
|||
const PRUnichar* kAppShellEventId = L"nsAppShell:EventID";
|
||||
const PRUnichar* kTaskbarButtonEventId = L"TaskbarButtonCreated";
|
||||
|
||||
// The maximum time we allow before forcing a native event callback
|
||||
#define NATIVE_EVENT_STARVATION_LIMIT mozilla::TimeDuration::FromSeconds(1)
|
||||
|
||||
static UINT sMsgId;
|
||||
|
||||
#if MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_WIN7
|
||||
|
@ -135,6 +138,8 @@ nsAppShell::Init()
|
|||
LSPAnnotate();
|
||||
#endif
|
||||
|
||||
mLastNativeEventScheduled = TimeStamp::Now();
|
||||
|
||||
if (!sMsgId)
|
||||
sMsgId = RegisterWindowMessageW(kAppShellEventId);
|
||||
|
||||
|
@ -306,6 +311,9 @@ nsAppShell::ScheduleNativeEventCallback()
|
|||
{
|
||||
// Post a message to the hidden message window
|
||||
NS_ADDREF_THIS(); // will be released when the event is processed
|
||||
// Time stamp this event so we can detect cases where the event gets
|
||||
// dropping in sub classes / modal loops we do not control.
|
||||
mLastNativeEventScheduled = TimeStamp::Now();
|
||||
::PostMessage(mEventWnd, sMsgId, 0, reinterpret_cast<LPARAM>(this));
|
||||
}
|
||||
|
||||
|
@ -348,5 +356,12 @@ nsAppShell::ProcessNextNativeEvent(PRBool mayWait)
|
|||
if (mNativeCallbackPending && mEventloopNestingLevel == 1)
|
||||
DoProcessMoreGeckoEvents();
|
||||
|
||||
// Check for starved native callbacks. If we haven't processed one
|
||||
// of these events in NATIVE_EVENT_STARVATION_LIMIT, fire one off.
|
||||
if ((TimeStamp::Now() - mLastNativeEventScheduled) >
|
||||
NATIVE_EVENT_STARVATION_LIMIT) {
|
||||
ScheduleNativeEventCallback();
|
||||
}
|
||||
|
||||
return gotMessage;
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
|
||||
#include "nsBaseAppShell.h"
|
||||
#include <windows.h>
|
||||
#include "mozilla/TimeStamp.h"
|
||||
|
||||
/**
|
||||
* Native Win32 Application shell wrapper
|
||||
|
@ -51,6 +52,7 @@ public:
|
|||
mEventWnd(NULL),
|
||||
mNativeCallbackPending(PR_FALSE)
|
||||
{}
|
||||
typedef mozilla::TimeStamp TimeStamp;
|
||||
|
||||
nsresult Init();
|
||||
void DoProcessMoreGeckoEvents();
|
||||
|
@ -72,6 +74,7 @@ protected:
|
|||
protected:
|
||||
HWND mEventWnd;
|
||||
PRBool mNativeCallbackPending;
|
||||
TimeStamp mLastNativeEventScheduled;
|
||||
};
|
||||
|
||||
#endif // nsAppShell_h__
|
||||
|
|
Загрузка…
Ссылка в новой задаче