Title: [191535] trunk/Source/WebKit2
Revision
191535
Author
[email protected]
Date
2015-10-24 08:57:25 -0700 (Sat, 24 Oct 2015)

Log Message

[Cocoa] _WKFormInputSession should provide access to the focused element info
https://bugs.webkit.org/show_bug.cgi?id=150512

Reviewed by Tim Horton.

* UIProcess/API/Cocoa/_WKFormInputSession.h: Added focusedElementInfo property to the
  protocol.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKFormInputSession initWithContentView:focusedElementInfo:userObject:]): Added the
  focusedElementInfo argument, used to initialize a new ivar.
(-[WKFormInputSession focusedElementInfo]): Added this getter for the new
  _WKFormInputSession property.
(-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:userObject:]):
  Create the WKFocusedElementInfo unconditionally and pass it to the new WKFormInputSession
  initializer.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (191534 => 191535)


--- trunk/Source/WebKit2/ChangeLog	2015-10-24 15:54:09 UTC (rev 191534)
+++ trunk/Source/WebKit2/ChangeLog	2015-10-24 15:57:25 UTC (rev 191535)
@@ -1,5 +1,24 @@
 2015-10-24  Dan Bernstein  <[email protected]>
 
+        [Cocoa] _WKFormInputSession should provide access to the focused element info
+        https://bugs.webkit.org/show_bug.cgi?id=150512
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/API/Cocoa/_WKFormInputSession.h: Added focusedElementInfo property to the
+          protocol.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKFormInputSession initWithContentView:focusedElementInfo:userObject:]): Added the
+          focusedElementInfo argument, used to initialize a new ivar.
+        (-[WKFormInputSession focusedElementInfo]): Added this getter for the new
+          _WKFormInputSession property.
+        (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:userObject:]):
+          Create the WKFocusedElementInfo unconditionally and pass it to the new WKFormInputSession
+          initializer.
+
+2015-10-24  Dan Bernstein  <[email protected]>
+
         [iOS] Allow clients to specify a custom input view to be used for a form input session
         https://bugs.webkit.org/show_bug.cgi?id=150395
 

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKFormInputSession.h (191534 => 191535)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKFormInputSession.h	2015-10-24 15:54:09 UTC (rev 191534)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKFormInputSession.h	2015-10-24 15:57:25 UTC (rev 191535)
@@ -28,11 +28,13 @@
 #if WK_API_ENABLED
 
 #import <Foundation/Foundation.h>
+#import <WebKit/_WKFocusedElementInfo.h>
 
 @protocol _WKFormInputSession <NSObject>
 
 @property (nonatomic, readonly, getter=isValid) BOOL valid;
 @property (nonatomic, readonly) NSObject <NSSecureCoding> *userObject;
+@property (nonatomic, readonly) id <_WKFocusedElementInfo> focusedElementInfo WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
 
 #if TARGET_OS_IPHONE
 @property (nonatomic, copy) NSString *accessoryViewCustomButtonTitle;

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (191534 => 191535)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2015-10-24 15:54:09 UTC (rev 191534)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2015-10-24 15:57:25 UTC (rev 191535)
@@ -223,9 +223,13 @@
 @end
 #endif
 
+@interface WKFocusedElementInfo : NSObject <_WKFocusedElementInfo>
+- (instancetype)initWithAssistedNodeInformation:(const AssistedNodeInformation&)information isUserInitiated:(BOOL)isUserInitiated;
+@end
+
 @interface WKFormInputSession : NSObject <_WKFormInputSession>
 
-- (instancetype)initWithContentView:(WKContentView *)view userObject:(NSObject <NSSecureCoding> *)userObject;
+- (instancetype)initWithContentView:(WKContentView *)view focusedElementInfo:(WKFocusedElementInfo *)elementInfo userObject:(NSObject <NSSecureCoding> *)userObject;
 - (void)invalidate;
 
 @end
@@ -233,20 +237,27 @@
 @implementation WKFormInputSession {
     WKContentView *_contentView;
     RetainPtr<NSObject <NSSecureCoding>> _userObject;
+    RetainPtr<WKFocusedElementInfo> _focusedElementInfo;
     RetainPtr<UIView> _customInputView;
 }
 
-- (instancetype)initWithContentView:(WKContentView *)view userObject:(NSObject <NSSecureCoding> *)userObject
+- (instancetype)initWithContentView:(WKContentView *)view focusedElementInfo:(WKFocusedElementInfo *)elementInfo userObject:(NSObject <NSSecureCoding> *)userObject
 {
     if (!(self = [super init]))
         return nil;
 
     _contentView = view;
+    _focusedElementInfo = elementInfo;
     _userObject = userObject;
 
     return self;
 }
 
+- (id <_WKFocusedElementInfo>)focusedElementInfo
+{
+    return _focusedElementInfo.get();
+}
+
 - (NSObject <NSSecureCoding> *)userObject
 {
     return _userObject.get();
@@ -293,10 +304,6 @@
 
 @end
 
-@interface WKFocusedElementInfo : NSObject <_WKFocusedElementInfo>
-- (instancetype)initWithAssistedNodeInformation:(const AssistedNodeInformation&)information isUserInitiated:(BOOL)isUserInitiated;
-@end
-
 @implementation WKFocusedElementInfo {
     WKInputType _type;
     RetainPtr<NSString> _value;
@@ -3192,11 +3199,12 @@
 - (void)_startAssistingNode:(const AssistedNodeInformation&)information userIsInteracting:(BOOL)userIsInteracting blurPreviousNode:(BOOL)blurPreviousNode userObject:(NSObject <NSSecureCoding> *)userObject
 {
     id <_WKInputDelegate> inputDelegate = [_webView _inputDelegate];
+    RetainPtr<WKFocusedElementInfo> focusedElementInfo = adoptNS([[WKFocusedElementInfo alloc] initWithAssistedNodeInformation:information isUserInitiated:userIsInteracting]);
     BOOL shouldShowKeyboard;
-    if ([inputDelegate respondsToSelector:@selector(_webView:focusShouldStartInputSession:)]) {
-        RetainPtr<WKFocusedElementInfo> focusedElementInfo = adoptNS([[WKFocusedElementInfo alloc] initWithAssistedNodeInformation:information isUserInitiated:userIsInteracting]);
+
+    if ([inputDelegate respondsToSelector:@selector(_webView:focusShouldStartInputSession:)])
         shouldShowKeyboard = [inputDelegate _webView:_webView focusShouldStartInputSession:focusedElementInfo.get()];
-    } else {
+    else {
         // The default behavior is to allow node assistance if the user is interacting or the keyboard is already active.
         shouldShowKeyboard = userIsInteracting || _textSelectionAssistant;
     }
@@ -3244,7 +3252,7 @@
     [_inputPeripheral beginEditing];
 
     if ([inputDelegate respondsToSelector:@selector(_webView:didStartInputSession:)]) {
-        _formInputSession = adoptNS([[WKFormInputSession alloc] initWithContentView:self userObject:userObject]);
+        _formInputSession = adoptNS([[WKFormInputSession alloc] initWithContentView:self focusedElementInfo:focusedElementInfo.get() userObject:userObject]);
         [inputDelegate _webView:_webView didStartInputSession:_formInputSession.get()];
     }
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to