зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1257759 part.10 PluginInstanceChild should consume WM_*CHAR messages which follow consumed WM_*KEYDOWN or WM_*KEYUP message r=jimm
nsWindow for Windows cannot decide if a preceding WM_*KEYDOWN or WM_*KEYUP which is a preceding message of WM_*CHAR is consumed because nsWindow cannot know if WM_*CHAR message came from same window which received the preceding WM_*KEYDOWN or WM_*KEYUP. Therefore, PluginInstanceChild should do that. MozReview-Commit-ID: 1uuZ0nTJ5Xb --HG-- extra : rebase_source : b99f8057d5e93035a769af2506292ff7d2cb8f4a
This commit is contained in:
Родитель
0b9b9bf032
Коммит
79ea112b87
|
@ -202,6 +202,9 @@ PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface,
|
|||
, mHasPainted(false)
|
||||
, mSurfaceDifferenceRect(0,0,0,0)
|
||||
, mDestroyed(false)
|
||||
#ifdef XP_WIN
|
||||
, mLastKeyEventConsumed(false)
|
||||
#endif // #ifdef XP_WIN
|
||||
, mStackDepth(0)
|
||||
{
|
||||
memset(&mWindow, 0, sizeof(mWindow));
|
||||
|
@ -1443,6 +1446,30 @@ PluginInstanceChild::RecvHandledWindowedPluginKeyEvent(
|
|||
const NativeEventData& aKeyEventData,
|
||||
const bool& aIsConsumed)
|
||||
{
|
||||
#if defined(OS_WIN)
|
||||
const WinNativeKeyEventData* eventData =
|
||||
static_cast<const WinNativeKeyEventData*>(aKeyEventData);
|
||||
switch (eventData->mMessage) {
|
||||
case WM_KEYDOWN:
|
||||
case WM_SYSKEYDOWN:
|
||||
case WM_KEYUP:
|
||||
case WM_SYSKEYUP:
|
||||
mLastKeyEventConsumed = aIsConsumed;
|
||||
break;
|
||||
case WM_CHAR:
|
||||
case WM_SYSCHAR:
|
||||
case WM_DEADCHAR:
|
||||
case WM_SYSDEADCHAR:
|
||||
// If preceding keydown or keyup event is consumed by the chrome
|
||||
// process, we should consume WM_*CHAR messages too.
|
||||
if (mLastKeyEventConsumed) {
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
MOZ_CRASH("Needs to handle all messages posted to the parent");
|
||||
}
|
||||
#endif // #if defined(OS_WIN)
|
||||
|
||||
// Unknown key input shouldn't be sent to plugin for security.
|
||||
// XXX Is this possible if a plugin process which posted the message
|
||||
// already crashed and this plugin process is recreated?
|
||||
|
@ -1468,8 +1495,6 @@ PluginInstanceChild::RecvHandledWindowedPluginKeyEvent(
|
|||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
const WinNativeKeyEventData* eventData =
|
||||
static_cast<const WinNativeKeyEventData*>(aKeyEventData);
|
||||
UINT message = 0;
|
||||
switch (eventData->mMessage) {
|
||||
case WM_KEYDOWN:
|
||||
|
@ -1670,6 +1695,7 @@ PluginInstanceChild::PluginWindowProcInternal(HWND hWnd,
|
|||
// Although, such case shouldn't occur.
|
||||
NS_WARN_IF(self->mPostingKeyEvents > 0);
|
||||
self->mPostingKeyEvents = 0;
|
||||
self->mLastKeyEventConsumed = false;
|
||||
break;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
|
|
|
@ -671,6 +671,14 @@ private:
|
|||
// Has this instance been destroyed, either by ActorDestroy or NPP_Destroy?
|
||||
bool mDestroyed;
|
||||
|
||||
#ifdef XP_WIN
|
||||
// WM_*CHAR messages are never consumed by chrome process's widget.
|
||||
// So, if preceding keydown or keyup event is consumed by reserved
|
||||
// shortcut key in the chrome process, we shouldn't send the following
|
||||
// WM_*CHAR messages to the plugin.
|
||||
bool mLastKeyEventConsumed;
|
||||
#endif // #ifdef XP_WIN
|
||||
|
||||
// While IME in the process has composition, this is set to true.
|
||||
// Otherwise, false.
|
||||
static bool sIsIMEComposing;
|
||||
|
|
|
@ -1507,7 +1507,7 @@ NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const
|
|||
WidgetKeyboardEvent keydownEvent(true, keyDownMessage, mWidget);
|
||||
nsEventStatus status = InitKeyEvent(keydownEvent, mModKeyState, &mMsg);
|
||||
bool dispatched =
|
||||
mDispatcher->DispatchKeyboardEvent(eKeyDown, keydownEvent, status,
|
||||
mDispatcher->DispatchKeyboardEvent(keyDownMessage, keydownEvent, status,
|
||||
const_cast<NativeKey*>(this));
|
||||
if (aEventDispatched) {
|
||||
*aEventDispatched = dispatched;
|
||||
|
@ -1765,11 +1765,11 @@ NativeKey::HandleKeyUpMessage(bool* aEventDispatched) const
|
|||
return true;
|
||||
}
|
||||
|
||||
WidgetKeyboardEvent keyupEvent(true, eKeyUp, mWidget);
|
||||
nsEventStatus status = InitKeyEvent(keyupEvent, mModKeyState, &mMsg);
|
||||
EventMessage keyUpMessage = IsKeyMessageOnPlugin() ? eKeyUpOnPlugin : eKeyUp;
|
||||
WidgetKeyboardEvent keyupEvent(true, keyUpMessage, mWidget);
|
||||
nsEventStatus status = InitKeyEvent(keyupEvent, mModKeyState, &mMsg);
|
||||
bool dispatched =
|
||||
mDispatcher->DispatchKeyboardEvent(eKeyUp, keyupEvent, status,
|
||||
mDispatcher->DispatchKeyboardEvent(keyUpMessage, keyupEvent, status,
|
||||
const_cast<NativeKey*>(this));
|
||||
if (aEventDispatched) {
|
||||
*aEventDispatched = dispatched;
|
||||
|
|
Загрузка…
Ссылка в новой задаче