gecko-dev/modules/libpref
Masayuki Nakano 06267cb849 Bug 1479964 - Set KeyboardEvent.keyCode and KeyboardEvent.charCode to same value if the event is "keypress" event r=smaug
Chrome sets both KeyboardEvent.keyCode and KeyboardEvent.charCode of "keypress"
event to same value.  On the other hand, our traditional behavior is, sets
one of them to 0.

Therefore, we need to set keyCode value to charCode value if the keypress
event is caused by a non-function key, i.e., it may be a printable key with
specific modifier state and/or different keyboard layout for compatibility
with Chrome.  Similarly, we need to set charCode value to keyCode value if
the keypress event is caused by a function key which is not mapped to producing
a character.

Note that this hack is for compatibility with Chrome.  So, for now, it's enough
to change the behavior only for "keypress" event handlers in web content.  If
we completely change the behavior, we need to fix a lot of default handlers
and mochitests too.  However, it's really difficult because default handlers
check whether keypress events are printable or not with following code:

> if (event.charCode &&
>     !event.altKey && !event.ctrlKey && !event.metaKey) {

or

> if (!event.keyCode &&
>     !event.altKey && !event.ctrlKey && !event.metaKey) {

So, until we stop dispatching "keypress" events for non-printable keys,
we need complicated check in each of them.

And also note that this patch changes the behavior of KeyboardEvent::KeyCode()
when spoofing is enabled and the instance is initialized by initKeyEvent() or
initKeyboardEvent().  That was changed by bug 1222285 unexpectedly and keeping
the behavior makes patched code really ugly.  Therefore, this takes back the
old behavior even if spoofing is enabled.

Differential Revision: https://phabricator.services.mozilla.com/D7974

--HG--
extra : moz-landing-system : lando
2018-10-09 04:43:37 +00:00
..
init Bug 1479964 - Set KeyboardEvent.keyCode and KeyboardEvent.charCode to same value if the event is "keypress" event r=smaug 2018-10-09 04:43:37 +00:00
parser Bug 1490115 - Handle unaccompanied low surrogate pairs in the prefs parser. r=glandium 2018-09-11 09:41:37 +10:00
test Backed out changeset ba1fef7b14eb (bug 1493955) for GTest failures CLOSED TREE 2018-09-28 02:42:20 +03:00
greprefs.js Bug 1448077 - move DevTools prefs from libpref/init/all.js to devtools/shared;r=jryans 2018-04-06 12:22:53 +02:00
moz.build Bug 1493682 - Part 1: Introduce two new prefs for controlling whether the content blocking allow list would be honoured r=baku 2018-09-25 05:40:12 +00:00
nsIPrefBranch.idl Bug 1472523: Part 4 - Avoid unnecessary domain string duplication in preference observers. r=njn 2018-07-04 14:52:48 -07:00
nsIPrefLocalizedString.idl
nsIPrefService.idl Bug 1471025: Part 1 - Store preference access counts in a separate hashtable. r=njn 2018-07-02 23:33:28 -07:00
nsIRelativeFilePref.idl Bug 1484109 - Part 2: Make nsIRelativeFilePref non-scriptable, since there are no script consumers; r=njn 2018-08-17 10:26:50 -04:00
nsRelativeFilePref.h Bug 1484809 - Put class nsRelativeFilePref into its own include file. r=njn 2018-08-21 00:28:00 +03:00
Preferences.cpp Bug 1493955 - Store floating-point preferences in a locale-independent way r=njn 2018-09-28 20:54:09 +00:00
Preferences.h Bug 1493955 - Store floating-point preferences in a locale-independent way r=njn 2018-09-28 20:54:09 +00:00
SharedPrefMap.cpp Bug 1477904: Correctly handle static var caches with changed default values. r=njn 2018-07-23 22:50:03 -07:00
SharedPrefMap.h Bug 1488649 - Convert the prefs table from PLDHashTable to mozilla::HashSet. r=glandium 2018-09-07 09:51:22 +10:00
StaticPrefs.h Bug 1472523: Part 1 - Avoid string copies in preference callbacks. r=njn 2018-06-30 23:06:17 -07:00