Provide handleKeyWebEvent with completion handler.
authorenrica@apple.com <enrica@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Feb 2016 00:09:33 +0000 (00:09 +0000)
committerenrica@apple.com <enrica@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Feb 2016 00:09:33 +0000 (00:09 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153806
rdar://problem/24399218

Reviewed by Tim Horton.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView handleKeyWebEvent:withCompletionHandler:]):
(-[WKContentView _didHandleKeyEvent:eventWasHandled:]):

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

index 6624619..ff1890c 100644 (file)
@@ -1,3 +1,16 @@
+2016-02-02  Enrica Casucci  <enrica@apple.com>
+
+        Provide handleKeyWebEvent with completion handler.
+        https://bugs.webkit.org/show_bug.cgi?id=153806
+        rdar://problem/24399218
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView handleKeyWebEvent:withCompletionHandler:]):
+        (-[WKContentView _didHandleKeyEvent:eventWasHandled:]):
+
 2016-02-02  Alex Christensen  <achristensen@webkit.org>
 
         Fix authentication with NetworkSession
index 8403c1f..877e4ae 100644 (file)
@@ -70,6 +70,7 @@ typedef void (^UIWKAutocorrectionContextHandler)(UIWKAutocorrectionContext *auto
 typedef void (^UIWKDictationContextHandler)(NSString *selectedText, NSString *beforeText, NSString *afterText);
 typedef void (^UIWKSelectionCompletionHandler)(void);
 typedef void (^UIWKSelectionWithDirectionCompletionHandler)(BOOL selectionEndIsMoving);
+typedef void (^UIWKKeyWebEventCompletionHandler)(WebIOSEvent *theEvent, BOOL wasHandled);
 
 namespace WebKit {
 struct WKSelectionDrawingInfo {
@@ -142,6 +143,7 @@ struct WKAutoCorrectionData {
     WebKit::AssistedNodeInformation _assistedNodeInformation;
     RetainPtr<NSObject<WKFormPeripheral>> _inputPeripheral;
     RetainPtr<UIEvent> _uiEventBeingResent;
+    UIWKKeyWebEventCompletionHandler _keyWebEventHandler;
 
     CGPoint _lastInteractionLocation;
 
index f8e1a5f..5194666 100644 (file)
@@ -2870,8 +2870,21 @@ static UITextAutocapitalizationType toUITextAutocapitalize(WebAutocapitalizeType
     _page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent));
 }
 
+- (void)handleKeyWebEvent:(WebIOSEvent *)theEvent withCompletionHandler:(void (^)(WebIOSEvent *theEvent, BOOL wasHandled))completionHandler
+{
+    _keyWebEventHandler = [completionHandler copy];
+    _page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent));
+}
+
 - (void)_didHandleKeyEvent:(WebIOSEvent *)event eventWasHandled:(BOOL)eventWasHandled
 {
+    if (_keyWebEventHandler) {
+        _keyWebEventHandler(event, eventWasHandled);
+        [_keyWebEventHandler release];
+        _keyWebEventHandler = nil;
+        return;
+    }
+        
     if (event.type == WebEventKeyDown) {
         // FIXME: This is only for staging purposes.
         if ([[UIKeyboardImpl sharedInstance] respondsToSelector:@selector(didHandleWebKeyEvent:)])