Bug 1303273 part.1 KeyboardLayout::IsSysKey() should check MODIFIER_ALT as a bit flag r?m_kato draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 11 Oct 2016 13:00:45 +0900
changeset 423625 cc1008939023532a32ab8e9f87e8b3ee10701f34
parent 423604 7ae377917236b7e6111146aa9fb4c073c0efc7f4
child 423626 3d6499049912f3213863ca3abb349b8e7676ff24
push id31948
push usermasayuki@d-toybox.com
push dateTue, 11 Oct 2016 12:46:29 +0000
reviewersm_kato
bugs1303273
milestone52.0a1
Bug 1303273 part.1 KeyboardLayout::IsSysKey() should check MODIFIER_ALT as a bit flag r?m_kato This is a simple mistake and blocks following patchs' automated tests. For example, when Alt+Shift+foo doesn't cause text, this returns false even though it should return true. MozReview-Commit-ID: 91L33vZhouT
widget/windows/KeyboardLayout.cpp
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -3516,16 +3516,17 @@ KeyboardLayout::IsDeadKey(uint8_t aVirtu
 
 bool
 KeyboardLayout::IsSysKey(uint8_t aVirtualKey,
                          const ModifierKeyState& aModKeyState) const
 {
   // If Alt key is not pressed, it's never a system key combination.
   // Additionally, if Ctrl key is pressed, it's never a system key combination
   // too.
+  // FYI: Windows logo key state won't affect if it's a system key.
   if (!aModKeyState.IsAlt() || aModKeyState.IsControl()) {
     return false;
   }
 
   int32_t virtualKeyIndex = GetKeyIndex(aVirtualKey);
   if (virtualKeyIndex < 0) {
     return true;
   }
@@ -3533,17 +3534,17 @@ KeyboardLayout::IsSysKey(uint8_t aVirtua
   UniCharsAndModifiers inputCharsAndModifiers =
     GetUniCharsAndModifiers(aVirtualKey, aModKeyState);
   if (inputCharsAndModifiers.IsEmpty()) {
     return true;
   }
 
   // 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.mModifiers[0] != MODIFIER_ALT;
+  return !!(inputCharsAndModifiers.mModifiers[0] & MODIFIER_ALT);
 }
 
 void
 KeyboardLayout::InitNativeKey(NativeKey& aNativeKey,
                               const ModifierKeyState& aModKeyState)
 {
   if (mIsPendingToRestoreKeyboardLayout) {
     LoadLayout(::GetKeyboardLayout(0));