Title: [230766] trunk/Source/WebKit
Revision
230766
Author
[email protected]
Date
2018-04-18 10:31:41 -0700 (Wed, 18 Apr 2018)

Log Message

Add -[_WKInputDelegateDelegate willStartInputSession:] for clients that want to configure input session before assisting form node
https://bugs.webkit.org/show_bug.cgi?id=184662

Patch by Paul Knight <[email protected]> on 2018-04-18
Reviewed by Beth Dakin.

Clients may wish to configure a WKInputSession before we start assisting
a node. Add a -[_WKInputDelegateDelegate _webView:willStartInputSession:]
callback.

For example, clients that wish to present a custom input view will want
to configure the WKFormInputSession's customInputView before the
keyboard is presented. Otherwise the standard keyboard will begin to
animate and then the custom input view will swap in later.

* UIProcess/API/Cocoa/_WKInputDelegate.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
    Call -_webView:willStartInputSession: before assisting the node.
    Only create the form session if the delegate implements either
    the willStart or didStartInputSession callbacks.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (230765 => 230766)


--- trunk/Source/WebKit/ChangeLog	2018-04-18 17:16:05 UTC (rev 230765)
+++ trunk/Source/WebKit/ChangeLog	2018-04-18 17:31:41 UTC (rev 230766)
@@ -1,3 +1,26 @@
+2018-04-18  Paul Knight  <[email protected]>
+
+        Add -[_WKInputDelegateDelegate willStartInputSession:] for clients that want to configure input session before assisting form node
+        https://bugs.webkit.org/show_bug.cgi?id=184662
+
+        Reviewed by Beth Dakin.
+
+        Clients may wish to configure a WKInputSession before we start assisting
+        a node. Add a -[_WKInputDelegateDelegate _webView:willStartInputSession:]
+        callback.
+
+        For example, clients that wish to present a custom input view will want
+        to configure the WKFormInputSession's customInputView before the
+        keyboard is presented. Otherwise the standard keyboard will begin to
+        animate and then the custom input view will swap in later.
+
+        * UIProcess/API/Cocoa/_WKInputDelegate.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:changingActivityState:userObject:]):
+            Call -_webView:willStartInputSession: before assisting the node.
+            Only create the form session if the delegate implements either
+            the willStart or didStartInputSession callbacks.
+
 2018-04-18  Chris Dumez  <[email protected]>
 
         Add support for converting a local window to a remote window

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInputDelegate.h (230765 => 230766)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInputDelegate.h	2018-04-18 17:16:05 UTC (rev 230765)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKInputDelegate.h	2018-04-18 17:31:41 UTC (rev 230766)
@@ -45,6 +45,7 @@
 - (BOOL)_webView:(WKWebView *)webView focusShouldStartInputSession:(id <_WKFocusedElementInfo>)info;
 - (void)_webView:(WKWebView *)webView accessoryViewCustomButtonTappedInFormInputSession:(id <_WKFormInputSession>)inputSession;
 - (void)_webView:(WKWebView *)webView insertTextSuggestion:(UITextSuggestion *)suggestion inInputSession:(id <_WKFormInputSession>)inputSession WK_API_AVAILABLE(ios(10.0));
+- (void)_webView:(WKWebView *)webView willStartInputSession:(id <_WKFormInputSession>)inputSession WK_API_AVAILABLE(ios(WK_IOS_TBA));
 - (BOOL)_webView:(WKWebView *)webView focusRequiresStrongPasswordAssistance:(id <_WKFocusedElementInfo>)info WK_API_AVAILABLE(ios(WK_IOS_TBA));
 
 - (BOOL)_webView:(WKWebView *)webView shouldRevealFocusOverlayForInputSession:(id <_WKFormInputSession>)inputSession WK_API_AVAILABLE(ios(WK_IOS_TBA));

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (230765 => 230766)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-04-18 17:16:05 UTC (rev 230765)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-04-18 17:31:41 UTC (rev 230766)
@@ -4043,6 +4043,15 @@
     if ([inputDelegate respondsToSelector:@selector(_webView:focusRequiresStrongPasswordAssistance:)])
         _focusRequiresStrongPasswordAssistance = [inputDelegate _webView:_webView focusRequiresStrongPasswordAssistance:focusedElementInfo.get()];
 
+    bool delegateImplementsWillStartInputSession = [inputDelegate respondsToSelector:@selector(_webView:willStartInputSession:)];
+    bool delegateImplementsDidStartInputSession = [inputDelegate respondsToSelector:@selector(_webView:didStartInputSession:)];
+
+    if (delegateImplementsWillStartInputSession || delegateImplementsDidStartInputSession)
+        _formInputSession = adoptNS([[WKFormInputSession alloc] initWithContentView:self focusedElementInfo:focusedElementInfo.get() requiresStrongPasswordAssistance:_focusRequiresStrongPasswordAssistance]);
+
+    if (delegateImplementsWillStartInputSession)
+        [inputDelegate _webView:_webView willStartInputSession:_formInputSession.get()];
+
     BOOL editableChanged = [self setIsEditable:YES];
     _assistedNodeInformation = information;
     _inputPeripheral = nil;
@@ -4085,10 +4094,8 @@
     // _inputPeripheral has been initialized in inputView called by reloadInputViews.
     [_inputPeripheral beginEditing];
 
-    if ([inputDelegate respondsToSelector:@selector(_webView:didStartInputSession:)]) {
-        _formInputSession = adoptNS([[WKFormInputSession alloc] initWithContentView:self focusedElementInfo:focusedElementInfo.get() requiresStrongPasswordAssistance:_focusRequiresStrongPasswordAssistance]);
+    if (delegateImplementsDidStartInputSession)
         [inputDelegate _webView:_webView didStartInputSession:_formInputSession.get()];
-    }
     
     [_webView didStartFormControlInteraction];
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to