Bug 1411705, check the pseudo char code in GetAccessKeyCandidates so that this check works in both keydown and keypress events, r=masayuki
authorNeil Deakin <neil@mozilla.com>
Thu, 09 Nov 2017 18:42:40 -0500
changeset 391055 a1030875b7c8c7b33e49c91aefeacdacc4425724
parent 391054 3a4fbb2ae0221a9cf3986bc18a199d3ddfcdb4b7
child 391056 a812659b1aa89c977b90ecd58b3e8bcb07080095
push id97180
push userneil@mozilla.com
push dateThu, 09 Nov 2017 23:43:33 +0000
treeherdermozilla-inbound@a812659b1aa8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1411705
milestone58.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 1411705, check the pseudo char code in GetAccessKeyCandidates so that this check works in both keydown and keypress events, r=masayuki
widget/WidgetEventImpl.cpp
--- a/widget/WidgetEventImpl.cpp
+++ b/widget/WidgetEventImpl.cpp
@@ -875,47 +875,48 @@ void
 WidgetKeyboardEvent::GetAccessKeyCandidates(nsTArray<uint32_t>& aCandidates) const
 {
   MOZ_ASSERT(aCandidates.IsEmpty(), "aCandidates must be empty");
 
   // return the lower cased charCode candidates for access keys.
   // the priority of the charCodes are:
   //   0: charCode, 1: unshiftedCharCodes[0], 2: shiftedCharCodes[0]
   //   3: unshiftedCharCodes[1], 4: shiftedCharCodes[1],...
-  if (mCharCode) {
-    uint32_t ch = mCharCode;
+  uint32_t pseudoCharCode = PseudoCharCode();
+  if (pseudoCharCode) {
+    uint32_t ch = pseudoCharCode;
     if (IS_IN_BMP(ch)) {
       ch = ToLowerCase(static_cast<char16_t>(ch));
     }
     aCandidates.AppendElement(ch);
   }
   for (uint32_t i = 0; i < mAlternativeCharCodes.Length(); ++i) {
     uint32_t ch[2] =
       { mAlternativeCharCodes[i].mUnshiftedCharCode,
         mAlternativeCharCodes[i].mShiftedCharCode };
     for (uint32_t j = 0; j < 2; ++j) {
       if (!ch[j]) {
         continue;
       }
       if (IS_IN_BMP(ch[j])) {
         ch[j] = ToLowerCase(static_cast<char16_t>(ch[j]));
       }
-      // Don't append the mCharCode that was already appended.
+      // Don't append the charcode that was already appended.
       if (aCandidates.IndexOf(ch[j]) == aCandidates.NoIndex) {
         aCandidates.AppendElement(ch[j]);
       }
     }
   }
   // Special case for "Space" key.  With some keyboard layouts, "Space" with
   // or without Shift key causes non-ASCII space.  For such keyboard layouts,
   // we should guarantee that the key press works as an ASCII white space key
   // press.  However, if the space key is assigned to a function key, it
   // shouldn't work as a space key.
   if (mKeyNameIndex == KEY_NAME_INDEX_USE_STRING &&
-      mCodeNameIndex == CODE_NAME_INDEX_Space && mCharCode != ' ') {
+      mCodeNameIndex == CODE_NAME_INDEX_Space && pseudoCharCode != ' ') {
     aCandidates.AppendElement(' ');
   }
 }
 
 // mask values for ui.key.chromeAccess and ui.key.contentAccess
 #define NS_MODIFIER_SHIFT    1
 #define NS_MODIFIER_CONTROL  2
 #define NS_MODIFIER_ALT      4