Bug 1297013 part.3 Make NativeKey log its behavior r=m_kato

MozReview-Commit-ID: 6ksuMFMxQdM

--HG--
extra : rebase_source : 28f04d8e5d33c018a8bcda7d8ae1a84da07eaeb9
This commit is contained in:
Masayuki Nakano 2016-09-21 13:29:34 +09:00
Родитель 97735168f1
Коммит c4106a36a9
3 изменённых файлов: 506 добавлений и 14 удалений

Просмотреть файл

@ -138,6 +138,12 @@ static const char* kVirtualKeyName[] = {
static_assert(sizeof(kVirtualKeyName) / sizeof(const char*) == 0x100,
"The virtual key name must be defined just 256 keys");
static const char*
GetBoolName(bool aBool)
{
return aBool ? "true" : "false";
}
static const nsCString
GetCharacterCodeName(WPARAM aCharCode)
{
@ -244,6 +250,23 @@ GetCharacterCodeName(WPARAM aCharCode)
}
}
static const nsCString
GetKeyLocationName(uint32_t aLocation)
{
switch (aLocation) {
case nsIDOMKeyEvent::DOM_KEY_LOCATION_LEFT:
return NS_LITERAL_CSTRING("KEY_LOCATION_LEFT");
case nsIDOMKeyEvent::DOM_KEY_LOCATION_RIGHT:
return NS_LITERAL_CSTRING("KEY_LOCATION_RIGHT");
case nsIDOMKeyEvent::DOM_KEY_LOCATION_STANDARD:
return NS_LITERAL_CSTRING("KEY_LOCATION_STANDARD");
case nsIDOMKeyEvent::DOM_KEY_LOCATION_NUMPAD:
return NS_LITERAL_CSTRING("KEY_LOCATION_NUMPAD");
default:
return nsPrintfCString("Unknown (0x%04X)", aLocation);
}
}
static const nsCString
GetCharacterCodeName(char16_t* aChars, uint32_t aLength)
{
@ -594,6 +617,42 @@ ToString(const MSG& aMSG)
return result;
}
static const nsCString
ToString(const UniCharsAndModifiers& aUniCharsAndModifiers)
{
if (aUniCharsAndModifiers.IsEmpty()) {
return NS_LITERAL_CSTRING("{}");
}
nsAutoCString result;
result.AssignLiteral("{ ");
result.Append(GetCharacterCodeName(aUniCharsAndModifiers.mChars[0]));
for (uint32_t i = 1; i < aUniCharsAndModifiers.mLength; ++i) {
if (aUniCharsAndModifiers.mModifiers[i - 1] !=
aUniCharsAndModifiers.mModifiers[i]) {
result.AppendLiteral(" [");
result.Append(GetModifiersName(aUniCharsAndModifiers.mModifiers[0]));
result.AppendLiteral("]");
}
result.AppendLiteral(", ");
result.Append(GetCharacterCodeName(aUniCharsAndModifiers.mChars[i]));
}
result.AppendLiteral(" [");
uint32_t lastIndex = aUniCharsAndModifiers.mLength - 1;
result.Append(GetModifiersName(aUniCharsAndModifiers.mModifiers[lastIndex]));
result.AppendLiteral("] }");
return result;
}
const nsCString
ToString(const ModifierKeyState& aModifierKeyState)
{
nsAutoCString result;
result.AssignLiteral("{ ");
result.Append(GetModifiersName(aModifierKeyState.GetModifiers()).get());
result.AppendLiteral(" }");
return result;
}
// Unique id counter associated with a keydown / keypress events. Used in
// identifing keypress events for removal from async event dispatch queue
// in metrofx after preventDefault is called on keydown events.
@ -1132,6 +1191,8 @@ VirtualKey::FillKbdState(PBYTE aKbdState,
uint8_t NativeKey::sDispatchedKeyOfAppCommand = 0;
LazyLogModule sNativeKeyLogger("NativeKeyWidgets");
NativeKey::NativeKey(nsWindowBase* aWidget,
const MSG& aMessage,
const ModifierKeyState& aModKeyState,
@ -1155,6 +1216,12 @@ NativeKey::NativeKey(nsWindowBase* aWidget,
, mFakeCharMsgs(aFakeCharMsgs && aFakeCharMsgs->Length() ?
aFakeCharMsgs : nullptr)
{
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::NativeKey(aWidget=0x%p { GetWindowHandle()=0x%p }, "
"aMessage=%s, aModKeyState=%s)",
this, aWidget, aWidget->GetWindowHandle(), ToString(aMessage).get(),
ToString(aModKeyState).get()));
MOZ_ASSERT(aWidget);
MOZ_ASSERT(mDispatcher);
KeyboardLayout* keyboardLayout = KeyboardLayout::GetInstance();
@ -1170,9 +1237,37 @@ NativeKey::NativeKey(nsWindowBase* aWidget,
if (mMsg.message == WM_APPCOMMAND) {
InitWithAppCommand();
return;
} else {
InitWithKeyChar();
}
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::NativeKey(), mKeyboardLayout=0x%08X, "
"mFocusedWndBeforeDispatch=0x%p, mDOMKeyCode=0x%04X, "
"mKeyNameIndex=%s, mCodeNameIndex=%s, mModKeyState=%s, "
"mVirtualKeyCode=%s, mOriginalVirtualKeyCode=%s, "
"mCommittedCharsAndModifiers=%s, mInputtingStringAndModifiers=%s, "
"mShiftedString=%s, mUnshiftedString=%s, mShiftedLatinChar=%s, "
"mUnshiftedLatinChar=%s, mScanCode=0x%04X, mIsExtended=%s, "
"mIsDeadKey=%s, mIsPrintableKey=%s, mIsOverridingKeyboardLayout=%s",
this, mKeyboardLayout, mFocusedWndBeforeDispatch,
GetDOMKeyCodeName(mDOMKeyCode).get(), ToString(mKeyNameIndex).get(),
ToString(mCodeNameIndex).get(),
ToString(mModKeyState).get(),
GetVirtualKeyCodeName(mVirtualKeyCode).get(),
GetVirtualKeyCodeName(mOriginalVirtualKeyCode).get(),
ToString(mCommittedCharsAndModifiers).get(),
ToString(mInputtingStringAndModifiers).get(),
ToString(mShiftedString).get(), ToString(mUnshiftedString).get(),
GetCharacterCodeName(mShiftedLatinChar).get(),
GetCharacterCodeName(mUnshiftedLatinChar).get(),
mScanCode, GetBoolName(mIsExtended), GetBoolName(mIsDeadKey),
GetBoolName(mIsPrintableKey), GetBoolName(mIsOverridingKeyboardLayout)));
}
void
NativeKey::InitWithKeyChar()
{
mScanCode = WinUtils::GetScanCode(mMsg.lParam);
mIsExtended = WinUtils::IsExtendedScanCode(mMsg.lParam);
switch (mMsg.message) {
@ -1186,6 +1281,9 @@ NativeKey::NativeKey(nsWindowBase* aWidget,
if (charMsg.message == WM_NULL) {
continue;
}
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::InitWithKeyChar(), removed char message, %s",
this, ToString(charMsg).get()));
NS_WARN_IF(charMsg.hwnd != mMsg.hwnd);
mFollowingCharMsgs.AppendElement(charMsg);
}
@ -1350,6 +1448,7 @@ NativeKey::NativeKey(nsWindowBase* aWidget,
mVirtualKeyCode = mOriginalVirtualKeyCode;
}
KeyboardLayout* keyboardLayout = KeyboardLayout::GetInstance();
mDOMKeyCode =
keyboardLayout->ConvertNativeKeyCodeToDOMKeyCode(mOriginalVirtualKeyCode);
// Be aware, keyboard utilities can change non-printable keys to printable
@ -1410,6 +1509,8 @@ NativeKey::NativeKey(nsWindowBase* aWidget,
NativeKey::~NativeKey()
{
MOZ_LOG(sNativeKeyLogger, LogLevel::Debug,
("%p NativeKey::~NativeKey(), destroyed", this));
if (mIsOverridingKeyboardLayout) {
KeyboardLayout* keyboardLayout = KeyboardLayout::GetInstance();
keyboardLayout->RestoreLayout();
@ -1611,6 +1712,10 @@ NativeKey::RemoveFollowingOddCharMessages()
"Unexpected message was removed");
continue;
}
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::RemoveFollowingOddCharMessages(), removed odd char "
"message, %s",
this, ToString(msg).get()));
mRemovedOddCharMsgs.AppendElement(msg);
}
}
@ -1811,6 +1916,19 @@ NativeKey::InitKeyEvent(WidgetKeyboardEvent& aKeyEvent,
KeyboardLayout::NotifyIdleServiceOfUserActivity();
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::InitKeyEvent(), initialized, aKeyEvent={ "
"mMessage=%s, mKeyNameIndex=%s, mKeyValue=\"%s\", mCodeNameIndex=%s, "
"mKeyCode=%s, mLocation=%s, mModifiers=%s, DefaultPrevented()=%s }",
this, ToChar(aKeyEvent.mMessage),
ToString(aKeyEvent.mKeyNameIndex).get(),
NS_ConvertUTF16toUTF8(aKeyEvent.mKeyValue).get(),
ToString(aKeyEvent.mCodeNameIndex).get(),
GetDOMKeyCodeName(aKeyEvent.mKeyCode).get(),
GetKeyLocationName(aKeyEvent.mLocation).get(),
GetModifiersName(aKeyEvent.mModifiers).get(),
GetBoolName(aKeyEvent.DefaultPrevented())));
return aKeyEvent.DefaultPrevented() ? nsEventStatus_eConsumeNoDefault :
nsEventStatus_eIgnore;
}
@ -1884,13 +2002,24 @@ NativeKey::DispatchCommandEvent(uint32_t aEventCommand) const
command = nsGkAtoms::PlayPause;
break;
default:
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::DispatchCommandEvent(), doesn't dispatch command "
"event", this));
return false;
}
WidgetCommandEvent commandEvent(true, nsGkAtoms::onAppCommand,
command, mWidget);
mWidget->InitEvent(commandEvent);
return (mWidget->DispatchWindowEvent(&commandEvent) || mWidget->Destroyed());
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::DispatchCommandEvent(), dispatching %s command event...",
this, nsAtomCString(command).get()));
bool ok = mWidget->DispatchWindowEvent(&commandEvent) || mWidget->Destroyed();
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::DispatchCommandEvent(), dispatched command event, "
"result=%s, mWidget->Destroyed()=%s",
this, GetBoolName(ok), GetBoolName(mWidget->Destroyed())));
return ok;
}
bool
@ -1925,21 +2054,40 @@ NativeKey::HandleAppCommandMessage() const
if (dispatchKeyEvent) {
nsresult rv = mDispatcher->BeginNativeInputTransaction();
if (NS_WARN_IF(NS_FAILED(rv))) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Error,
("%p NativeKey::HandleAppCommandMessage(), FAILED due to "
"BeginNativeInputTransaction() failure", this));
return true;
}
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleAppCommandMessage(), initializing keydown "
"event...", this));
WidgetKeyboardEvent keydownEvent(true, eKeyDown, mWidget);
nsEventStatus status = InitKeyEvent(keydownEvent, mModKeyState, &mMsg);
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleAppCommandMessage(), tries to dispatch "
"keydown event...", this));
// NOTE: If the keydown event is consumed by web contents, we shouldn't
// continue to handle the command.
if (!mDispatcher->DispatchKeyboardEvent(eKeyDown, keydownEvent, status,
const_cast<NativeKey*>(this))) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleAppCommandMessage(), keydown event isn't "
"dispatched", this));
// If keyboard event wasn't fired, there must be composition.
// So, we don't need to dispatch a command event.
return true;
}
consumed = status == nsEventStatus_eConsumeNoDefault;
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleAppCommandMessage(), keydown event was "
"dispatched, consumed=%s",
this, GetBoolName(consumed)));
sDispatchedKeyOfAppCommand = mVirtualKeyCode;
if (mWidget->Destroyed()) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleAppCommandMessage(), keydown event caused "
"destroying the widget", this));
return true;
}
}
@ -1998,12 +2146,26 @@ NativeKey::HandleAppCommandMessage() const
if (contentCommandMessage) {
WidgetContentCommandEvent contentCommandEvent(true, contentCommandMessage,
mWidget);
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleAppCommandMessage(), dispatching %s event...",
this, ToChar(contentCommandMessage)));
mWidget->DispatchWindowEvent(&contentCommandEvent);
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleAppCommandMessage(), dispatched %s event",
this, ToChar(contentCommandMessage)));
consumed = true;
}
if (mWidget->Destroyed()) {
return true;
if (mWidget->Destroyed()) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleAppCommandMessage(), %s event caused "
"destroying the widget",
this, ToChar(contentCommandMessage)));
return true;
}
} else {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleAppCommandMessage(), doesn't dispatch content "
"command event", this));
}
}
@ -2012,15 +2174,30 @@ NativeKey::HandleAppCommandMessage() const
if (dispatchKeyEvent && !mVirtualKeyCode) {
nsresult rv = mDispatcher->BeginNativeInputTransaction();
if (NS_WARN_IF(NS_FAILED(rv))) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Error,
("%p NativeKey::HandleAppCommandMessage(), FAILED due to "
"BeginNativeInputTransaction() failure", this));
return true;
}
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleAppCommandMessage(), initializing keyup "
"event...", this));
WidgetKeyboardEvent keyupEvent(true, eKeyUp, mWidget);
nsEventStatus status = InitKeyEvent(keyupEvent, mModKeyState, &mMsg);
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleAppCommandMessage(), dispatching keyup event...",
this));
// NOTE: Ignore if the keyup event is consumed because keyup event
// represents just a physical key event state change.
mDispatcher->DispatchKeyboardEvent(eKeyUp, keyupEvent, status,
const_cast<NativeKey*>(this));
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleAppCommandMessage(), dispatched keyup event",
this));
if (mWidget->Destroyed()) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleAppCommandMessage(), %s event caused "
"destroying the widget", this));
return true;
}
}
@ -2042,6 +2219,10 @@ NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const
// The multimedia key event has already been dispatch from
// HandleAppCommandMessage().
sDispatchedKeyOfAppCommand = 0;
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), doesn't dispatch keydown "
"event due to already dispatched from HandleAppCommandMessage(), ",
this));
return true;
}
@ -2051,19 +2232,33 @@ NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const
// Ignore [shift+]alt+space so the OS can handle it.
if (mModKeyState.IsAlt() && !mModKeyState.IsControl() &&
mVirtualKeyCode == VK_SPACE) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), doesn't dispatch keydown "
"event due to Alt+Space", this));
return false;
}
nsresult rv = mDispatcher->BeginNativeInputTransaction();
if (NS_WARN_IF(NS_FAILED(rv))) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Error,
("%p NativeKey::HandleKeyDownMessage(), FAILED due to "
"BeginNativeInputTransaction() failure", this));
return true;
}
bool isIMEEnabled = WinUtils::IsIMEEnabled(mWidget->GetInputContext());
MOZ_LOG(sNativeKeyLogger, LogLevel::Debug,
("%p NativeKey::HandleKeyDownMessage(), initializing keydown "
"event...", this));
EventMessage keyDownMessage =
IsKeyMessageOnPlugin() ? eKeyDownOnPlugin : eKeyDown;
WidgetKeyboardEvent keydownEvent(true, keyDownMessage, mWidget);
nsEventStatus status = InitKeyEvent(keydownEvent, mModKeyState, &mMsg);
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), dispatching keydown event...",
this));
bool dispatched =
mDispatcher->DispatchKeyboardEvent(keyDownMessage, keydownEvent, status,
const_cast<NativeKey*>(this));
@ -2073,6 +2268,9 @@ NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const
if (!dispatched) {
// If the keydown event wasn't fired, there must be composition.
// we don't need to do anything anymore.
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), doesn't dispatch keypress "
"event(s) because keydown event isn't dispatched actually", this));
return false;
}
defaultPrevented = status == nsEventStatus_eConsumeNoDefault;
@ -2080,13 +2278,26 @@ NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const
// We don't need to handle key messages on plugin for eKeyPress since
// eKeyDownOnPlugin is handled as both eKeyDown and eKeyPress.
if (IsKeyMessageOnPlugin()) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), doesn't dispatch keypress "
"event(s) because it's a keydown message on windowed plugin, "
"defaultPrevented=%s",
this, GetBoolName(defaultPrevented)));
return defaultPrevented;
}
if (mWidget->Destroyed() || IsFocusedWindowChanged()) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), keydown event caused "
"destroying the widget", this));
return true;
}
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), dispatched keydown event, "
"dispatched=%s, defaultPrevented=%s",
this, GetBoolName(dispatched), GetBoolName(defaultPrevented)));
// If IMC wasn't associated to the window but is associated it now (i.e.,
// focus is moved from a non-editable editor to an editor by keydown
// event handler), WM_CHAR and WM_SYSCHAR shouldn't cause first character
@ -2114,14 +2325,26 @@ NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const
RedirectedKeyDownMessageManager::WillRedirect(mMsg, defaultPrevented);
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), redirecting %s...",
this, ToString(mMsg).get()));
::SendInput(1, &keyinput, sizeof(keyinput));
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), redirected %s",
this, ToString(mMsg).get()));
// Return here. We shouldn't dispatch keypress event for this WM_KEYDOWN.
// If it's needed, it will be dispatched after next (redirected)
// WM_KEYDOWN.
return true;
}
} else {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), received a redirected %s",
this, ToString(mMsg).get()));
defaultPrevented = RedirectedKeyDownMessageManager::DefaultPrevented();
// If this is redirected keydown message, we have dispatched the keydown
// event already.
@ -2134,10 +2357,18 @@ NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const
// If the key was processed by IME, we shouldn't dispatch keypress event.
if (mOriginalVirtualKeyCode == VK_PROCESSKEY) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), not dispatching keypress "
"event because the key was already handled by IME, defaultPrevented=%s",
this, GetBoolName(defaultPrevented)));
return defaultPrevented;
}
if (defaultPrevented) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), not dispatching keypress "
"event because preceding keydown event was consumed",
this));
MaybeDispatchPluginEventsForRemovedCharMessages();
return true;
}
@ -2145,6 +2376,9 @@ NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const
// If we won't be getting a WM_CHAR, WM_SYSCHAR or WM_DEADCHAR, synthesize a
// keypress for almost all keys
if (NeedsToHandleWithoutFollowingCharMessages()) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), tries to be dispatching "
"keypress events...", this));
return (MaybeDispatchPluginEventsForRemovedCharMessages() ||
DispatchKeyPressEventsWithoutCharMessage());
}
@ -2152,19 +2386,38 @@ NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const
if (!mFollowingCharMsgs.IsEmpty()) {
bool consumed = false;
for (size_t i = 0; i < mFollowingCharMsgs.Length(); ++i) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), stopped dispatching "
"keypress events for remaining char messages, consumed=%s, "
"mFollowingCharMsgs[%u]=%s, mMsg=%s, "
"mFocusedWndBeforeDispatch=0x%p, ::GetFocus()=0x%p",
this, GetBoolName(consumed), i,
ToString(mFollowingCharMsgs[i]).get(),
ToString(mMsg).get(), mFocusedWndBeforeDispatch, ::GetFocus()));
consumed =
DispatchKeyPressEventForFollowingCharMessage(mFollowingCharMsgs[i]) ||
consumed;
if (mWidget->Destroyed() || IsFocusedWindowChanged()) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), %s event caused "
"destroying the widget", this));
return true;
}
}
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), handled all following char "
"messages, consumed=%s",
this, GetBoolName(consumed)));
return consumed;
}
// If WM_KEYDOWN of VK_PACKET isn't followed by WM_CHAR, we don't need to
// dispatch keypress events.
if (mVirtualKeyCode == VK_PACKET) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), not dispatching keypress event "
"because the key is VK_PACKET and there are no char messages",
this));
return false;
}
@ -2173,13 +2426,24 @@ NativeKey::HandleKeyDownMessage(bool* aEventDispatched) const
// If this is simple KeyDown event but next message is not WM_CHAR,
// this event may not input text, so we should ignore this event.
// See bug 314130.
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), not dispatching keypress event "
"because the key event is simple printable key's event but not followed "
"by char messages", this));
return false;
}
if (mIsDeadKey) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), not dispatching keypress event "
"because the key is a dead key and not followed by char messages",
this));
return false;
}
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyDownMessage(), tries to be dispatching "
"keypress events due to no following char messages...", this));
return DispatchKeyPressEventsWithoutCharMessage();
}
@ -2197,12 +2461,18 @@ NativeKey::HandleCharMessage(const MSG& aCharMsg,
// Alt+Space key is handled by OS, we shouldn't touch it.
if (mModKeyState.IsAlt() && !mModKeyState.IsControl() &&
mVirtualKeyCode == VK_SPACE) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleCharMessage(), doesn't dispatch keypress "
"event due to Alt+Space", this));
return false;
}
// Bug 818235: Ignore Ctrl+Enter.
if (!mModKeyState.IsAlt() && mModKeyState.IsControl() &&
mVirtualKeyCode == VK_RETURN) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleCharMessage(), doesn't dispatch keypress "
"event due to Ctrl+Enter", this));
return false;
}
@ -2225,9 +2495,16 @@ NativeKey::HandleCharMessage(const MSG& aCharMsg,
}
nsresult rv = mDispatcher->BeginNativeInputTransaction();
if (NS_WARN_IF(NS_FAILED(rv))) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Error,
("%p NativeKey::HandleCharMessage(), FAILED due to "
"BeginNativeInputTransaction() failure", this));
return true;
}
MOZ_LOG(sNativeKeyLogger, LogLevel::Debug,
("%p NativeKey::HandleCharMessage(), initializing keypress "
"event...", this));
// When AltGr (Alt+Ctrl) is pressed, that causes normal text input.
// At this time, if either alt or ctrl flag is set, EditorBase ignores the
// keypress event. For avoiding this issue, we should remove ctrl and alt
@ -2235,13 +2512,27 @@ NativeKey::HandleCharMessage(const MSG& aCharMsg,
ModifierKeyState modKeyState(mModKeyState);
modKeyState.Unset(MODIFIER_ALT | MODIFIER_CONTROL);
nsEventStatus status = InitKeyEvent(keypressEvent, modKeyState, &aCharMsg);
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleCharMessage(), dispatching keypress event...",
this));
bool dispatched =
mDispatcher->MaybeDispatchKeypressEvents(keypressEvent, status,
const_cast<NativeKey*>(this));
if (aEventDispatched) {
*aEventDispatched = dispatched;
}
return status == nsEventStatus_eConsumeNoDefault;
if (mWidget->Destroyed()) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleCharMessage(), keypress event caused "
"destroying the widget", this));
return true;
}
bool consumed = status == nsEventStatus_eConsumeNoDefault;
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleCharMessage(), dispatched keypress event, "
"dispatched=%s, consumed=%s",
this, GetBoolName(dispatched), GetBoolName(consumed)));
return consumed;
}
// XXX It seems that following code was implemented for shortcut key
@ -2256,17 +2547,35 @@ NativeKey::HandleCharMessage(const MSG& aCharMsg,
IsControlChar(static_cast<char16_t>(aCharMsg.wParam))) {
// Bug 16486: Need to account for shift here.
uniChar = aCharMsg.wParam - 1 + (mModKeyState.IsShift() ? 'A' : 'a');
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleCharMessage(), computing charCode for ASCII "
"control characters which are inputted with Ctrl key, uniChar=%s",
this, GetCharacterCodeName(uniChar).get()));
} else if (mModKeyState.IsControl() && aCharMsg.wParam <= 0x1F) {
// XXX Looks like that this block won't run since the condition is
// included in the first |if|'s condition.
// Bug 50255: <ctrl><[> and <ctrl><]> are not being processed.
// also fixes ctrl+\ (x1c), ctrl+^ (x1e) and ctrl+_ (x1f)
// for some reason the keypress handler need to have the uniChar code set
// with the addition of a upper case A not the lower case.
uniChar = aCharMsg.wParam - 1 + 'A';
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleCharMessage(), computing charCode for ASCII "
"control characters which are inputted with Ctrl key, uniChar=%s",
this, GetCharacterCodeName(uniChar).get()));
} else if (IsControlChar(static_cast<char16_t>(aCharMsg.wParam)) ||
(aCharMsg.wParam == U_EQUAL && mModKeyState.IsControl())) {
uniChar = 0;
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleCharMessage(), setting charCode to 0 because "
"the character is a control character without Ctrl key or Ctrl+=",
this));
} else {
uniChar = aCharMsg.wParam;
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleCharMessage(), deciding to use given charCode, "
"uniChar=%s",
this, GetCharacterCodeName(uniChar).get()));
}
// Bug 50255 and Bug 351310: Keep the characters unshifted for shortcuts and
@ -2277,8 +2586,14 @@ NativeKey::HandleCharMessage(const MSG& aCharMsg,
mVirtualKeyCode : mModKeyState.IsShift() ?
ComputeUnicharFromScanCode() : 0;
// Ignore diacritics (top bit set) and key mapping errors (char code 0)
if (static_cast<int32_t>(unshiftedCharCode) > 0) {
if (uniChar != unshiftedCharCode &&
static_cast<int32_t>(unshiftedCharCode) > 0) {
uniChar = unshiftedCharCode;
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleCharMessage(), adjusting computed charCode "
"because unshifted charCode is better, uniChar=%s, mModKeyState=%s",
this, GetCharacterCodeName(uniChar).get(),
ToString(mModKeyState).get()));
}
}
@ -2286,28 +2601,55 @@ NativeKey::HandleCharMessage(const MSG& aCharMsg,
// bug 178110. When pressing (alt|ctrl)+char, the char must be lowercase
// unless shift is pressed too.
if (!mModKeyState.IsShift() &&
(mModKeyState.IsAlt() || mModKeyState.IsControl())) {
(mModKeyState.IsAlt() || mModKeyState.IsControl()) &&
uniChar != towlower(uniChar)) {
uniChar = towlower(uniChar);
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleCharMessage(), making computed charCode "
"lower case character because Shift isn't pressed but Ctrl or Alt is "
"pressed, uniChar=%s, mModKeyState=%s",
this, GetCharacterCodeName(uniChar).get(),
ToString(mModKeyState).get()));
}
nsresult rv = mDispatcher->BeginNativeInputTransaction();
if (NS_WARN_IF(NS_FAILED(rv))) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Error,
("%p NativeKey::HandleCharMessage(), FAILED due to "
"BeginNativeInputTransaction() failure", this));
return true;
}
MOZ_LOG(sNativeKeyLogger, LogLevel::Debug,
("%p NativeKey::HandleCharMessage(), initializing keypress "
"event after some hacks...", this));
WidgetKeyboardEvent keypressEvent(true, eKeyPress, mWidget);
keypressEvent.mCharCode = uniChar;
if (!keypressEvent.mCharCode) {
keypressEvent.mKeyCode = mDOMKeyCode;
}
nsEventStatus status = InitKeyEvent(keypressEvent, mModKeyState, &aCharMsg);
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleCharMessage(), dispatching keypress event with "
"some hacks...", this));
bool dispatched =
mDispatcher->MaybeDispatchKeypressEvents(keypressEvent, status,
const_cast<NativeKey*>(this));
if (aEventDispatched) {
*aEventDispatched = dispatched;
}
return status == nsEventStatus_eConsumeNoDefault;
if (mWidget->Destroyed()) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleCharMessage(), keypress event caused "
"destroying the widget", this));
return true;
}
bool consumed = status == nsEventStatus_eConsumeNoDefault;
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleCharMessage(), dispatched keypress event with "
"some hacks, dispatched=%s, consumed=%s",
this, GetBoolName(dispatched), GetBoolName(consumed)));
return consumed;
}
bool
@ -2322,24 +2664,47 @@ NativeKey::HandleKeyUpMessage(bool* aEventDispatched) const
// Ignore [shift+]alt+space so the OS can handle it.
if (mModKeyState.IsAlt() && !mModKeyState.IsControl() &&
mVirtualKeyCode == VK_SPACE) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyUpMessage(), doesn't dispatch keyup "
"event due to Alt+Space", this));
return false;
}
nsresult rv = mDispatcher->BeginNativeInputTransaction();
if (NS_WARN_IF(NS_FAILED(rv))) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Error,
("%p NativeKey::HandleKeyUpMessage(), FAILED due to "
"BeginNativeInputTransaction() failure", this));
return true;
}
MOZ_LOG(sNativeKeyLogger, LogLevel::Debug,
("%p NativeKey::HandleKeyUpMessage(), initializing keyup event...",
this));
EventMessage keyUpMessage = IsKeyMessageOnPlugin() ? eKeyUpOnPlugin : eKeyUp;
WidgetKeyboardEvent keyupEvent(true, keyUpMessage, mWidget);
nsEventStatus status = InitKeyEvent(keyupEvent, mModKeyState, &mMsg);
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyUpMessage(), dispatching keyup event...",
this));
bool dispatched =
mDispatcher->DispatchKeyboardEvent(keyUpMessage, keyupEvent, status,
const_cast<NativeKey*>(this));
if (aEventDispatched) {
*aEventDispatched = dispatched;
}
return status == nsEventStatus_eConsumeNoDefault;
if (mWidget->Destroyed()) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyUpMessage(), keyup event caused "
"destroying the widget", this));
return true;
}
bool consumed = status == nsEventStatus_eConsumeNoDefault;
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::HandleKeyUpMessage(), dispatched keyup event, "
"dispatched=%s, consumed=%s",
this, GetBoolName(dispatched), GetBoolName(consumed)));
return consumed;
}
bool
@ -2481,6 +2846,9 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) const
if (!WinUtils::PeekMessage(&nextKeyMsg, mMsg.hwnd, WM_KEYFIRST, WM_KEYLAST,
PM_NOREMOVE | PM_NOYIELD) ||
!IsCharMessage(nextKeyMsg)) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Verbose,
("%p NativeKey::GetFollowingCharMessage(), there are no char messages",
this));
return false;
}
@ -2501,6 +2869,11 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) const
if (!WinUtils::PeekMessage(&nextKeyMsgInAllWindows, 0,
WM_KEYFIRST, WM_KEYLAST,
PM_NOREMOVE | PM_NOYIELD)) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Warning,
("%p NativeKey::GetFollowingCharMessage(), WARNING, failed to "
"remove a char message, but it's already gone from all message "
"queues, nextKeyMsg=%s",
this, ToString(nextKeyMsg).get()));
return true;
}
if (MayBeSameCharMessage(nextKeyMsgInAllWindows, nextKeyMsg)) {
@ -2508,6 +2881,11 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) const
// thread.
if (nextKeyMsgInAllWindows.hwnd != mMsg.hwnd) {
aCharMsg = nextKeyMsgInAllWindows;
MOZ_LOG(sNativeKeyLogger, LogLevel::Warning,
("%p NativeKey::GetFollowingCharMessage(), WARNING, failed to "
"remove a char message, but found in another message queue, "
"nextKeyMsgInAllWindows=%s",
this, ToString(nextKeyMsgInAllWindows).get()));
return true;
}
// The found char message still in the queue, but PeekMessage() failed
@ -2516,10 +2894,19 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) const
// Try to remove the char message with GetMessage() again.
if (WinUtils::GetMessage(&removedMsg, mMsg.hwnd,
nextKeyMsg.message, nextKeyMsg.message)) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Warning,
("%p NativeKey::GetFollowingCharMessage(), WARNING, failed to "
"remove a char message, but succeeded with GetMessage(), "
"removedMsg=%s",
this, ToString(removedMsg).get()));
// Cancel to crash, but we need to check the removed message value.
doCrash = false;
}
}
MOZ_LOG(sNativeKeyLogger, LogLevel::Error,
("%p NativeKey::GetFollowingCharMessage(), FAILED, lost target "
"message to remove, nextKeyMsg=%s",
this, ToString(nextKeyMsg).get()));
}
if (doCrash) {
@ -2552,6 +2939,11 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) const
// Retry for the strange case.
if (removedMsg.message == WM_NULL) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Warning,
("%p NativeKey::GetFollowingCharMessage(), WARNING, failed to "
"remove a char message, instead, removed WM_NULL message, ",
"removedMsg=%s",
this, ToString(removedMsg).get()));
continue;
}
@ -2559,6 +2951,11 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) const
// wParam becomes 0, that means that the key event shouldn't cause text
// input. So, let's ignore the strange char message.
if (removedMsg.message == nextKeyMsg.message && !removedMsg.wParam) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Warning,
("%p NativeKey::GetFollowingCharMessage(), WARNING, succeeded to "
"remove a char message, but the removed message's wParam is 0, "
"removedMsg=%s",
this, ToString(removedMsg).get()));
return false;
}
@ -2566,6 +2963,11 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) const
// in lParam may be changed from 0 to something. The changed value
// is different from the scan code of handling keydown message.
if (!MayBeSameCharMessage(removedMsg, nextKeyMsg)) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Error,
("%p NativeKey::GetFollowingCharMessage(), FAILED, removed message "
"is really different from what we have already found, removedMsg=%s, "
"nextKeyMsg=%s",
this, ToString(removedMsg).get(), ToString(nextKeyMsg).get()));
#ifdef MOZ_CRASHREPORTER
nsPrintfCString info("\nPeekMessage() removed unexpcted char message! "
"\nHandling message: %s, InSendMessageEx()=%s, "
@ -2607,8 +3009,16 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) const
}
aCharMsg = removedMsg;
MOZ_LOG(sNativeKeyLogger, LogLevel::Verbose,
("%p NativeKey::GetFollowingCharMessage(), succeeded to retrieve next "
"char message, aCharMsg=%s",
this, ToString(aCharMsg).get()));
return true;
}
MOZ_LOG(sNativeKeyLogger, LogLevel::Error,
("%p NativeKey::GetFollowingCharMessage(), FAILED, removed messages "
"are all WM_NULL, nextKeyMsg=%s",
this, ToString(nextKeyMsg).get()));
#ifdef MOZ_CRASHREPORTER
nsPrintfCString info("\nWe lost following char message! "
"\nHandling message: %s, InSendMessageEx()=%s, \n"
@ -2631,12 +3041,25 @@ NativeKey::MaybeDispatchPluginEventsForRemovedCharMessages() const
for (size_t i = 0;
i < mFollowingCharMsgs.Length() && mWidget->ShouldDispatchPluginEvent();
++i) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::MaybeDispatchPluginEventsForRemovedCharMessages(), "
"dispatching %uth plugin event for %s...",
this, i + 1, ToString(mFollowingCharMsgs[i]).get()));
MOZ_RELEASE_ASSERT(!mWidget->Destroyed(),
"NativeKey tries to dispatch a plugin event on destroyed widget");
mWidget->DispatchPluginEvent(mFollowingCharMsgs[i]);
if (mWidget->Destroyed() || IsFocusedWindowChanged()) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::MaybeDispatchPluginEventsForRemovedCharMessages(), "
"%uth plugin event caused %s",
this, i + 1, mWidget->Destroyed() ? "destroying the widget" :
"focus change"));
return true;
}
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::MaybeDispatchPluginEventsForRemovedCharMessages(), "
"dispatched %uth plugin event",
this, i + 1));
}
// Dispatch odd char messages which are caused by ATOK or WXG (both of them
@ -2644,12 +3067,25 @@ NativeKey::MaybeDispatchPluginEventsForRemovedCharMessages() const
for (size_t i = 0;
i < mRemovedOddCharMsgs.Length() && mWidget->ShouldDispatchPluginEvent();
++i) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::MaybeDispatchPluginEventsForRemovedCharMessages(), "
"dispatching %uth plugin event for odd char message, %s...",
this, i + 1, ToString(mFollowingCharMsgs[i]).get()));
MOZ_RELEASE_ASSERT(!mWidget->Destroyed(),
"NativeKey tries to dispatch a plugin event on destroyed widget");
mWidget->DispatchPluginEvent(mRemovedOddCharMsgs[i]);
if (mWidget->Destroyed() || IsFocusedWindowChanged()) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::MaybeDispatchPluginEventsForRemovedCharMessages(), "
"%uth plugin event for odd char message caused %s",
this, i + 1, mWidget->Destroyed() ? "destroying the widget" :
"focus change"));
return true;
}
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::MaybeDispatchPluginEventsForRemovedCharMessages(), "
"dispatched %uth plugin event for odd char message",
this, i + 1));
}
return false;
@ -2745,6 +3181,9 @@ NativeKey::DispatchKeyPressEventsWithoutCharMessage() const
nsresult rv = mDispatcher->BeginNativeInputTransaction();
if (NS_WARN_IF(NS_FAILED(rv))) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Error,
("%p NativeKey::DispatchKeyPressEventsWithoutCharMessage(), FAILED due "
"to BeginNativeInputTransaction() failure", this));
return true;
}
@ -2753,10 +3192,28 @@ NativeKey::DispatchKeyPressEventsWithoutCharMessage() const
mShiftedString.IsEmpty() && mUnshiftedString.IsEmpty()) {
keypressEvent.mKeyCode = mDOMKeyCode;
}
MOZ_LOG(sNativeKeyLogger, LogLevel::Debug,
("%p NativeKey::DispatchKeyPressEventsWithoutCharMessage(), initializing "
"keypress event...", this));
nsEventStatus status = InitKeyEvent(keypressEvent, mModKeyState);
mDispatcher->MaybeDispatchKeypressEvents(keypressEvent, status,
const_cast<NativeKey*>(this));
return status == nsEventStatus_eConsumeNoDefault;
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::DispatchKeyPressEventsWithoutCharMessage(), dispatching "
"keypress event(s)...", this));
bool dispatched =
mDispatcher->MaybeDispatchKeypressEvents(keypressEvent, status,
const_cast<NativeKey*>(this));
if (mWidget->Destroyed()) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::DispatchKeyPressEventsWithoutCharMessage(), "
"keypress event(s) caused destroying the widget", this));
return true;
}
bool consumed = status == nsEventStatus_eConsumeNoDefault;
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::DispatchKeyPressEventsWithoutCharMessage(), dispatched "
"keypress event(s), dispatched=%s, consumed=%s",
this, GetBoolName(dispatched), GetBoolName(consumed)));
return consumed;
}
void
@ -2770,6 +3227,10 @@ NativeKey::WillDispatchKeyboardEvent(WidgetKeyboardEvent& aKeyboardEvent,
uint32_t skipShiftedChars = longestLength - mShiftedString.mLength;
uint32_t skipUnshiftedChars = longestLength - mUnshiftedString.mLength;
if (aIndex >= longestLength) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::WillDispatchKeyboardEvent(), does nothing for %uth "
"%s event",
this, aIndex + 1, ToChar(aKeyboardEvent.mMessage)));
return;
}
@ -2807,6 +3268,10 @@ NativeKey::WillDispatchKeyboardEvent(WidgetKeyboardEvent& aKeyboardEvent,
modKeyState.Set(
mInputtingStringAndModifiers.mModifiers[aIndex - skipUniChars]);
modKeyState.InitInputEvent(aKeyboardEvent);
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::WillDispatchKeyboardEvent(), "
"setting %uth modifier state to %s",
this, aIndex + 1, ToString(modKeyState).get()));
}
uint16_t uniChar =
mInputtingStringAndModifiers.mChars[aIndex - skipUniChars];
@ -2816,6 +3281,10 @@ NativeKey::WillDispatchKeyboardEvent(WidgetKeyboardEvent& aKeyboardEvent,
// compatibility rather than inputting character without the modifiers.
// Therefore, we need to modify mCharCode value here.
aKeyboardEvent.SetCharCode(uniChar);
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::WillDispatchKeyboardEvent(), "
"setting %uth charCode to %s",
this, aIndex + 1, GetCharacterCodeName(uniChar).get()));
}
// We need to append alterntaive charCode values:
@ -2923,17 +3392,35 @@ NativeKey::DispatchKeyPressEventForFollowingCharMessage(
if (IsDeadCharMessage(aCharMsg)) {
if (!mWidget->PluginHasFocus()) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::DispatchKeyPressEventForFollowingCharMessage(), "
"plugin doesn't have focus", this));
return false;
}
return (mWidget->DispatchPluginEvent(aCharMsg) || mWidget->Destroyed());
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::DispatchKeyPressEventForFollowingCharMessage(), "
"dispatching plugin event...", this));
bool ok = mWidget->DispatchPluginEvent(aCharMsg) || mWidget->Destroyed();
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::DispatchKeyPressEventForFollowingCharMessage(), "
"dispatched plugin event, result=%s, mWidget->Destroyed()=%s",
this, GetBoolName(ok), GetBoolName(mWidget->Destroyed())));
}
bool defaultPrevented = HandleCharMessage(aCharMsg);
// If a syschar keypress wasn't processed, Windows may want to
// handle it to activate a native menu.
if (!defaultPrevented && IsSysCharMessage(aCharMsg)) {
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::DispatchKeyPressEventForFollowingCharMessage(), "
"calling DefWindowProcW(aCharMsg=%s)...",
this, ToString(aCharMsg).get()));
::DefWindowProcW(aCharMsg.hwnd, aCharMsg.message,
aCharMsg.wParam, aCharMsg.lParam);
MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
("%p NativeKey::DispatchKeyPressEventForFollowingCharMessage(), "
"called DefWindowProcW(aCharMsg=%s)",
this, ToString(aCharMsg).get()));
}
return defaultPrevented;
}

Просмотреть файл

@ -340,6 +340,7 @@ private:
}
void InitWithAppCommand();
void InitWithKeyChar();
/**
* Returns true if the key event is caused by auto repeat.

Просмотреть файл

@ -10,6 +10,8 @@
#include "mozilla/EventForwards.h"
#include <windows.h>
class nsCString;
namespace mozilla {
namespace widget {
@ -52,6 +54,8 @@ private:
void InitMouseEvent(WidgetInputEvent& aMouseEvent) const;
};
const nsCString ToString(const ModifierKeyState& aModifierKeyState);
} // namespace widget
} // namespace mozilla