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
--- 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()