WebKit Bugzilla
Attachment 349101 Details for
Bug 189389
: [iOS] Arrow keys do not dispatch DOM events to non-editable elements
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189389-20180906180647.patch (text/plain), 13.17 KB, created by
Daniel Bates
on 2018-09-06 18:06:48 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Daniel Bates
Created:
2018-09-06 18:06:48 PDT
Size:
13.17 KB
patch
obsolete
>Subversion Revision: 235769 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index b28eef54ba9c38129c0f73978c2d870622db8af2..9884878a5c0433d293da52e5e0d495956f428709 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,38 @@ >+2018-09-06 Daniel Bates <dabates@apple.com> >+ >+ [iOS] Arrow keys do not work >+ https://bugs.webkit.org/show_bug.cgi?id=189389 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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. >+ >+ Unfortunately I ran into <https://bugs.webkit.org/show_bug.cgi?id=189388> and hence could >+ not write a test for this change. >+ >+ * SourcesCocoa.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * 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): >+ > 2018-08-22 Daniel Bates <dabates@apple.com> > > HTML{Image, Link, Script}Element::crossOrigin() should return an AtomicString >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index f01cd93395e8debe8fd06cf423f157b4ed3b23bf..0325d66b0fc5c88e8afbb8a3f62803c8d4396d52 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,17 @@ >+2018-09-06 Daniel Bates <dabates@apple.com> >+ >+ [iOS] Arrow keys do not work >+ https://bugs.webkit.org/show_bug.cgi?id=189389 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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): >+ > 2018-09-06 Wenson Hsieh <wenson_hsieh@apple.com> > > [macOS] [WK2] Support changing attributes for selected text (text shadow, underline, strike-through) >diff --git a/Source/WebCore/SourcesCocoa.txt b/Source/WebCore/SourcesCocoa.txt >index 5dc3823f2f309c3a9d4766ab1821de871f90b3f0..354d532e2e728cc21a226f40e3a2b21d290b706d 100644 >--- a/Source/WebCore/SourcesCocoa.txt >+++ b/Source/WebCore/SourcesCocoa.txt >@@ -385,7 +385,7 @@ platform/ios/LegacyTileLayer.mm > platform/ios/LegacyTileLayerPool.mm > platform/ios/LowPowerModeNotifierIOS.mm > platform/ios/PasteboardIOS.mm >-platform/ios/PlatformEventFactoryIOS.mm >+platform/ios/PlatformEventFactoryIOS.mm @no-unify > platform/ios/PlatformPasteboardIOS.mm > platform/ios/PlatformScreenIOS.mm > platform/ios/PlatformSpeechSynthesizerIOS.mm @no-unify >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 4a8ac36dffdb0f3b2e8b894f13fe42c26e47255c..9878b3227a91cd90422534b5ad5a3301c259c6dc 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -4126,6 +4126,7 @@ > CE7B2DB31586ABAD0098B3FA /* AlternativeTextUIController.h in Headers */ = {isa = PBXBuildFile; fileRef = CE7B2DAF1586ABAD0098B3FA /* AlternativeTextUIController.h */; settings = {ATTRIBUTES = (Private, ); }; }; > CE7B2DB51586ABAD0098B3FA /* TextAlternativeWithRange.h in Headers */ = {isa = PBXBuildFile; fileRef = CE7B2DB11586ABAD0098B3FA /* TextAlternativeWithRange.h */; settings = {ATTRIBUTES = (Private, ); }; }; > CE7E17831C83A49100AD06AF /* ContentSecurityPolicyHash.h in Headers */ = {isa = PBXBuildFile; fileRef = CE7E17821C83A49100AD06AF /* ContentSecurityPolicyHash.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ CEA284662141E84900E407E8 /* PlatformEventFactoryIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 26601EBE14B3B9AD0012C0FE /* PlatformEventFactoryIOS.mm */; }; > CEBB8C3320786DCB00039547 /* FetchIdioms.h in Headers */ = {isa = PBXBuildFile; fileRef = CEBB8C3120786DCB00039547 /* FetchIdioms.h */; }; > CECADFC7153778FF00E37068 /* DictationAlternative.h in Headers */ = {isa = PBXBuildFile; fileRef = CECADFC3153778FF00E37068 /* DictationAlternative.h */; settings = {ATTRIBUTES = (Private, ); }; }; > CECADFC9153778FF00E37068 /* DictationCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = CECADFC5153778FF00E37068 /* DictationCommand.h */; }; >@@ -28781,7 +28782,6 @@ > D6489D26166FFCF1007C031B /* JSHTMLTemplateElement.h in Headers */, > A80E7E9D0A1A83E3007FB8C5 /* JSHTMLTextAreaElement.h in Headers */, > 83E359A21BB1031D002CEB98 /* JSHTMLTimeElement.h in Headers */, >- E42050172141901B0066EF3B /* ProcessWarming.h in Headers */, > A80E7B0C0A19D606007FB8C5 /* JSHTMLTitleElement.h in Headers */, > 070756D414239A4F00414161 /* JSHTMLTrackElement.h in Headers */, > 1A85B2110A1B258700D8C87C /* JSHTMLUListElement.h in Headers */, >@@ -29789,6 +29789,7 @@ > B71FE6DF11091CB300DAEF77 /* PrintContext.h in Headers */, > 51F645D51FECDBCE00B54DED /* Process.h in Headers */, > A8EA7EBC0A1945D000A8EF5F /* ProcessingInstruction.h in Headers */, >+ E42050172141901B0066EF3B /* ProcessWarming.h in Headers */, > E44613EC0CD681B500FADA75 /* ProgressEvent.h in Headers */, > A715E653134BBBEC00D8E713 /* ProgressShadowElement.h in Headers */, > 1A2A68240B5BEDE70002A480 /* ProgressTracker.h in Headers */, >@@ -31570,6 +31571,7 @@ > 31078CC71880AAB5008099DC /* OESTextureHalfFloatLinear.cpp in Sources */, > 77A17A7112F28182004E02F6 /* OESVertexArrayObject.cpp in Sources */, > DE5F86101FA238D9006DB63A /* PaymentMerchantSessionCocoa.mm in Sources */, >+ CEA284662141E84900E407E8 /* PlatformEventFactoryIOS.mm in Sources */, > AA12DF491743DF83004DAFDF /* PlatformSpeechSynthesizerIOS.mm in Sources */, > CDA29A301CBF74D400901CCF /* PlaybackSessionInterfaceAVKit.mm in Sources */, > CDA29A161CBDA56C00901CCF /* PlaybackSessionInterfaceMac.mm in Sources */, >diff --git a/Source/WebCore/platform/ios/PlatformEventFactoryIOS.h b/Source/WebCore/platform/ios/PlatformEventFactoryIOS.h >index bc7459487b615dee3676c247908e19049f2115da..79a8a662618f11db5c35ce37a4473dc6a94adb92 100644 >--- a/Source/WebCore/platform/ios/PlatformEventFactoryIOS.h >+++ b/Source/WebCore/platform/ios/PlatformEventFactoryIOS.h >@@ -53,6 +53,7 @@ public: > WEBCORE_EXPORT String keyForKeyEvent(WebEvent *); > WEBCORE_EXPORT String codeForKeyEvent(WebEvent *); > WEBCORE_EXPORT String keyIdentifierForKeyEvent(WebEvent *); >+WEBCORE_EXPORT int keyCodeForEvent(WebEvent *); > > } // namespace WebCore > >diff --git a/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm b/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm >index 9e1fb9703a387189914565f9fd14bbce093108a7..380d66f648b66acd6f31bf5aeea382c649b01a09 100644 >--- a/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm >+++ b/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm >@@ -30,12 +30,27 @@ > > #import "IntPoint.h" > #import "KeyEventCocoa.h" >+#import "KeyEventCodesIOS.h" > #import "Logging.h" > #import "WAKAppKitStubs.h" > #import "WebEvent.h" > #import "WindowsKeyboardCodes.h" >+#import <UIKit/UIKit.h> >+#import <wtf/Optional.h> >+#import <wtf/SoftLinking.h> > #import <wtf/WallTime.h> > >+SOFT_LINK_FRAMEWORK(UIKit) >+SOFT_LINK_CONSTANT(UIKit, UIKeyInputUpArrow, NSString *) >+SOFT_LINK_CONSTANT(UIKit, UIKeyInputDownArrow, NSString *) >+SOFT_LINK_CONSTANT(UIKit, UIKeyInputLeftArrow, NSString *) >+SOFT_LINK_CONSTANT(UIKit, UIKeyInputRightArrow, NSString *) >+ >+#define UIKeyInputUpArrow getUIKeyInputUpArrow() >+#define UIKeyInputDownArrow getUIKeyInputDownArrow() >+#define UIKeyInputLeftArrow getUIKeyInputLeftArrow() >+#define UIKeyInputRightArrow getUIKeyInputRightArrow() >+ > namespace WebCore { > > static OptionSet<PlatformEvent::Modifier> modifiersForEvent(WebEvent *event) >@@ -82,6 +97,32 @@ static PlatformEvent::Type mouseEventType(WebEvent *event) > } > } > >+static std::optional<int> convertSpecialKeyToCharCode(NSString *keyString) >+{ >+ if ([keyString isEqualToString:UIKeyInputUpArrow]) >+ return NSUpArrowFunctionKey; >+ if ([keyString isEqualToString:UIKeyInputDownArrow]) >+ return NSDownArrowFunctionKey; >+ if ([keyString isEqualToString:UIKeyInputLeftArrow]) >+ return NSLeftArrowFunctionKey; >+ if ([keyString isEqualToString:UIKeyInputRightArrow]) >+ return NSRightArrowFunctionKey; >+ return std::nullopt; >+} >+ >+int keyCodeForEvent(WebEvent *event) >+{ >+ if ([event.characters isEqualToString:UIKeyInputUpArrow]) >+ return VK_UP; >+ if ([event.characters isEqualToString:UIKeyInputDownArrow]) >+ return VK_DOWN; >+ if ([event.characters isEqualToString:UIKeyInputLeftArrow]) >+ return VK_LEFT; >+ if ([event.characters isEqualToString:UIKeyInputRightArrow]) >+ return VK_RIGHT; >+ return event.keyCode; >+} >+ > class PlatformMouseEventBuilder : public PlatformMouseEvent { > public: > PlatformMouseEventBuilder(WebEvent *event) >@@ -125,36 +166,36 @@ PlatformWheelEvent PlatformEventFactory::createPlatformWheelEvent(WebEvent *even > > String keyIdentifierForKeyEvent(WebEvent *event) > { >- NSString *s = event.charactersIgnoringModifiers; >- if ([s length] != 1) { >- LOG(Events, "received an unexpected number of characters in key event: %u", [s length]); >- return "Unidentified"; >+ NSString *characters = event.charactersIgnoringModifiers; >+ if (auto specialKeyCharCode = convertSpecialKeyToCharCode(characters)) >+ return keyIdentifierForCharCode(*specialKeyCharCode); >+ if ([characters length] != 1) { >+ LOG(Events, "received an unexpected number of characters in key event: %u", [characters length]); >+ return "Unidentified"_s; > } >- >- return keyIdentifierForCharCode(CFStringGetCharacterAtIndex((CFStringRef)s, 0)); >+ return keyIdentifierForCharCode([characters characterAtIndex:0]); > } > > String keyForKeyEvent(WebEvent *event) > { > NSString *characters = event.characters; > auto length = [characters length]; >- > // characters return an empty string for dead keys. > // https://developer.apple.com/reference/appkit/nsevent/1534183-characters > // "Dead" is defined here https://w3c.github.io/uievents-key/#keys-composition. > if (!length) > return "Dead"_s; >- >+ if (auto specialKeyCharCode = convertSpecialKeyToCharCode(characters)) >+ return keyForCharCode(*specialKeyCharCode); > if (length > 1) > return characters; >- > return keyForCharCode([characters characterAtIndex:0]); > } > > // https://w3c.github.io/uievents-code/ > String codeForKeyEvent(WebEvent *event) > { >- switch (event.keyCode) { >+ switch (keyCodeForEvent(event)) { > // Keys in the alphanumeric section. > case VK_OEM_3: return "Backquote"_s; > case VK_OEM_5: return "Backslash"_s; >@@ -378,7 +419,7 @@ public: > m_key = keyForKeyEvent(event); > m_code = codeForKeyEvent(event); > m_keyIdentifier = keyIdentifierForKeyEvent(event); >- m_windowsVirtualKeyCode = event.keyCode; >+ m_windowsVirtualKeyCode = keyCodeForEvent(event); > m_autoRepeat = event.isKeyRepeating; > m_isKeypad = false; // iOS does not distinguish the numpad. See <rdar://problem/7190835>. > m_isSystemKey = false; >diff --git a/Source/WebKit/Shared/ios/WebIOSEventFactory.mm b/Source/WebKit/Shared/ios/WebIOSEventFactory.mm >index 503678b6f5fdd7cfbaf4f18135bced909383eec6..832fd143c25a2f0fe00e730a46e81ed85846207e 100644 >--- a/Source/WebKit/Shared/ios/WebIOSEventFactory.mm >+++ b/Source/WebKit/Shared/ios/WebIOSEventFactory.mm >@@ -58,8 +58,8 @@ WebKit::WebKeyboardEvent WebIOSEventFactory::createWebKeyboardEvent(::WebEvent * > String key = WebCore::keyForKeyEvent(event); > String code = WebCore::codeForKeyEvent(event); > String keyIdentifier = WebCore::keyIdentifierForKeyEvent(event); >- int windowsVirtualKeyCode = event.keyCode; >- int nativeVirtualKeyCode = event.keyCode; >+ int windowsVirtualKeyCode = WebCore::keyCodeForEvent(event); >+ int nativeVirtualKeyCode = WebCore::keyCodeForEvent(event); > int macCharCode = 0; > bool autoRepeat = event.isKeyRepeating; > bool isKeypad = false;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189389
:
349101
|
349200