[iOS] Interpret text key commands on keydown and app key commands on keypress
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Jan 2019 20:59:48 +0000 (20:59 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Jan 2019 20:59:48 +0000 (20:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=192897
<rdar://problem/46857378>

Reviewed by Brent Fulgham.

Source/WebKit:

Adopt SPI to interpret text key commands and app key commands independently on keydown (isCharEvent
is false) and keypress (isCharEvent is true), respectively.

* Platform/spi/ios/UIKitSPI.h: Add more SPI.
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _interpretKeyEvent:isCharEvent:]):

Source/WebKitLegacy/ios:

Add stubs for SPI.

* DefaultDelegates/WebDefaultUIKitDelegate.m:
(-[WebDefaultUIKitDelegate handleKeyTextCommandForCurrentEvent]): Added.
(-[WebDefaultUIKitDelegate handleKeyAppCommandForCurrentEvent]): Added.
(-[WebDefaultUIKitDelegate handleKeyCommandForCurrentEvent]): Deleted.
* WebView/WebUIKitDelegate.h:

Source/WebKitLegacy/mac:

Adopt SPI to interpret text key commands and app key commands independently on keydown (isCharEvent
is false) and keypress (isCharEvent is true), respectively.

* WebView/WebHTMLView.mm:
(-[WebHTMLView _handleEditingKeyEvent:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240285 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/Platform/spi/ios/UIKitSPI.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKitLegacy/ios/ChangeLog
Source/WebKitLegacy/ios/DefaultDelegates/WebDefaultUIKitDelegate.m
Source/WebKitLegacy/ios/WebView/WebUIKitDelegate.h
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebHTMLView.mm

index adb745d..d8af7ad 100644 (file)
@@ -1,3 +1,18 @@
+2019-01-22  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Interpret text key commands on keydown and app key commands on keypress
+        https://bugs.webkit.org/show_bug.cgi?id=192897
+        <rdar://problem/46857378>
+
+        Reviewed by Brent Fulgham.
+
+        Adopt SPI to interpret text key commands and app key commands independently on keydown (isCharEvent
+        is false) and keypress (isCharEvent is true), respectively.
+
+        * Platform/spi/ios/UIKitSPI.h: Add more SPI.
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _interpretKeyEvent:isCharEvent:]):
+
 2019-01-22  David Kilzer  <ddkilzer@apple.com>
 
         C strings in ClientCertificateAuthenticationXPCConstants.h are duplicated
index 1f63a32..f9562f2 100644 (file)
@@ -1072,6 +1072,8 @@ typedef NSInteger UICompositingMode;
 @interface UIKeyboardImpl (IPI)
 - (void)setInitialDirection;
 - (void)prepareKeyboardInputModeFromPreferences:(UIKeyboardInputMode *)lastUsedMode;
+- (BOOL)handleKeyTextCommandForCurrentEvent;
+- (BOOL)handleKeyAppCommandForCurrentEvent;
 @property (nonatomic, readonly) UIKeyboardInputMode *currentInputModeInPreference;
 @end
 
index 8038a92..61b7665 100644 (file)
 
 #endif
 
-#if PLATFORM(IOS_FAMILY)
-
-@interface UIKeyboardImpl (Staging)
-- (BOOL)handleKeyCommandForCurrentEvent;
-@end
-
-#endif
-
 namespace WebKit {
 using namespace WebCore;
 using namespace WebKit;
@@ -4023,7 +4015,9 @@ static NSString *contentTypeFromFieldName(WebCore::AutofillFieldName fieldName)
     UIKeyboardImpl *keyboard = [UIKeyboardImpl sharedInstance];
 
 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000
-    if (event.type == WebEventKeyDown && [keyboard respondsToSelector:@selector(handleKeyCommandForCurrentEvent)] && [keyboard handleKeyCommandForCurrentEvent])
+    if (!isCharEvent && [keyboard respondsToSelector:@selector(handleKeyTextCommandForCurrentEvent)] && [keyboard handleKeyTextCommandForCurrentEvent])
+        return YES;
+    if (isCharEvent && [keyboard respondsToSelector:@selector(handleKeyAppCommandForCurrentEvent)] && [keyboard handleKeyAppCommandForCurrentEvent])
         return YES;
 #endif
 
index 611c275..d093f3e 100644 (file)
@@ -1,3 +1,19 @@
+2019-01-22  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Interpret text key commands on keydown and app key commands on keypress
+        https://bugs.webkit.org/show_bug.cgi?id=192897
+        <rdar://problem/46857378>
+
+        Reviewed by Brent Fulgham.
+
+        Add stubs for SPI.
+
+        * DefaultDelegates/WebDefaultUIKitDelegate.m:
+        (-[WebDefaultUIKitDelegate handleKeyTextCommandForCurrentEvent]): Added.
+        (-[WebDefaultUIKitDelegate handleKeyAppCommandForCurrentEvent]): Added.
+        (-[WebDefaultUIKitDelegate handleKeyCommandForCurrentEvent]): Deleted.
+        * WebView/WebUIKitDelegate.h:
+
 2019-01-04  Simon Fraser  <simon.fraser@apple.com>
 
         Factor legacy WK1 code for fixed and scrolling layers into their own helper class
index aaee826..f2b1fa6 100644 (file)
@@ -162,7 +162,12 @@ static WebDefaultUIKitDelegate *sharedDelegate = nil;
 {
 }
 
-- (BOOL)handleKeyCommandForCurrentEvent
+- (BOOL)handleKeyTextCommandForCurrentEvent
+{
+    return NO;
+}
+
+- (BOOL)handleKeyAppCommandForCurrentEvent
 {
     return NO;
 }
index b85547b..9897456 100644 (file)
@@ -90,7 +90,8 @@ typedef NS_ENUM(NSInteger, WebMediaCaptureType) {
 - (void)webView:(WebView *)webView didHideFullScreenForPlugInView:(id)plugInView;
 - (void)webView:(WebView *)aWebView didReceiveMessage:(NSDictionary *)aMessage;
 - (void)addInputString:(NSString *)str withFlags:(NSUInteger)flags;
-- (BOOL)handleKeyCommandForCurrentEvent;
+- (BOOL)handleKeyTextCommandForCurrentEvent;
+- (BOOL)handleKeyAppCommandForCurrentEvent;
 // FIXME: remove deleteFromInput when UIKit implements deleteFromInputWithFlags.
 - (void)deleteFromInput;
 - (void)deleteFromInputWithFlags:(NSUInteger)flags;
index 7faf732..ad6b937 100644 (file)
@@ -1,3 +1,17 @@
+2019-01-22  Daniel Bates  <dabates@apple.com>
+
+        [iOS] Interpret text key commands on keydown and app key commands on keypress
+        https://bugs.webkit.org/show_bug.cgi?id=192897
+        <rdar://problem/46857378>
+
+        Reviewed by Brent Fulgham.
+
+        Adopt SPI to interpret text key commands and app key commands independently on keydown (isCharEvent
+        is false) and keypress (isCharEvent is true), respectively.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _handleEditingKeyEvent:]):
+
 2019-01-22  Oriol Brufau  <obrufau@igalia.com>
 
         [css-logical] Implement flow-relative margin, padding and border shorthands
index 512934a..7b4394a 100644 (file)
@@ -6092,8 +6092,12 @@ static BOOL writingDirectionKeyBindingsEnabled()
         if (!webView.isEditable && event.isTabKey)
             return NO;
 
+        bool isCharEvent = platformEvent->type() == PlatformKeyboardEvent::Char;
+
 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000
-        if (event.type == WebEventKeyDown && [webView._UIKitDelegateForwarder handleKeyCommandForCurrentEvent])
+        if (!isCharEvent && [webView._UIKitDelegateForwarder handleKeyTextCommandForCurrentEvent])
+            return YES;
+        if (isCharEvent && [webView._UIKitDelegateForwarder handleKeyAppCommandForCurrentEvent])
             return YES;
 #endif
 
@@ -6107,14 +6111,14 @@ static BOOL writingDirectionKeyBindingsEnabled()
             return YES;
         case kWebEnterKey:
         case kWebReturnKey:
-            if (platformEvent->type() == PlatformKeyboardEvent::Char) {
+            if (isCharEvent) {
                 // Map \r from HW keyboard to \n to match the behavior of the soft keyboard.
                 [[webView _UIKitDelegateForwarder] addInputString:@"\n" withFlags:0];
                 return YES;
             }
             break;
         default:
-            if (platformEvent->type() == PlatformKeyboardEvent::Char) {
+            if (isCharEvent) {
                 [[webView _UIKitDelegateForwarder] addInputString:event.characters withFlags:event.keyboardFlags];
                 return YES;
             }