diff options
Diffstat (limited to 'widget/windows/KeyboardLayout.cpp')
-rw-r--r-- | widget/windows/KeyboardLayout.cpp | 179 |
1 files changed, 2 insertions, 177 deletions
diff --git a/widget/windows/KeyboardLayout.cpp b/widget/windows/KeyboardLayout.cpp index 11f657874..9166d97d7 100644 --- a/widget/windows/KeyboardLayout.cpp +++ b/widget/windows/KeyboardLayout.cpp @@ -13,9 +13,6 @@ #include "mozilla/WindowsVersion.h" #include "nsAlgorithm.h" -#ifdef MOZ_CRASHREPORTER -#include "nsExceptionHandler.h" -#endif #include "nsGkAtoms.h" #include "nsIDOMKeyEvent.h" #include "nsIIdleServiceInternal.h" @@ -1363,34 +1360,6 @@ NativeKey::InitWithKeyChar() break; } - if (!CanComputeVirtualKeyCodeFromScanCode()) { - // The right control key and the right alt key are extended keys. - // Therefore, we never get VK_RCONTRL and VK_RMENU for the result of - // MapVirtualKeyEx() on WinXP or WinServer2003. - // - // If VK_SHIFT, VK_CONTROL or VK_MENU key message is caused by well - // known scan code, we should decide it as Right key. Otherwise, - // decide it as Left key. - switch (mOriginalVirtualKeyCode) { - case VK_CONTROL: - mVirtualKeyCode = - mIsExtended && mScanCode == 0x1D ? VK_RCONTROL : VK_LCONTROL; - break; - case VK_MENU: - mVirtualKeyCode = - mIsExtended && mScanCode == 0x38 ? VK_RMENU : VK_LMENU; - break; - case VK_SHIFT: - // Neither left shift nor right shift is an extended key, - // let's use VK_LSHIFT for unknown mapping. - mVirtualKeyCode = VK_LSHIFT; - break; - default: - MOZ_CRASH("Unsupported mOriginalVirtualKeyCode"); - } - break; - } - NS_ASSERTION(!mVirtualKeyCode, "mVirtualKeyCode has been computed already"); @@ -1447,11 +1416,6 @@ NativeKey::InitWithKeyChar() // scancode, we cannot compute virtual keycode. I.e., with such // applications, we cannot generate proper KeyboardEvent.code value. - // We cannot compute the virtual key code from WM_CHAR message on WinXP - // if it's caused by an extended key. - if (!CanComputeVirtualKeyCodeFromScanCode()) { - break; - } mVirtualKeyCode = mOriginalVirtualKeyCode = ComputeVirtualKeyCodeFromScanCodeEx(); NS_ASSERTION(mVirtualKeyCode, "Failed to compute virtual keycode"); @@ -1869,18 +1833,6 @@ NativeKey::GetKeyLocation() const } } -bool -NativeKey::CanComputeVirtualKeyCodeFromScanCode() const -{ - // Vista or later supports ScanCodeEx. - if (IsVistaOrLater()) { - return true; - } - // Otherwise, MapVirtualKeyEx() can compute virtual keycode only with - // non-extended key. - return !mIsExtended; -} - uint8_t NativeKey::ComputeVirtualKeyCodeFromScanCode() const { @@ -1894,12 +1846,6 @@ NativeKey::ComputeVirtualKeyCodeFromScanCodeEx() const // MapVirtualKeyEx() has been improved for supporting extended keys since // Vista. When we call it for mapping a scancode of an extended key and // a virtual keycode, we need to add 0xE000 to the scancode. - // On the other hand, neither WinXP nor WinServer2003 doesn't support 0xE000. - // Therefore, we have no way to get virtual keycode from scan code of - // extended keys. - if (NS_WARN_IF(!CanComputeVirtualKeyCodeFromScanCode())) { - return 0; - } return static_cast<uint8_t>( ::MapVirtualKeyEx(GetScanCodeWithExtendedFlag(), MAPVK_VSC_TO_VK_EX, mKeyboardLayout)); @@ -1910,8 +1856,7 @@ NativeKey::ComputeScanCodeExFromVirtualKeyCode(UINT aVirtualKeyCode) const { return static_cast<uint16_t>( ::MapVirtualKeyEx(aVirtualKeyCode, - IsVistaOrLater() ? MAPVK_VK_TO_VSC_EX : - MAPVK_VK_TO_VSC, + MAPVK_VK_TO_VSC_EX, mKeyboardLayout)); } @@ -2792,42 +2737,6 @@ NativeKey::NeedsToHandleWithoutFollowingCharMessages() const return mIsPrintableKey; } -#ifdef MOZ_CRASHREPORTER - -static nsCString -GetResultOfInSendMessageEx() -{ - DWORD ret = ::InSendMessageEx(nullptr); - if (!ret) { - return NS_LITERAL_CSTRING("ISMEX_NOSEND"); - } - nsAutoCString result; - if (ret & ISMEX_CALLBACK) { - result = "ISMEX_CALLBACK"; - } - if (ret & ISMEX_NOTIFY) { - if (!result.IsEmpty()) { - result += " | "; - } - result += "ISMEX_NOTIFY"; - } - if (ret & ISMEX_REPLIED) { - if (!result.IsEmpty()) { - result += " | "; - } - result += "ISMEX_REPLIED"; - } - if (ret & ISMEX_SEND) { - if (!result.IsEmpty()) { - result += " | "; - } - result += "ISMEX_SEND"; - } - return result; -} - -#endif // #ifdef MOZ_CRASHREPORTER - bool NativeKey::MayBeSameCharMessage(const MSG& aCharMsg1, const MSG& aCharMsg2) const @@ -3071,33 +2980,6 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) } if (doCrash) { -#ifdef MOZ_CRASHREPORTER - nsPrintfCString info("\nPeekMessage() failed to remove char message! " - "\nActive keyboard layout=0x%08X (%s), " - "\nHandling message: %s, InSendMessageEx()=%s, " - "\nFound message: %s, " - "\nWM_NULL has been removed: %d, " - "\nNext key message in all windows: %s, " - "time=%d, ", - KeyboardLayout::GetActiveLayout(), - KeyboardLayout::GetActiveLayoutName().get(), - ToString(mMsg).get(), - GetResultOfInSendMessageEx().get(), - ToString(kFoundCharMsg).get(), i, - ToString(nextKeyMsgInAllWindows).get(), - nextKeyMsgInAllWindows.time); - CrashReporter::AppendAppNotesToCrashReport(info); - MSG nextMsg; - if (WinUtils::PeekMessage(&nextMsg, 0, 0, 0, - PM_NOREMOVE | PM_NOYIELD)) { - nsPrintfCString info("\nNext message in all windows: %s, time=%d", - ToString(nextMsg).get(), nextMsg.time); - CrashReporter::AppendAppNotesToCrashReport(info); - } else { - CrashReporter::AppendAppNotesToCrashReport( - NS_LITERAL_CSTRING("\nThere is no message in any window")); - } -#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("We lost the following char message"); } @@ -3216,63 +3098,12 @@ NativeKey::GetFollowingCharMessage(MSG& aCharMsg) "nextKeyMsg=%s, kFoundCharMsg=%s", this, ToString(removedMsg).get(), ToString(nextKeyMsg).get(), ToString(kFoundCharMsg).get())); -#ifdef MOZ_CRASHREPORTER - nsPrintfCString info("\nPeekMessage() removed unexpcted char message! " - "\nActive keyboard layout=0x%08X (%s), " - "\nHandling message: %s, InSendMessageEx()=%s, " - "\nFound message: %s, " - "\nRemoved message: %s, ", - KeyboardLayout::GetActiveLayout(), - KeyboardLayout::GetActiveLayoutName().get(), - ToString(mMsg).get(), - GetResultOfInSendMessageEx().get(), - ToString(kFoundCharMsg).get(), - ToString(removedMsg).get()); - CrashReporter::AppendAppNotesToCrashReport(info); - // What's the next key message? - MSG nextKeyMsgAfter; - if (WinUtils::PeekMessage(&nextKeyMsgAfter, mMsg.hwnd, - WM_KEYFIRST, WM_KEYLAST, - PM_NOREMOVE | PM_NOYIELD)) { - nsPrintfCString info("\nNext key message after unexpected char message " - "removed: %s, ", - ToString(nextKeyMsgAfter).get()); - CrashReporter::AppendAppNotesToCrashReport(info); - } else { - CrashReporter::AppendAppNotesToCrashReport( - NS_LITERAL_CSTRING("\nThere is no key message after unexpected char " - "message removed, ")); - } - // Another window has a key message? - if (WinUtils::PeekMessage(&nextKeyMsgInAllWindows, 0, - WM_KEYFIRST, WM_KEYLAST, - PM_NOREMOVE | PM_NOYIELD)) { - nsPrintfCString info("\nNext key message in all windows: %s.", - ToString(nextKeyMsgInAllWindows).get()); - CrashReporter::AppendAppNotesToCrashReport(info); - } else { - CrashReporter::AppendAppNotesToCrashReport( - NS_LITERAL_CSTRING("\nThere is no key message in any windows.")); - } -#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("PeekMessage() removed unexpected message"); } 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! " - "\nActive keyboard layout=0x%08X (%s), " - "\nHandling message: %s, InSendMessageEx()=%s, \n" - "Found message: %s, removed a lot of WM_NULL", - KeyboardLayout::GetActiveLayout(), - KeyboardLayout::GetActiveLayoutName().get(), - ToString(mMsg).get(), - GetResultOfInSendMessageEx().get(), - ToString(kFoundCharMsg).get()); - CrashReporter::AppendAppNotesToCrashReport(info); -#endif // #ifdef MOZ_CRASHREPORTER MOZ_CRASH("We lost the following char message"); return false; } @@ -4345,8 +4176,7 @@ KeyboardLayout::LoadLayout(HKL aLayout) if (MOZ_LOG_TEST(sKeyboardLayoutLogger, LogLevel::Verbose)) { static const UINT kExtendedScanCode[] = { 0x0000, 0xE000 }; - static const UINT kMapType = - IsVistaOrLater() ? MAPVK_VSC_TO_VK_EX : MAPVK_VSC_TO_VK; + static const UINT kMapType = MAPVK_VSC_TO_VK_EX; MOZ_LOG(sKeyboardLayoutLogger, LogLevel::Verbose, ("Logging virtual keycode values for scancode (0x%p)...", mKeyboardLayout)); @@ -4358,11 +4188,6 @@ KeyboardLayout::LoadLayout(HKL aLayout) MOZ_LOG(sKeyboardLayoutLogger, LogLevel::Verbose, ("0x%04X, %s", scanCode, kVirtualKeyName[virtualKeyCode])); } - // XP and Server 2003 don't support 0xE0 prefix of the scancode. - // Therefore, we don't need to continue on them. - if (!IsVistaOrLater()) { - break; - } } } } |