Bug 900750 - part 3: Remove unnecessary ModifierKeyState argument from some methods of NativeKey and KeyboardLayout r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 01 Jun 2018 15:22:41 +0900
changeset 810604 58d29f55590e9799e29861e3ea94e5555d3c13ba
parent 810603 9f114fddcda61dba38d20e54dc4a20b0e51a8885
child 810605 39ec2dc6e9a88419938b6505e8872247823d1754
push id114050
push usermasayuki@d-toybox.com
push dateTue, 26 Jun 2018 07:59:02 +0000
reviewersm_kato
bugs900750
milestone62.0a1
Bug 900750 - part 3: Remove unnecessary ModifierKeyState argument from some methods of NativeKey and KeyboardLayout r?m_kato KeyboardLayout::InitNativeKey() takes |const ModifierKeyState&| as its argument with NativeKey reference and it calls some internal methods with the given ModifierKeyState without any changes. Additionally, its caller is only NativeKey::InitWithKeyChar() and its called with given NativeKey instance's mModKeyState. So, removing the redundant arguments from some methods makes them clearer what they compute with. So, this patch does not change any behavior. MozReview-Commit-ID: 3w9Ee7PMU05
widget/windows/KeyboardLayout.cpp
widget/windows/KeyboardLayout.h
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -1519,17 +1519,17 @@ NativeKey::InitWithKeyOrChar()
       MOZ_LOG(sNativeKeyLogger, LogLevel::Info,
         ("%p   NativeKey::InitWithKeyOrChar(), removed char message, %s",
          this, ToString(charMsg).get()));
       Unused << NS_WARN_IF(charMsg.hwnd != mMsg.hwnd);
       mFollowingCharMsgs.AppendElement(charMsg);
     }
   }
 
-  keyboardLayout->InitNativeKey(*this, mModKeyState);
+  keyboardLayout->InitNativeKey(*this);
 
   mIsDeadKey =
     (IsFollowedByDeadCharMessage() ||
      keyboardLayout->IsDeadKey(mOriginalVirtualKeyCode, mModKeyState));
   mIsPrintableKey =
     mKeyNameIndex == KEY_NAME_INDEX_USE_STRING ||
     KeyboardLayout::IsPrintableCharKey(mOriginalVirtualKeyCode);
   // The repeat count in mMsg.lParam isn't useful to check whether the event
@@ -1549,24 +1549,23 @@ NativeKey::InitWithKeyOrChar()
       ComputeInputtingStringWithKeyboardLayout();
     }
     // Remove odd char messages if there are.
     RemoveFollowingOddCharMessages();
   }
 }
 
 void
-NativeKey::InitCommittedCharsAndModifiersWithFollowingCharMessages(
-             const ModifierKeyState& aModKeyState)
+NativeKey::InitCommittedCharsAndModifiersWithFollowingCharMessages()
 {
   mCommittedCharsAndModifiers.Clear();
   // This should cause inputting text in focused editor.  However, it
   // ignores keypress events whose altKey or ctrlKey is true.
   // Therefore, we need to remove these modifier state here.
-  Modifiers modifiers = aModKeyState.GetModifiers();
+  Modifiers modifiers = mModKeyState.GetModifiers();
   if (IsFollowedByPrintableCharMessage()) {
     modifiers &= ~(MODIFIER_ALT | MODIFIER_CONTROL);
   }
   // NOTE: This method assumes that WM_CHAR and WM_SYSCHAR are never retrieved
   //       at same time.
   for (size_t i = 0; i < mFollowingCharMsgs.Length(); ++i) {
     // Ignore non-printable char messages.
     if (!IsPrintableCharOrSysCharMessage(mFollowingCharMsgs[i])) {
@@ -3835,34 +3834,33 @@ KeyboardLayout::IsSysKey(uint8_t aVirtua
   }
 
   // If the Alt key state isn't consumed, that means that the key with Alt
   // doesn't cause text input.  So, the combination is a system key.
   return !!(inputCharsAndModifiers.ModifiersAt(0) & MODIFIER_ALT);
 }
 
 void
-KeyboardLayout::InitNativeKey(NativeKey& aNativeKey,
-                              const ModifierKeyState& aModKeyState)
+KeyboardLayout::InitNativeKey(NativeKey& aNativeKey)
 {
   if (mIsPendingToRestoreKeyboardLayout) {
     LoadLayout(::GetKeyboardLayout(0));
   }
 
   // If the aNativeKey is initialized with WM_CHAR, the key information
   // should be discarded because mKeyValue should have the string to be
   // inputted.
   if (aNativeKey.mMsg.message == WM_CHAR) {
     char16_t ch = static_cast<char16_t>(aNativeKey.mMsg.wParam);
     // But don't set key value as printable key if the character is a control
     // character such as 0x0D at pressing Enter key.
     if (!NativeKey::IsControlChar(ch)) {
       aNativeKey.mKeyNameIndex = KEY_NAME_INDEX_USE_STRING;
       Modifiers modifiers =
-        aModKeyState.GetModifiers() & ~(MODIFIER_ALT | MODIFIER_CONTROL);
+        aNativeKey.GetModifiers() & ~(MODIFIER_ALT | MODIFIER_CONTROL);
       aNativeKey.mCommittedCharsAndModifiers.Append(ch, modifiers);
       return;
     }
   }
 
   // When it's followed by non-dead char message(s) for printable character(s),
   // aNativeKey should dispatch eKeyPress events for them rather than
   // information from keyboard layout because respecting WM_(SYS)CHAR messages
@@ -3871,33 +3869,32 @@ KeyboardLayout::InitNativeKey(NativeKey&
   // Or, when it was followed by non-dead char message for a printable character
   // but it's gone at removing the message from the queue, let's treat it
   // as a key inputting empty string.
   if (aNativeKey.IsFollowedByPrintableCharOrSysCharMessage() ||
       aNativeKey.mCharMessageHasGone) {
     MOZ_ASSERT(!aNativeKey.IsCharMessage(aNativeKey.mMsg));
     if (aNativeKey.IsFollowedByPrintableCharOrSysCharMessage()) {
       // Initialize mCommittedCharsAndModifiers with following char messages.
-      aNativeKey.
-        InitCommittedCharsAndModifiersWithFollowingCharMessages(aModKeyState);
+      aNativeKey.InitCommittedCharsAndModifiersWithFollowingCharMessages();
       MOZ_ASSERT(!aNativeKey.mCommittedCharsAndModifiers.IsEmpty());
 
       // Currently, we are doing a ugly hack to keypress events to cause
       // inputting character even if Ctrl or Alt key is pressed, that is, we
       // remove Ctrl and Alt modifier state from keypress event.  However, for
       // example, Ctrl+Space which causes ' ' of WM_CHAR message never causes
       // keypress event whose ctrlKey is true.  For preventing this problem,
       // we should mark as not removable if Ctrl or Alt key does not cause
       // changing inputting character.
       if (IsPrintableCharKey(aNativeKey.mOriginalVirtualKeyCode) &&
-          (aModKeyState.IsControl() ^ aModKeyState.IsAlt())) {
-        ModifierKeyState state = aModKeyState;
+          (aNativeKey.IsControl() ^ aNativeKey.IsAlt())) {
+        ModifierKeyState state = aNativeKey.ModifierKeyStateRef();
         state.Unset(MODIFIER_ALT | MODIFIER_CONTROL);
         UniCharsAndModifiers charsWithoutModifier =
-          GetUniCharsAndModifiers(aNativeKey.mOriginalVirtualKeyCode, state);
+          GetUniCharsAndModifiers(aNativeKey.GenericVirtualKeyCode(), state);
         aNativeKey.mCanIgnoreModifierStateAtKeyPress =
           !charsWithoutModifier.UniCharsEqual(
                                   aNativeKey.mCommittedCharsAndModifiers);
       }
     } else {
       aNativeKey.mCommittedCharsAndModifiers.Clear();
     }
     aNativeKey.mKeyNameIndex = KEY_NAME_INDEX_USE_STRING;
@@ -3915,17 +3912,17 @@ KeyboardLayout::InitNativeKey(NativeKey&
                  OverwriteModifiersIfBeginsWith(deadChars);
     // Finish the dead key sequence.
     DeactivateDeadKeyState();
     return;
   }
 
   // If it's a dead key, aNativeKey will be initialized by
   // MaybeInitNativeKeyAsDeadKey().
-  if (MaybeInitNativeKeyAsDeadKey(aNativeKey, aModKeyState)) {
+  if (MaybeInitNativeKeyAsDeadKey(aNativeKey)) {
     return;
   }
 
   // If the key is not a usual printable key, KeyboardLayout class assume that
   // it's not cause dead char nor printable char.  Therefore, there are nothing
   // to do here fore such keys (e.g., function keys).
   // However, this should keep dead key state even if non-printable key is
   // pressed during a dead key sequence.
@@ -3936,22 +3933,21 @@ KeyboardLayout::InitNativeKey(NativeKey&
   MOZ_ASSERT(aNativeKey.mOriginalVirtualKeyCode != VK_PACKET,
     "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");
 
   // If it's in dead key handling and the pressed key causes a composite
   // character, aNativeKey will be initialized by
   // MaybeInitNativeKeyWithCompositeChar().
-  if (MaybeInitNativeKeyWithCompositeChar(aNativeKey, aModKeyState)) {
+  if (MaybeInitNativeKeyWithCompositeChar(aNativeKey)) {
     return;
   }
 
-  UniCharsAndModifiers baseChars =
-    GetUniCharsAndModifiers(aNativeKey.mOriginalVirtualKeyCode, aModKeyState);
+  UniCharsAndModifiers baseChars = GetUniCharsAndModifiers(aNativeKey);
 
   // If the key press isn't related to any dead keys, initialize aNativeKey
   // with the characters which should be caused by the key.
   if (!IsInDeadKeySequence()) {
     aNativeKey.mCommittedCharsAndModifiers = baseChars;
     return;
   }
 
@@ -3961,106 +3957,99 @@ KeyboardLayout::InitNativeKey(NativeKey&
   UniCharsAndModifiers deadChars = GetDeadUniCharsAndModifiers();
   aNativeKey.mCommittedCharsAndModifiers = deadChars + baseChars;
   if (aNativeKey.IsKeyDownMessage()) {
     DeactivateDeadKeyState();
   }
 }
 
 bool
-KeyboardLayout::MaybeInitNativeKeyAsDeadKey(
-                  NativeKey& aNativeKey,
-                  const ModifierKeyState& aModKeyState)
+KeyboardLayout::MaybeInitNativeKeyAsDeadKey(NativeKey& aNativeKey)
 {
   // Only when it's not in dead key sequence, we can trust IsDeadKey() result.
-  if (!IsInDeadKeySequence() &&
-      !IsDeadKey(aNativeKey.mOriginalVirtualKeyCode, aModKeyState)) {
+  if (!IsInDeadKeySequence() && !IsDeadKey(aNativeKey)) {
     return false;
   }
 
   // When keydown message is followed by a dead char message, it should be
   // initialized as dead key.
   bool isDeadKeyDownEvent =
     aNativeKey.IsKeyDownMessage() &&
     aNativeKey.IsFollowedByDeadCharMessage();
 
   // When keyup message is received, let's check if it's one of preceding
   // dead keys because keydown message order and keyup message order may be
   // different.
   bool isDeadKeyUpEvent =
     !aNativeKey.IsKeyDownMessage() &&
-    mActiveDeadKeys.Contains(aNativeKey.mOriginalVirtualKeyCode);
+    mActiveDeadKeys.Contains(aNativeKey.GenericVirtualKeyCode());
 
   if (isDeadKeyDownEvent || isDeadKeyUpEvent) {
-    ActivateDeadKeyState(aNativeKey, aModKeyState);
+    ActivateDeadKeyState(aNativeKey);
     // Any dead key events don't generate characters.  So, a dead key should
     // cause only keydown event and keyup event whose KeyboardEvent.key
     // values are "Dead".
     aNativeKey.mCommittedCharsAndModifiers.Clear();
     aNativeKey.mKeyNameIndex = KEY_NAME_INDEX_Dead;
     return true;
   }
 
   // At keydown message handling, we need to forget the first dead key
   // because there is no guarantee coming WM_KEYUP for the second dead
   // key before next WM_KEYDOWN.  E.g., due to auto key repeat or pressing
   // another dead key before releasing current key.  Therefore, we can
   // set only a character for current key for keyup event.
   if (!IsInDeadKeySequence()) {
     aNativeKey.mCommittedCharsAndModifiers =
-      GetUniCharsAndModifiers(aNativeKey.mOriginalVirtualKeyCode, aModKeyState);
+      GetUniCharsAndModifiers(aNativeKey);
     return true;
   }
 
   // When non-printable key event comes during a dead key sequence, that must
   // be a modifier key event.  So, such events shouldn't be handled as a part
   // of the dead key sequence.
-  if (!IsDeadKey(aNativeKey.mOriginalVirtualKeyCode, aModKeyState)) {
+  if (!IsDeadKey(aNativeKey)) {
     return false;
   }
 
   // FYI: Following code may run when the user doesn't input text actually
   //      but the key sequence is a dead key sequence.  For example,
   //      ` -> Ctrl+` with Spanish keyboard layout.  Let's keep using this
   //      complicated code for now because this runs really rarely.
 
   // Dead key followed by another dead key may cause a composed character
   // (e.g., "Russian - Mnemonic" keyboard layout's 's' -> 'c').
-  if (MaybeInitNativeKeyWithCompositeChar(aNativeKey, aModKeyState)) {
+  if (MaybeInitNativeKeyWithCompositeChar(aNativeKey)) {
     return true;
   }
 
   // Otherwise, dead key followed by another dead key causes inputting both
   // character.
   UniCharsAndModifiers prevDeadChars = GetDeadUniCharsAndModifiers();
-  UniCharsAndModifiers newChars =
-    GetUniCharsAndModifiers(aNativeKey.mOriginalVirtualKeyCode, aModKeyState);
+  UniCharsAndModifiers newChars = GetUniCharsAndModifiers(aNativeKey);
   // But keypress events should be fired for each committed character.
   aNativeKey.mCommittedCharsAndModifiers = prevDeadChars + newChars;
   if (aNativeKey.IsKeyDownMessage()) {
     DeactivateDeadKeyState();
   }
   return true;
 }
 
 bool
-KeyboardLayout::MaybeInitNativeKeyWithCompositeChar(
-                  NativeKey& aNativeKey,
-                  const ModifierKeyState& aModKeyState)
+KeyboardLayout::MaybeInitNativeKeyWithCompositeChar(NativeKey& aNativeKey)
 {
   if (!IsInDeadKeySequence()) {
     return false;
   }
 
   if (NS_WARN_IF(!IsPrintableCharKey(aNativeKey.mOriginalVirtualKeyCode))) {
     return false;
   }
 
-  UniCharsAndModifiers baseChars =
-    GetUniCharsAndModifiers(aNativeKey.mOriginalVirtualKeyCode, aModKeyState);
+  UniCharsAndModifiers baseChars = GetUniCharsAndModifiers(aNativeKey);
   if (baseChars.IsEmpty() || !baseChars.CharAt(0)) {
     return false;
   }
 
   char16_t compositeChar = GetCompositeChar(baseChars.CharAt(0));
   if (!compositeChar) {
     return false;
   }
@@ -4084,30 +4073,16 @@ KeyboardLayout::GetUniCharsAndModifiers(
   int32_t key = GetKeyIndex(aVirtualKey);
   if (key < 0) {
     return result;
   }
   return mVirtualKeys[key].GetUniChars(aShiftState);
 }
 
 UniCharsAndModifiers
-KeyboardLayout::GetNativeUniCharsAndModifiers(
-                  uint8_t aVirtualKey,
-                  const ModifierKeyState& aModKeyState) const
-{
-  int32_t key = GetKeyIndex(aVirtualKey);
-  if (key < 0) {
-    return UniCharsAndModifiers();
-  }
-  VirtualKey::ShiftState shiftState =
-    VirtualKey::ModifierKeyStateToShiftState(aModKeyState);
-  return mVirtualKeys[key].GetNativeUniChars(shiftState);
-}
-
-UniCharsAndModifiers
 KeyboardLayout::GetDeadUniCharsAndModifiers() const
 {
   MOZ_RELEASE_ASSERT(mActiveDeadKeys.Length() == mDeadKeyShiftStates.Length());
 
   if (NS_WARN_IF(mActiveDeadKeys.IsEmpty())) {
     return UniCharsAndModifiers();
   }
 
@@ -4528,27 +4503,25 @@ KeyboardLayout::EnsureDeadKeyActive(bool
     // >1 - Previous pressed key does not produce any composite characters.
     //      Return dead-key character followed by base character(s).
   } while ((ret < 0) != aIsActive);
 
   return (ret < 0);
 }
 
 void
-KeyboardLayout::ActivateDeadKeyState(const NativeKey& aNativeKey,
-                                     const ModifierKeyState& aModKeyState)
+KeyboardLayout::ActivateDeadKeyState(const NativeKey& aNativeKey)
 {
   // Dead-key state should be activated at keydown.
   if (!aNativeKey.IsKeyDownMessage()) {
     return;
   }
 
   mActiveDeadKeys.AppendElement(aNativeKey.mOriginalVirtualKeyCode);
-  mDeadKeyShiftStates.AppendElement(
-    VirtualKey::ModifierKeyStateToShiftState(aModKeyState));
+  mDeadKeyShiftStates.AppendElement(aNativeKey.GetShiftState());
 }
 
 void
 KeyboardLayout::DeactivateDeadKeyState()
 {
   if (mActiveDeadKeys.IsEmpty()) {
     return;
   }
--- a/widget/windows/KeyboardLayout.h
+++ b/widget/windows/KeyboardLayout.h
@@ -473,16 +473,43 @@ public:
                                  uint32_t aIndex);
 
   /**
    * Returns true if aChar is a control character which shouldn't be inputted
    * into focused text editor.
    */
   static bool IsControlChar(char16_t aChar);
 
+  bool IsControl() const { return mModKeyState.IsControl(); }
+  bool IsAlt() const { return mModKeyState.IsAlt(); }
+  Modifiers GetModifiers() const { return mModKeyState.GetModifiers(); }
+  const ModifierKeyState& ModifierKeyStateRef() const
+  {
+    return mModKeyState;
+  }
+  VirtualKey::ShiftState GetShiftState() const
+  {
+    return VirtualKey::ModifierKeyStateToShiftState(mModKeyState);
+  }
+
+  /**
+   * GenericVirtualKeyCode() returns virtual keycode which cannot distinguish
+   * position of modifier keys.  E.g., VK_CONTROL for both ControlLeft and
+   * ControlRight.
+   */
+  uint8_t GenericVirtualKeyCode() const { return mOriginalVirtualKeyCode; }
+
+  /**
+   * SpecificVirtualKeyCode() returns virtual keycode which can distinguish
+   * position of modifier keys.  E.g., returns VK_LCONTROL or VK_RCONTROL
+   * instead of VK_CONTROL.  If the key message is synthesized with not
+   * enough information, this prefers left position's keycode.
+   */
+  uint8_t SpecificVirtualKeyCode() const { return mVirtualKeyCode; }
+
 private:
   NativeKey* mLastInstance;
   // mRemovingMsg is set at removing a char message from
   // GetFollowingCharMessage().
   MSG mRemovingMsg;
   // mReceivedMsg is set when another instance starts to handle the message
   // unexpectedly.
   MSG mReceivedMsg;
@@ -589,22 +616,21 @@ private:
    * InitIsSkippableForKeyOrChar() initializes mIsSkippableInRemoteProcess with
    * mIsRepeat and previous key message information.  So, this must be called
    * after mIsRepeat is initialized.
    */
   void InitIsSkippableForKeyOrChar(const MSG& aLastKeyMSG);
 
   /**
    * InitCommittedCharsAndModifiersWithFollowingCharMessages() initializes
-   * mCommittedCharsAndModifiers with mFollowingCharMsgs and aModKeyState.
+   * mCommittedCharsAndModifiers with mFollowingCharMsgs and mModKeyState.
    * If mFollowingCharMsgs includes non-printable char messages, they are
    * ignored (skipped).
    */
-  void InitCommittedCharsAndModifiersWithFollowingCharMessages(
-         const ModifierKeyState& aModKeyState);
+  void InitCommittedCharsAndModifiersWithFollowingCharMessages();
 
   UINT GetScanCodeWithExtendedFlag() const;
 
   // The result is one of eKeyLocation*.
   uint32_t GetKeyLocation() const;
 
   /**
    * RemoveFollowingOddCharMessages() removes odd WM_CHAR messages from the
@@ -859,55 +885,61 @@ public:
   bool HasAltGr() const { return mHasAltGr; }
 
   /**
    * IsDeadKey() returns true if aVirtualKey is a dead key with aModKeyState.
    * This method isn't stateful.
    */
   bool IsDeadKey(uint8_t aVirtualKey,
                  const ModifierKeyState& aModKeyState) const;
+  bool IsDeadKey(const NativeKey& aNativeKey) const
+  {
+    return IsDeadKey(aNativeKey.GenericVirtualKeyCode(),
+                     aNativeKey.ModifierKeyStateRef());
+  }
 
   /**
    * IsInDeadKeySequence() returns true when it's in a dead key sequence.
    * It starts when a dead key is down and ends when another key down causes
    * inactivating the dead key state.
    */
   bool IsInDeadKeySequence() const { return !mActiveDeadKeys.IsEmpty(); }
 
   /**
    * IsSysKey() returns true if aVirtualKey with aModKeyState causes WM_SYSKEY*
    * or WM_SYS*CHAR messages.
    */
   bool IsSysKey(uint8_t aVirtualKey,
                 const ModifierKeyState& aModKeyState) const;
+  bool IsSysKey(const NativeKey& aNativeKey) const
+  {
+    return IsSysKey(aNativeKey.GenericVirtualKeyCode(),
+                    aNativeKey.ModifierKeyStateRef());
+  }
 
   /**
    * GetUniCharsAndModifiers() returns characters which are inputted by
    * aVirtualKey with aModKeyState.  This method isn't stateful.
    * Note that if the combination causes text input, the result's Ctrl and
    * Alt key state are never active.
    */
-  UniCharsAndModifiers GetUniCharsAndModifiers(
-                         uint8_t aVirtualKey,
-                         const ModifierKeyState& aModKeyState) const
+  UniCharsAndModifiers
+  GetUniCharsAndModifiers(uint8_t aVirtualKey,
+                          const ModifierKeyState& aModKeyState) const
   {
     VirtualKey::ShiftState shiftState =
       VirtualKey::ModifierKeyStateToShiftState(aModKeyState);
     return GetUniCharsAndModifiers(aVirtualKey, shiftState);
   }
-
-  /**
-   * GetNativeUniCharsAndModifiers() returns characters which are inputted by
-   * aVirtualKey with aModKeyState.  The method isn't stateful.
-   * Note that different from GetUniCharsAndModifiers(), this returns
-   * actual modifier state of Ctrl and Alt.
-   */
-  UniCharsAndModifiers GetNativeUniCharsAndModifiers(
-                         uint8_t aVirtualKey,
-                         const ModifierKeyState& aModKeyState) const;
+  UniCharsAndModifiers
+  GetUniCharsAndModifiers(const NativeKey& aNativeKey) const
+  {
+    return GetUniCharsAndModifiers(aNativeKey.GenericVirtualKeyCode(),
+                                   aNativeKey.GetShiftState());
+  }
 
   /**
    * OnLayoutChange() must be called before the first keydown message is
    * received.  LoadLayout() changes the keyboard state, that causes breaking
    * dead key state.  Therefore, we need to load the layout before the first
    * keydown message.
    */
   void OnLayoutChange(HKL aKeyboardLayout)
@@ -999,29 +1031,28 @@ private:
   bool mIsOverridden;
   bool mIsPendingToRestoreKeyboardLayout;
   bool mHasAltGr;
 
   static inline int32_t GetKeyIndex(uint8_t aVirtualKey);
   static int CompareDeadKeyEntries(const void* aArg1, const void* aArg2,
                                    void* aData);
   static bool AddDeadKeyEntry(char16_t aBaseChar, char16_t aCompositeChar,
-                                DeadKeyEntry* aDeadKeyArray, uint32_t aEntries);
+                              DeadKeyEntry* aDeadKeyArray, uint32_t aEntries);
   bool EnsureDeadKeyActive(bool aIsActive, uint8_t aDeadKey,
-                             const PBYTE aDeadKeyKbdState);
+                           const PBYTE aDeadKeyKbdState);
   uint32_t GetDeadKeyCombinations(uint8_t aDeadKey,
                                   const PBYTE aDeadKeyKbdState,
                                   uint16_t aShiftStatesWithBaseChars,
                                   DeadKeyEntry* aDeadKeyArray,
                                   uint32_t aMaxEntries);
   /**
    * Activates or deactivates dead key state.
    */
-  void ActivateDeadKeyState(const NativeKey& aNativeKey,
-                            const ModifierKeyState& aModKeyState);
+  void ActivateDeadKeyState(const NativeKey& aNativeKey);
   void DeactivateDeadKeyState();
 
   const DeadKeyTable* AddDeadKeyTable(const DeadKeyEntry* aDeadKeyArray,
                                       uint32_t aEntries);
   void ReleaseDeadKeyTables();
 
   /**
    * Loads the specified keyboard layout. This method always clear the dead key
@@ -1036,46 +1067,42 @@ private:
   nsCString GetLayoutName(HKL aLayout) const;
 
   /**
    * InitNativeKey() must be called when actually widget receives WM_KEYDOWN or
    * WM_KEYUP.  This method is stateful.  This saves current dead key state at
    * WM_KEYDOWN.  Additionally, computes current inputted character(s) and set
    * them to the aNativeKey.
    */
-  void InitNativeKey(NativeKey& aNativeKey,
-                     const ModifierKeyState& aModKeyState);
+  void InitNativeKey(NativeKey& aNativeKey);
 
   /**
    * MaybeInitNativeKeyAsDeadKey() initializes aNativeKey only when aNativeKey
    * is a dead key's event.
    * When it's not in a dead key sequence, this activates the dead key state.
    * When it's in a dead key sequence, this initializes aNativeKey with a
    * composite character or a preceding dead char and a dead char which should
    * be caused by aNativeKey.
    * Returns true when this initializes aNativeKey.  Otherwise, false.
    */
-  bool MaybeInitNativeKeyAsDeadKey(NativeKey& aNativeKey,
-                                   const ModifierKeyState& aModKeyState);
+  bool MaybeInitNativeKeyAsDeadKey(NativeKey& aNativeKey);
 
   /**
    * MaybeInitNativeKeyWithCompositeChar() may initialize aNativeKey with
    * proper composite character when dead key produces a composite character.
    * Otherwise, just returns false.
    */
-  bool MaybeInitNativeKeyWithCompositeChar(
-         NativeKey& aNativeKey,
-         const ModifierKeyState& aModKeyState);
+  bool MaybeInitNativeKeyWithCompositeChar(NativeKey& aNativeKey);
 
   /**
    * See the comment of GetUniCharsAndModifiers() below.
    */
-  UniCharsAndModifiers GetUniCharsAndModifiers(
-                         uint8_t aVirtualKey,
-                         VirtualKey::ShiftState aShiftState) const;
+  UniCharsAndModifiers
+  GetUniCharsAndModifiers(uint8_t aVirtualKey,
+                          VirtualKey::ShiftState aShiftState) const;
 
   /**
    * GetDeadUniCharsAndModifiers() returns dead chars which are stored in
    * current dead key sequence.  So, this is stateful.
    */
   UniCharsAndModifiers GetDeadUniCharsAndModifiers() const;
 
   /**