gecko-dev/dom/events
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
..
crashtests Bug 1397711 - Null-check widget of keyboard event before invoking its PostHandleKeyEvent. r=masayuki 2017-09-07 22:07:34 +10:00
test 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
AnimationEvent.cpp Bug 1436902 part 2. Use NS_INLINE_DECL_REFCOUNTING_INHERITED for some classes that have otherwise-empty QI impls. r=mccr8 2018-02-12 15:43:55 -05:00
AnimationEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
AsyncEventDispatcher.cpp Bug 1470545: Add chromeonly "shadowrootattached" event for devtools. r=smaug 2018-06-27 11:24:43 +02:00
AsyncEventDispatcher.h Bug 1477640 - Make AsyncEventDispatcher(dom::EventTarget* aTarget, dom::Event* aEvent) crash in debug build if aEvent is not safe to be dispatched asynchronously r=smaug 2018-07-24 14:51:32 +09:00
BeforeUnloadEvent.cpp Bug 1436902 part 2. Use NS_INLINE_DECL_REFCOUNTING_INHERITED for some classes that have otherwise-empty QI impls. r=mccr8 2018-02-12 15:43:55 -05:00
BeforeUnloadEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
Clipboard.cpp Bug 1461465 - Implement async Clipboard APIs, r=nika,r=enndeakin 2018-07-31 13:13:02 -04:00
Clipboard.h Bug 1461465 - Implement async Clipboard APIs, r=nika,r=enndeakin 2018-07-31 13:13:02 -04:00
ClipboardEvent.cpp Bug 1444919 part 2. Remove nsIDOMClipboardEvent. r=mystor 2018-03-13 00:59:24 -04:00
ClipboardEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
CommandEvent.cpp Bug 971462 - Hide event type from constructor of WidgetCommandEvent r=smaug 2018-07-30 12:20:47 +00:00
CommandEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
CompositionEvent.cpp Bug 1414974 - Part 6: Change WebIDL bindings to refer to nsGlobalWindowInner rather than nsGlobalWindow, r=bz 2017-11-09 10:44:49 -05:00
CompositionEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
ConstructibleEventTarget.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
ConstructibleEventTarget.h Bug 1379688 part 2. Make the EventTarget interface constructible. r=smaug 2017-11-20 13:59:22 -05:00
ContentEventHandler.cpp Bug 1490997 - Use nsAtom instead of nsString for font family name in the FontFamilyName struct, and switch its methods from 16-bit to 8-bit strings. r=lsalzman 2018-09-18 09:34:21 +01:00
ContentEventHandler.h Bug 1481292 - part 1: Get rid of ContentEventHandler::GetNodePositionHavingFlatText() because of unused r=smaug 2018-08-07 13:50:23 +00:00
CustomEvent.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
CustomEvent.h Bug 1447472 part 2. Remove nsIDOMCustomEvent. r=qdot 2018-03-26 14:53:51 -04:00
DOMEventTargetHelper.cpp Bug 1278831 - DOMEventTargetHelper must release itself when disconnected from the owner and when kept alive by some event listener, r=smaug 2018-08-01 00:19:15 +02:00
DOMEventTargetHelper.h Bug 1450167. Stop using atom-or-string for event names in the listener manager. r=smaug 2018-07-24 18:15:19 -04:00
DataTransfer.cpp Bug 1310193 - Remove wrapping of nsISupports as nsISupportsInterfacePointer in transferables. r=smaug 2018-10-07 16:33:07 +02:00
DataTransfer.h Bug 1453153 - Initial removal of moz* APIs in DataTransfer, r=enndeakin,r=nika 2018-08-22 15:10:31 -04:00
DataTransferItem.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
DataTransferItem.h Bug 1461465 - Implement async Clipboard APIs, r=nika,r=enndeakin 2018-07-31 13:13:02 -04:00
DataTransferItemList.cpp Bug 1461465 - Implement async Clipboard APIs, r=nika,r=enndeakin 2018-07-31 13:13:02 -04:00
DataTransferItemList.h Bug 1412125, part 2 - Fix dom/ mode lines. r=qdot 2017-10-26 15:08:41 -07:00
DeviceMotionEvent.cpp Bug 1391005 - Eliminate NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED. r=peterv 2017-08-29 16:02:48 -07:00
DeviceMotionEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
DragEvent.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
DragEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
Event.cpp Bug 1493737 - Fix many trivial calls to do_QueryInterface r=smaug 2018-10-01 21:38:01 +00:00
Event.h Bug 1375319 part 1 - Make DispatchTrustedEvent able to dispatch composed event and have fullscreen events composed. r=smaug 2018-09-14 00:05:39 +00:00
EventDispatcher.cpp Bug 1493737 - Fix many trivial calls to do_QueryInterface r=smaug 2018-10-01 21:38:01 +00:00
EventDispatcher.h Bug 1466581, handle sequential focus also in nested shadow DOM, r=mrbkap 2018-07-10 01:56:42 +03:00
EventListenerManager.cpp Bug 1492395 - Make event markers in profiler timeline per event, not per event listener, r=mstange 2018-09-21 02:03:04 +03:00
EventListenerManager.h Bug 1450167. Stop using atom-or-string for event names in the listener manager. r=smaug 2018-07-24 18:15:19 -04:00
EventListenerService.cpp Bug 1486690 - Remove unnecessary checks after moz_xmalloc() calls. r=glandium 2018-08-28 15:56:01 +10:00
EventListenerService.h Bug 1480678 part 7 - Use CallbackObject's callback global for realm entering in more places. r=bz 2018-08-07 14:06:44 +02:00
EventNameList.h Bug 1359017 - onmessageerror for WindowEventHandlers in case StructuredClone algorithm fails when deserializing, r=masayuki, r=smaug 2017-09-13 05:59:06 +02:00
EventStateManager.cpp Bug 1451169 - Use `nsStaticAtom*` instead of `nsStaticAtom**` in Element.h. r=baku 2018-04-03 13:21:06 +10:00
EventStateManager.h Bug 1490539 part 1 - Change FullScreen to Fullscreen in various names. r=smaug 2018-09-12 15:51:30 +00:00
EventStates.h Bug 1490539 part 1 - Change FullScreen to Fullscreen in various names. r=smaug 2018-09-12 15:51:30 +00:00
EventTarget.cpp Bug 1472491: Part 1 - Add [ChromeOnly] wantUntrusted event listener option. r=bz 2018-07-29 18:51:00 -07:00
EventTarget.h Bug 1489454 - Remove all trailing whitespaces (again) r=Ehsan 2018-09-07 14:47:51 +00:00
FocusEvent.cpp Bug 1446708. Get rid of nsIDOMFocusEvent. r=qdot 2018-03-19 15:50:19 -04:00
FocusEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
IMEContentObserver.cpp Bug 1453795 - DOM/Events - Initialize member fields in classes/ structures. r=smaug 2018-06-14 22:26:29 +03:00
IMEContentObserver.h Bug 1387143 part 29. Remove nsISelection. r=mats 2018-05-08 13:52:42 -04:00
IMEStateManager.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
IMEStateManager.h Bug 1387143 part 29. Remove nsISelection. r=mats 2018-05-08 13:52:42 -04:00
ImageCaptureError.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
ImageCaptureError.h
InputEvent.cpp Bug 1446527 part 5. Remove unused nsIDOMUIEvent bits. r=qdot 2018-03-26 14:53:02 -04:00
InputEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
InternalMutationEvent.h Bug 1455676 part 14. Remove most use of nsIDOMNode in dom/. r=qdot 2018-05-29 22:58:49 -04:00
JSEventHandler.cpp Bug 1472976 part 2 - Use the callback global instead of the callback in JSEventHandler::HandleEvent. r=smaug 2018-08-10 11:57:39 +02:00
JSEventHandler.h Bug 1436508 part 12. Remove nsIDOMKeyEvent. r=masayuki 2018-02-09 11:17:10 -05:00
KeyNameList.h Bug 1386825 - Part 1: Remove MOZ_B2G from dom. r=bkelly 2017-08-08 14:41:05 -07:00
KeyboardEvent.cpp 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
KeyboardEvent.h 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
MessageEvent.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
MessageEvent.h Bug 1470930: Use enums for passing arguments for event dispatch. r=smaug 2018-06-26 18:22:06 +02:00
MouseEvent.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
MouseEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
MouseScrollEvent.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
MouseScrollEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
MutationEvent.cpp Bug 1455676 part 14. Remove most use of nsIDOMNode in dom/. r=qdot 2018-05-29 22:58:49 -04:00
MutationEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
NotifyPaintEvent.cpp Bug 1455052 part 10. Remove various unused nsIDOMEvent bits. r=masayuki 2018-04-20 12:55:31 -04:00
NotifyPaintEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
PaintRequest.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
PaintRequest.h Bug 1455052 part 8. Stop using nsIDOMEvent in docshell and dom. r=masayuki 2018-04-20 12:55:30 -04:00
PendingFullscreenEvent.h Bug 1491192 - Get raw pointer from RefPtr in ternary expression to fix MSVC build. a=tier2-permafail-fix 2018-09-14 15:41:31 +10:00
PhysicalKeyCodeNameList.h
PointerEvent.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
PointerEvent.h Bug 1303957 Part1: Add support for PointerEvent.getCoalescedEvents. r=smaug. 2017-09-20 13:00:57 +08:00
PointerEventHandler.cpp Bug 1472425 - PointerEventHandler should use IsInComposedDoc, r=mrbkap 2018-07-03 18:06:29 +03:00
PointerEventHandler.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
ScrollAreaEvent.cpp Bug 1455052 part 10. Remove various unused nsIDOMEvent bits. r=masayuki 2018-04-20 12:55:31 -04:00
ScrollAreaEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
SimpleGestureEvent.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
SimpleGestureEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
SpeechRecognitionError.cpp
SpeechRecognitionError.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
StorageEvent.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
StorageEvent.h
TextClause.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
TextClause.h Bug 1412125, part 2 - Fix dom/ mode lines. r=qdot 2017-10-26 15:08:41 -07:00
TextComposition.cpp Bug 1462257 - TextComposition should dispatch eCompositionChange event when eCompositionCommit is being fired immediately after eCompositionStart r=m_kato 2018-07-11 23:05:39 +09:00
TextComposition.h Bug 1462257 - TextComposition should dispatch eCompositionChange event when eCompositionCommit is being fired immediately after eCompositionStart r=m_kato 2018-07-11 23:05:39 +09:00
Touch.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
Touch.h bug 1429572, touch.target retargeting in shadow DOM, r=masayuki 2018-05-25 18:02:59 +03:00
TouchEvent.cpp Bug 1348273 - Convert crash annotations into a machine-readable list of constants; r=ted.mielczarek,njn,dholbert,mak,cpearce,mcmanus,froydnj,Dexter,jrmuizel,jchen,jimm,bz,surkov 2018-07-05 15:42:11 +02:00
TouchEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
TransitionEvent.cpp Bug 1436902 part 2. Use NS_INLINE_DECL_REFCOUNTING_INHERITED for some classes that have otherwise-empty QI impls. r=mccr8 2018-02-12 15:43:55 -05:00
TransitionEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
UIEvent.cpp Bug 1455676 part 14. Remove most use of nsIDOMNode in dom/. r=qdot 2018-05-29 22:58:49 -04:00
UIEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
VirtualKeyCodeList.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
WheelEvent.cpp Bug 1482665 Part 2 - Remove nsPresContext::AppUnitsPerCSSPixel() and replace it with mozilla::AppUnitsPerCSSPixel(). r=dholbert 2018-08-13 14:29:28 -07:00
WheelEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
WheelHandlingHelper.cpp Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
WheelHandlingHelper.h Bug 1453795 - DOM/Events - Initialize member fields in classes/ structures. r=smaug 2018-06-14 22:26:29 +03:00
XULCommandEvent.cpp Bug 1453795 - DOM/Events - Initialize member fields in classes/ structures. r=smaug 2018-06-14 22:26:29 +03:00
XULCommandEvent.h Bug 1470325 - s/FooBinding/Foo_Binding/g - r=qdot 2018-06-26 17:05:01 -07:00
moz.build Bug 326944, remove nsIComboboxControlFrame interface, r=mats 2018-09-26 10:41:12 -04:00
nsIEventListenerService.idl Bug 1489047 - Change almost all DOMString occurrences in XPIDL files to AString. r=nika 2018-09-06 18:02:43 +10:00