Bug 1307112 part.9 Get rid of remaining hacks for KeyboardEvent.charCode when Ctrl or Alt is pressed r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 04 Oct 2016 22:21:49 +0900
changeset 316883 99042be37c7c777ae1ef75c8e044bf4053bec8bc
parent 316882 b4b179a1d43e0d6288fee3ffa62ac8331ce11a76
child 316884 1de5e07bed6601d2647e88ed2690b3f30418d8aa
push id32935
push usermasayuki@d-toybox.com
push dateFri, 07 Oct 2016 05:19:38 +0000
treeherderautoland@1de5e07bed66 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1307112
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1307112 part.9 Get rid of remaining hacks for KeyboardEvent.charCode when Ctrl or Alt is pressed r=m_kato Current shortcut key handling is really difference from what we did before struggling with "key hell". Therefore, remaining hacks for charCode in NativeKey::HandleCharMessage() are not necessary because they are for old code. MozReview-Commit-ID: 3hvsBOiJ6VV
widget/windows/KeyboardLayout.cpp
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -2597,70 +2597,29 @@ NativeKey::HandleCharMessage(const MSG& 
     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
-  //     handling.  However, it's now handled in WM_KEYDOWN message handler.
-  //     So, this actually runs only when WM_CHAR is sent/posted without
-  //     WM_KEYDOWN.  I think that we don't need to keypress event in such
-  //     case especially for shortcut keys.
-  char16_t uniChar = static_cast<char16_t>(aCharMsg.wParam);
-
-  // Bug 50255 and Bug 351310: Keep the characters unshifted for shortcuts and
-  // accesskeys and make sure that numbers are always passed as such.
-  if (uniChar && (mModKeyState.IsControl() || mModKeyState.IsAlt())) {
-    char16_t unshiftedCharCode =
-      (mVirtualKeyCode >= '0' && mVirtualKeyCode <= '9') ?
-        mVirtualKeyCode :  mModKeyState.IsShift() ?
-                             ComputeUnicharFromScanCode() : 0;
-    // Ignore diacritics (top bit set) and key mapping errors (char code 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()));
-    }
-  }
-
-  // Bug 285161 and Bug 295095: They were caused by the initial fix for
-  // bug 178110.  When pressing (alt|ctrl)+char, the char must be lowercase
-  // unless shift is pressed too.
-  if (!mModKeyState.IsShift() &&
-      (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;
+  keypressEvent.mCharCode = static_cast<char16_t>(aCharMsg.wParam);
   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 =