Changeset 191535 in webkit


Ignore:
Timestamp:
Oct 24, 2015 8:57:25 AM (9 years ago)
Author:
mitz@apple.com
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.

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r191534 r191535  
     12015-10-24  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] _WKFormInputSession should provide access to the focused element info
     4        https://bugs.webkit.org/show_bug.cgi?id=150512
     5
     6        Reviewed by Tim Horton.
     7
     8        * UIProcess/API/Cocoa/_WKFormInputSession.h: Added focusedElementInfo property to the
     9          protocol.
     10
     11        * UIProcess/ios/WKContentViewInteraction.mm:
     12        (-[WKFormInputSession initWithContentView:focusedElementInfo:userObject:]): Added the
     13          focusedElementInfo argument, used to initialize a new ivar.
     14        (-[WKFormInputSession focusedElementInfo]): Added this getter for the new
     15          _WKFormInputSession property.
     16        (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:userObject:]):
     17          Create the WKFocusedElementInfo unconditionally and pass it to the new WKFormInputSession
     18          initializer.
     19
    1202015-10-24  Dan Bernstein  <mitz@apple.com>
    221
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKFormInputSession.h

    r191534 r191535  
    2929
    3030#import <Foundation/Foundation.h>
     31#import <WebKit/_WKFocusedElementInfo.h>
    3132
    3233@protocol _WKFormInputSession <NSObject>
     
    3435@property (nonatomic, readonly, getter=isValid) BOOL valid;
    3536@property (nonatomic, readonly) NSObject <NSSecureCoding> *userObject;
     37@property (nonatomic, readonly) id <_WKFocusedElementInfo> focusedElementInfo WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
    3638
    3739#if TARGET_OS_IPHONE
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r191534 r191535  
    224224#endif
    225225
     226@interface WKFocusedElementInfo : NSObject <_WKFocusedElementInfo>
     227- (instancetype)initWithAssistedNodeInformation:(const AssistedNodeInformation&)information isUserInitiated:(BOOL)isUserInitiated;
     228@end
     229
    226230@interface WKFormInputSession : NSObject <_WKFormInputSession>
    227231
    228 - (instancetype)initWithContentView:(WKContentView *)view userObject:(NSObject <NSSecureCoding> *)userObject;
     232- (instancetype)initWithContentView:(WKContentView *)view focusedElementInfo:(WKFocusedElementInfo *)elementInfo userObject:(NSObject <NSSecureCoding> *)userObject;
    229233- (void)invalidate;
    230234
     
    234238    WKContentView *_contentView;
    235239    RetainPtr<NSObject <NSSecureCoding>> _userObject;
     240    RetainPtr<WKFocusedElementInfo> _focusedElementInfo;
    236241    RetainPtr<UIView> _customInputView;
    237242}
    238243
    239 - (instancetype)initWithContentView:(WKContentView *)view userObject:(NSObject <NSSecureCoding> *)userObject
     244- (instancetype)initWithContentView:(WKContentView *)view focusedElementInfo:(WKFocusedElementInfo *)elementInfo userObject:(NSObject <NSSecureCoding> *)userObject
    240245{
    241246    if (!(self = [super init]))
     
    243248
    244249    _contentView = view;
     250    _focusedElementInfo = elementInfo;
    245251    _userObject = userObject;
    246252
    247253    return self;
     254}
     255
     256- (id <_WKFocusedElementInfo>)focusedElementInfo
     257{
     258    return _focusedElementInfo.get();
    248259}
    249260
     
    292303}
    293304
    294 @end
    295 
    296 @interface WKFocusedElementInfo : NSObject <_WKFocusedElementInfo>
    297 - (instancetype)initWithAssistedNodeInformation:(const AssistedNodeInformation&)information isUserInitiated:(BOOL)isUserInitiated;
    298305@end
    299306
     
    31933200{
    31943201    id <_WKInputDelegate> inputDelegate = [_webView _inputDelegate];
     3202    RetainPtr<WKFocusedElementInfo> focusedElementInfo = adoptNS([[WKFocusedElementInfo alloc] initWithAssistedNodeInformation:information isUserInitiated:userIsInteracting]);
    31953203    BOOL shouldShowKeyboard;
    3196     if ([inputDelegate respondsToSelector:@selector(_webView:focusShouldStartInputSession:)]) {
    3197         RetainPtr<WKFocusedElementInfo> focusedElementInfo = adoptNS([[WKFocusedElementInfo alloc] initWithAssistedNodeInformation:information isUserInitiated:userIsInteracting]);
     3204
     3205    if ([inputDelegate respondsToSelector:@selector(_webView:focusShouldStartInputSession:)])
    31983206        shouldShowKeyboard = [inputDelegate _webView:_webView focusShouldStartInputSession:focusedElementInfo.get()];
    3199     } else {
     3207    else {
    32003208        // The default behavior is to allow node assistance if the user is interacting or the keyboard is already active.
    32013209        shouldShowKeyboard = userIsInteracting || _textSelectionAssistant;
     
    32453253
    32463254    if ([inputDelegate respondsToSelector:@selector(_webView:didStartInputSession:)]) {
    3247         _formInputSession = adoptNS([[WKFormInputSession alloc] initWithContentView:self userObject:userObject]);
     3255        _formInputSession = adoptNS([[WKFormInputSession alloc] initWithContentView:self focusedElementInfo:focusedElementInfo.get() userObject:userObject]);
    32483256        [inputDelegate _webView:_webView didStartInputSession:_formInputSession.get()];
    32493257    }
Note: See TracChangeset for help on using the changeset viewer.