Use existing KeyEventCodesIOS constants instead of duplicating them
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Apr 2019 21:53:22 +0000 (21:53 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Apr 2019 21:53:22 +0000 (21:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197081

Rubber-stamped by Wenson Hsieh.

Source/WebKit:

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _interpretKeyEvent:isCharEvent:]): While I am here, remove the case for the space key
as it is identical to the default switch case.

Source/WebKitLegacy/mac:

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

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebView/WebHTMLView.mm

index 9eac676..63d8421 100644 (file)
@@ -1,3 +1,14 @@
+2019-04-18  Daniel Bates  <dabates@apple.com>
+
+        Use existing KeyEventCodesIOS constants instead of duplicating them
+        https://bugs.webkit.org/show_bug.cgi?id=197081
+
+        Rubber-stamped by Wenson Hsieh.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _interpretKeyEvent:isCharEvent:]): While I am here, remove the case for the space key
+        as it is identical to the default switch case.
+
 2019-04-19  Keith Rollin  <krollin@apple.com>
 
         Add postprocess-header-rule scripts
index a77a2b1..fe544a6 100644 (file)
@@ -83,6 +83,7 @@
 #import <WebCore/FloatQuad.h>
 #import <WebCore/FontAttributeChanges.h>
 #import <WebCore/InputMode.h>
+#import <WebCore/KeyEventCodesIOS.h>
 #import <WebCore/LocalizedStrings.h>
 #import <WebCore/NotImplemented.h>
 #import <WebCore/Pasteboard.h>
@@ -4503,12 +4504,6 @@ static NSString *contentTypeFromFieldName(WebCore::AutofillFieldName fieldName)
 
 - (BOOL)_interpretKeyEvent:(::WebEvent *)event isCharEvent:(BOOL)isCharEvent
 {
-    static const unsigned kWebEnterKey = 0x0003;
-    static const unsigned kWebBackspaceKey = 0x0008;
-    static const unsigned kWebReturnKey = 0x000D;
-    static const unsigned kWebDeleteKey = 0x007F;
-    static const unsigned kWebSpaceKey = 0x20;
-
     if (event.keyboardFlags & WebEventKeyboardInputModifierFlagsChanged)
         return NO;
 
@@ -4534,30 +4529,21 @@ static NSString *contentTypeFromFieldName(WebCore::AutofillFieldName fieldName)
         return NO;
 
     switch ([characters characterAtIndex:0]) {
-    case kWebBackspaceKey:
-    case kWebDeleteKey:
+    case NSBackspaceCharacter:
+    case NSDeleteCharacter:
         if (contentEditable) {
             [keyboard deleteFromInputWithFlags:event.keyboardFlags];
             return YES;
         }
         break;
-
-    case kWebSpaceKey:
-        if (contentEditable && isCharEvent) {
-            [keyboard addInputString:event.characters withFlags:event.keyboardFlags withInputManagerHint:event.inputManagerHint];
-            return YES;
-        }
-        break;
-
-    case kWebEnterKey:
-    case kWebReturnKey:
+    case NSEnterCharacter:
+    case NSCarriageReturnCharacter:
         if (contentEditable && isCharEvent) {
             // Map \r from HW keyboard to \n to match the behavior of the soft keyboard.
             [keyboard addInputString:@"\n" withFlags:0 withInputManagerHint:nil];
             return YES;
         }
         break;
-
     default:
         if (contentEditable && isCharEvent) {
             [keyboard addInputString:event.characters withFlags:event.keyboardFlags withInputManagerHint:event.inputManagerHint];
index 5c68912..801977a 100644 (file)
@@ -1,3 +1,13 @@
+2019-04-18  Daniel Bates  <dabates@apple.com>
+
+        Use existing KeyEventCodesIOS constants instead of duplicating them
+        https://bugs.webkit.org/show_bug.cgi?id=197081
+
+        Rubber-stamped by Wenson Hsieh.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView _handleEditingKeyEvent:]):
+
 2019-04-18  Ryosuke Niwa  <rniwa@webkit.org>
 
         Crash in FrameLoader::stopAllLoaders via [WebView dealloc] inside ~ObjCEventListener
index c9cf7f9..6b048a1 100644 (file)
@@ -6069,11 +6069,6 @@ static BOOL writingDirectionKeyBindingsEnabled()
 
 #if PLATFORM(IOS_FAMILY)
     
-#define kWebEnterKey         0x0003
-#define kWebBackspaceKey     0x0008
-#define kWebReturnKey        0x000d
-#define kWebDeleteKey        0x007F
-    
 - (BOOL)_handleEditingKeyEvent:(KeyboardEvent *)wcEvent
 {
     // Use the isEditable state to determine whether or not to process tab key events.
@@ -6105,12 +6100,12 @@ static BOOL writingDirectionKeyBindingsEnabled()
         if (!s.length)
             return NO;
         switch ([s characterAtIndex:0]) {
-        case kWebBackspaceKey:
-        case kWebDeleteKey:
+        case NSBackspaceCharacter:
+        case NSDeleteCharacter:
             [[webView _UIKitDelegateForwarder] deleteFromInputWithFlags:event.keyboardFlags];
             return YES;
-        case kWebEnterKey:
-        case kWebReturnKey:
+        case NSEnterCharacter:
+        case NSCarriageReturnCharacter:
             if (isCharEvent) {
                 // Map \r from HW keyboard to \n to match the behavior of the soft keyboard.
                 [[webView _UIKitDelegateForwarder] addInputString:@"\n" withFlags:0];