Bug 1259679 - Space key shouldn't work as a space key if it's assigned to a function key. r?masayuki draft
authorArata Furukawa <old.river.new@gmail.com>
Sat, 26 Mar 2016 14:06:16 +0900
changeset 344908 46ace4df97b0c52c85082975aba75a601e55368d
parent 344388 24c5fbde4488e06ef79905e1c520027cddcd1189
child 344909 5918de6a8dc9cc4baa09d3f087ef5de880a18066
child 344910 04d18c1ba93173bc2e0c01ea52c92d554a379be0
push id13959
push userbmo:old.river.new@gmail.com
push dateSat, 26 Mar 2016 05:24:10 +0000
reviewersmasayuki
bugs1259679
milestone48.0a1
Bug 1259679 - Space key shouldn't work as a space key if it's assigned to a function key. r?masayuki Even if space key is pressed but it's assigned to a non-printable key, it shouldn't work as a space key because some users may assign Enter key or something to the space key. MozReview-Commit-ID: 4av1n9GPfSf
widget/WidgetEventImpl.cpp
--- a/widget/WidgetEventImpl.cpp
+++ b/widget/WidgetEventImpl.cpp
@@ -558,18 +558,20 @@ WidgetKeyboardEvent::GetShortcutKeyCandi
       ShortcutKeyCandidate key(ch, true);
       aCandidates.AppendElement(key);
     }
   }
 
   // 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.
-  if (mCodeNameIndex == CODE_NAME_INDEX_Space &&
+  // 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 &&
       pseudoCharCode != static_cast<uint32_t>(' ')) {
     ShortcutKeyCandidate spaceKey(static_cast<uint32_t>(' '), false);
     aCandidates.AppendElement(spaceKey);
   }
 }
 
 void
 WidgetKeyboardEvent::GetAccessKeyCandidates(nsTArray<uint32_t>& aCandidates)
@@ -602,18 +604,20 @@ WidgetKeyboardEvent::GetAccessKeyCandida
       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.
-  if (mCodeNameIndex == CODE_NAME_INDEX_Space &&
+  // 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 &&
       charCode != static_cast<uint32_t>(' ')) {
     aCandidates.AppendElement(static_cast<uint32_t>(' '));
   }
   return;
 }
 
 /* static */ void
 WidgetKeyboardEvent::Shutdown()