зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1300003 part.2 Don't continue to dispatch eKeyPress event at handling WM_KEYDOWN or following WM_CHAR messages if focused window is changed during dispatching an event r=m_kato
While dispatching an event, focused widget may be changed. In such case, NativeKey shouldn't continue to dispatch remaining events (eKeyPress events) for preventing to dispatch to input text in unexpected website. MozReview-Commit-ID: 7geuqks0LQK --HG-- extra : rebase_source : 3e6c82e1eb0e27115fe93b1a3b4a155914fd06f7
This commit is contained in:
Родитель
af43a9e1dc
Коммит
6934d7ed93
|
@ -849,6 +849,7 @@ NativeKey::NativeKey(nsWindowBase* aWidget,
|
|||
: mWidget(aWidget)
|
||||
, mDispatcher(aWidget->GetTextEventDispatcher())
|
||||
, mMsg(aMessage)
|
||||
, mFocusedWndBeforeDispatch(::GetFocus())
|
||||
, mDOMKeyCode(0)
|
||||
, mKeyNameIndex(KEY_NAME_INDEX_Unidentified)
|
||||
, mCodeNameIndex(CODE_NAME_INDEX_UNKNOWN)
|
||||
|
@ -1749,7 +1750,7 @@ NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const
|
|||
return defaultPrevented;
|
||||
}
|
||||
|
||||
if (mWidget->Destroyed()) {
|
||||
if (mWidget->Destroyed() || IsFocusedWindowChanged()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1821,7 +1822,7 @@ NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const
|
|||
consumed =
|
||||
DispatchKeyPressEventForFollowingCharMessage(mFollowingCharMsgs[i]) ||
|
||||
consumed;
|
||||
if (mWidget->Destroyed()) {
|
||||
if (mWidget->Destroyed() || IsFocusedWindowChanged()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2361,7 +2362,7 @@ NativeKey::DispatchPluginEventsAndDiscardsCharMessages() const
|
|||
MOZ_RELEASE_ASSERT(!mWidget->Destroyed(),
|
||||
"NativeKey tries to dispatch a plugin event on destroyed widget");
|
||||
mWidget->DispatchPluginEvent(mFollowingCharMsgs[i]);
|
||||
if (mWidget->Destroyed()) {
|
||||
if (mWidget->Destroyed() || IsFocusedWindowChanged()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -267,6 +267,10 @@ private:
|
|||
// WM_SYSDEADCHAR message which follows WM_KEYDOWN.
|
||||
// Note that the stored messaged are already removed from the queue.
|
||||
nsTArray<MSG> mFollowingCharMsgs;
|
||||
// If dispatching eKeyDown or eKeyPress event causes focus change,
|
||||
// the instance shouldn't handle remaning char messages. For checking it,
|
||||
// this should store first focused window.
|
||||
HWND mFocusedWndBeforeDispatch;
|
||||
|
||||
uint32_t mDOMKeyCode;
|
||||
KeyNameIndex mKeyNameIndex;
|
||||
|
@ -526,6 +530,15 @@ private:
|
|||
* state.
|
||||
*/
|
||||
void ComputeInputtingStringWithKeyboardLayout();
|
||||
|
||||
/**
|
||||
* IsFocusedWindowChanged() returns true if focused window is changed
|
||||
* after the instance is created.
|
||||
*/
|
||||
bool IsFocusedWindowChanged() const
|
||||
{
|
||||
return mFocusedWndBeforeDispatch != ::GetFocus();
|
||||
}
|
||||
};
|
||||
|
||||
class KeyboardLayout
|
||||
|
|
Загрузка…
Ссылка в новой задаче