[iOS] Arrow keys do not dispatch DOM events to non-editable elements
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Sep 2018 21:02:50 +0000 (21:02 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Sep 2018 21:02:50 +0000 (21:02 +0000)
commit539abc40cf2ce8db07d8903f1c4748ae9d8d5e54
tree05964983f33110d6f78718980ae558165c60a42b
parent91789a584d05a4a35f0265b9a8e7c74b7cd713be
[iOS] Arrow keys do not dispatch DOM events to non-editable elements
https://bugs.webkit.org/show_bug.cgi?id=189389

Reviewed by Simon Fraser.

Source/WebCore:

On iOS the arrow keys are identified by special multi character key strings: UIKeyInput{Up,
Down, Left, Right}Arrow as opposed to special key codes as on Mac. When converting the iOS-
specific WebEvent we need to take care to recognize when the key string for the event is
one of these special key strings when computing key code, character code, and key identifier
properties for the WebCore platform-specific event. These details will be included in
the corresponding DOM keyboard events that are dispatched when the arrow keys are pressed.

* SourcesCocoa.txt:
* WebCore.xcodeproj/project.pbxproj:
Mark file PlatformEventFactoryIOS as @no-unify as it is not compatible with the unified sources
build strategy given its use of wtf/cocoa/SoftLinking.h macros.

* platform/ios/PlatformEventFactoryIOS.h:
* platform/ios/PlatformEventFactoryIOS.mm:
(WebCore::convertSpecialKeyToCharCode): Manufacture the appropriate character code for an
event that represents an arrow key. Otherwise, return std::nullopt to indicate that the
event is not for an arrow key.
(WebCore::keyCodeForEvent): Manufacture the appropriate Windows virtual key code for an
event that represents an arrow key. Otherwise, do what we do now and return the key code
associated with the WebEvent.
(WebCore::keyIdentifierForKeyEvent): Modified to test if the event is for an arrow key
and return the appropriate key identifier.
(WebCore::keyForKeyEvent): Modified to test if the event is for an arrow key
and return the appropriate character code.
(WebCore::codeForKeyEvent): Modified to call keyCodeForEvent(), which knows how to account
for events that represent arrow keys.
(WebCore::PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder):

Source/WebKit:

Use WebCore::keyCodeForEvent() to retrieve the key code for a WebEvent instead of querying
the key code from the WebEvent directly. The function WebCore::keyCodeForEvent() knows how
to compute the key code for an event that represents an arrow key.

* Shared/ios/WebIOSEventFactory.mm:
(WebIOSEventFactory::createWebKeyboardEvent):

LayoutTests:

Update expected result now that we compute the correct keyIdentifier, keycode, and which properties
for DOM keyboard events dispatched when the arrow keys are pressed.

* fast/events/ios/keydown-keyup-in-non-editable-content-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235860 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/events/ios/keydown-keyup-in-non-editable-content-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/SourcesCocoa.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/ios/PlatformEventFactoryIOS.h
Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm
Source/WebKit/ChangeLog
Source/WebKit/Shared/ios/WebIOSEventFactory.mm