Bug 1306549 part.1 KeyboardLayout::InitNativeKey() should use KeyboardLayout::IsDeadKey() r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 16 Sep 2016 17:24:39 +0900
changeset 420501 52db3256c73603fd3b4b36d3b4ade14228575ac0
parent 420017 955840bfd3c20eb24dd5a01be27bdc55c489a285
child 420502 771247191a87e9388dfa1841a3aaf9a91ceb22b0
push id31215
push usermasayuki@d-toybox.com
push dateTue, 04 Oct 2016 07:44:41 +0000
reviewersm_kato
bugs1306549
milestone52.0a1
Bug 1306549 part.1 KeyboardLayout::InitNativeKey() should use KeyboardLayout::IsDeadKey() r?m_kato KeyboardLayout::InitNativeKey() is very messy because it handles a lot of cases without helper methods. It's important to make it simpler implementation for preventing regressions caused by some patches which are written with misunderstanding. So, let's rewrite the method with helper method. First, this patch make InitNativeKey() use IsDeadKey() instead of referring the table because calling IsDeadKey() is easier to understand. MozReview-Commit-ID: DtN9qoh7Gz7
widget/windows/KeyboardLayout.cpp
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -3572,16 +3572,19 @@ KeyboardLayout::ComputeScanCodeForVirtua
            ::MapVirtualKeyEx(aVirtualKeyCode, MAPVK_VK_TO_VSC, GetLayout()));
 }
 
 bool
 KeyboardLayout::IsDeadKey(uint8_t aVirtualKey,
                           const ModifierKeyState& aModKeyState) const
 {
   int32_t virtualKeyIndex = GetKeyIndex(aVirtualKey);
+
+  // XXX KeyboardLayout class doesn't support unusual keyboard layout which
+  //     maps some function keys as dead keys.
   if (virtualKeyIndex < 0) {
     return false;
   }
 
   return mVirtualKeys[virtualKeyIndex].IsDeadKey(
            VirtualKey::ModifiersToShiftState(aModKeyState.GetModifiers()));
 }
 
@@ -3648,17 +3651,17 @@ KeyboardLayout::InitNativeKey(NativeKey&
     "At handling VK_PACKET, we shouldn't refer keyboard layout");
   MOZ_ASSERT(aNativeKey.mKeyNameIndex == KEY_NAME_INDEX_USE_STRING,
     "Printable key's key name index must be KEY_NAME_INDEX_USE_STRING");
 
   bool isKeyDown = aNativeKey.IsKeyDownMessage();
   uint8_t shiftState =
     VirtualKey::ModifiersToShiftState(aModKeyState.GetModifiers());
 
-  if (mVirtualKeys[virtualKeyIndex].IsDeadKey(shiftState)) {
+  if (IsDeadKey(virtualKey, aModKeyState)) {
     if ((isKeyDown && mActiveDeadKey < 0) ||
         (!isKeyDown && mActiveDeadKey == virtualKey)) {
       //  First dead key event doesn't generate characters.
       if (isKeyDown) {
         // Dead-key state activated at keydown.
         mActiveDeadKey = virtualKey;
         mDeadKeyShiftState = shiftState;
       }