Changeset 166933 in webkit


Ignore:
Timestamp:
Apr 8, 2014 10:17:44 AM (10 years ago)
Author:
mitz@apple.com
Message:

../WebKit/mac: WebKit part of [Cocoa] Add WKFormDelegate
https://bugs.webkit.org/show_bug.cgi?id=131343

Reviewed by Anders Carlsson.

  • MigrateHeaders.make: Added new WebKit2 headers to WEBKIT2_HEADERS.

../WebKit2: [Cocoa] Add WKFormDelegate
https://bugs.webkit.org/show_bug.cgi?id=131343

Reviewed by Anders Carlsson.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _formDelegate]): Added this accessor.
(-[WKWebView _setFormDelegate:]): Ditto.

  • UIProcess/API/Cocoa/WKWebViewPrivate.h: Declared _formDelegate property.
  • UIProcess/API/Cocoa/_WKFormDelegate.h: Added.
  • UIProcess/API/Cocoa/_WKFormInputSession.h: Added.
  • UIProcess/ios/WKContentView.h: Moved _webView ivar into the @interface…
  • UIProcess/ios/WKContentView.mm: …from the @implementation.
  • UIProcess/ios/WKContentViewInteraction.h: Added _formInputSession ivar and

formAccessoryView property.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKFormInputSession initWithContentView:userObject:]): Added.
(-[WKFormInputSession dealloc]): Added.
(-[WKFormInputSession userObject]): Added.
(-[WKFormInputSession isValid]): Added.
(-[WKFormInputSession accessoryViewCustomButtonTitle]): Added.
(-[WKFormInputSession setAccessoryViewCustomButtonTitle:]): Added.
(-[WKFormInputSession invalidate]): Added.
(-[WKContentView cleanupInteraction]): Invalidate and release the input session.
(-[WKContentView formAccessoryView]): Added this accessor.
(-[WKContentView _startAssistingNode:userObject:]): Create an input session and message the
form delegate.
(-[WKContentView _stopAssistingNode]): Invalidate and release the input session.

  • WebKit2.xcodeproj/project.pbxproj: Added references to new files.
  • WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFormDelegatePrivate.h: Added

comment.

Location:
trunk/Source
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/mac/ChangeLog

    r166928 r166933  
     12014-04-08  Dan Bernstein  <mitz@apple.com>
     2
     3        WebKit part of [Cocoa] Add WKFormDelegate
     4        https://bugs.webkit.org/show_bug.cgi?id=131343
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * MigrateHeaders.make: Added new WebKit2 headers to WEBKIT2_HEADERS.
     9
    1102014-04-08  Daniel Bates  <dabates@apple.com>
    211
  • trunk/Source/WebKit/mac/MigrateHeaders.make

    r166859 r166933  
    288288    _WKActivatedElementInfo.h \
    289289    _WKElementAction.h \
     290    _WKFormDelegate.h \
     291    _WKFormInputSession.h \
    290292    _WKProcessPoolConfiguration.h \
    291293    _WKScriptWorld.h \
  • trunk/Source/WebKit2/ChangeLog

    r166928 r166933  
     12014-04-08  Dan Bernstein  <mitz@apple.com>
     2
     3        [Cocoa] Add WKFormDelegate
     4        https://bugs.webkit.org/show_bug.cgi?id=131343
     5
     6        Reviewed by Anders Carlsson.
     7
     8        * UIProcess/API/Cocoa/WKWebView.mm:
     9        (-[WKWebView _formDelegate]): Added this accessor.
     10        (-[WKWebView _setFormDelegate:]): Ditto.
     11        * UIProcess/API/Cocoa/WKWebViewPrivate.h: Declared _formDelegate property.
     12
     13        * UIProcess/API/Cocoa/_WKFormDelegate.h: Added.
     14
     15        * UIProcess/API/Cocoa/_WKFormInputSession.h: Added.
     16
     17        * UIProcess/ios/WKContentView.h: Moved _webView ivar into the @interface…
     18        * UIProcess/ios/WKContentView.mm: …from the @implementation.
     19
     20        * UIProcess/ios/WKContentViewInteraction.h: Added _formInputSession ivar and
     21        formAccessoryView property.
     22        * UIProcess/ios/WKContentViewInteraction.mm:
     23        (-[WKFormInputSession initWithContentView:userObject:]): Added.
     24        (-[WKFormInputSession dealloc]): Added.
     25        (-[WKFormInputSession userObject]): Added.
     26        (-[WKFormInputSession isValid]): Added.
     27        (-[WKFormInputSession accessoryViewCustomButtonTitle]): Added.
     28        (-[WKFormInputSession setAccessoryViewCustomButtonTitle:]): Added.
     29        (-[WKFormInputSession invalidate]): Added.
     30        (-[WKContentView cleanupInteraction]): Invalidate and release the input session.
     31        (-[WKContentView formAccessoryView]): Added this accessor.
     32        (-[WKContentView _startAssistingNode:userObject:]): Create an input session and message the
     33        form delegate.
     34        (-[WKContentView _stopAssistingNode]): Invalidate and release the input session.
     35
     36        * WebKit2.xcodeproj/project.pbxproj: Added references to new files.
     37
     38        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFormDelegatePrivate.h: Added
     39        comment.
     40
    1412014-04-08  Daniel Bates  <dabates@apple.com>
    242
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r166905 r166933  
    8888    _WKRenderingProgressEvents _observedRenderingProgressEvents;
    8989
     90    WebKit::WeakObjCPtr<id <_WKFormDelegate>> _formDelegate;
     91
    9092#if PLATFORM(IOS)
    9193    RetainPtr<WKScrollView> _scrollView;
     
    11391141}
    11401142
     1143- (id <_WKFormDelegate>)_formDelegate
     1144{
     1145    return _formDelegate.getAutoreleased();
     1146}
     1147
     1148- (void)_setFormDelegate:(id <_WKFormDelegate>)formDelegate
     1149{
     1150    _formDelegate = formDelegate;
     1151}
     1152
    11411153#pragma mark iOS-specific methods
    11421154
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r166767 r166933  
    5757@protocol WKHistoryDelegatePrivate;
    5858@protocol _WKFindDelegate;
     59@protocol _WKFormDelegate;
    5960
    6061@interface WKWebView (WKPrivate)
     
    147148- (void)_hideFindUI;
    148149
     150@property (nonatomic, weak, setter=_setFormDelegate:) id <_WKFormDelegate> _formDelegate;
     151
    149152@end
    150153
  • trunk/Source/WebKit2/UIProcess/ios/WKContentView.h

    r166658 r166933  
    4949@package
    5050    RefPtr<WebKit::WebPageProxy> _page;
     51    WKWebView *_webView;
    5152}
    5253
  • trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm

    r166663 r166933  
    177177    RetainPtr<WKInspectorIndicationView> _inspectorIndicationView;
    178178
    179     WKWebView *_webView;
    180 
    181179    HistoricalVelocityData _historicalKinematicData;
    182180}
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h

    r166900 r166933  
    5959@class WebIOSEvent;
    6060@class WKActionSheetAssistant;
     61@class WKFormInputSession;
    6162
    6263typedef void (^UIWKAutocorrectionCompletionHandler)(UIWKAutocorrectionRects *rectsForInput);
     
    9798    RetainPtr<WKActionSheetAssistant> _actionSheetAssistant;
    9899    RetainPtr<WKAirPlayRoutePicker> _airPlayRoutePicker;
     100    RetainPtr<WKFormInputSession> _formInputSession;
    99101
    100102    std::unique_ptr<WebKit::SmartMagnificationController> _smartMagnificationController;
     
    124126@property (nonatomic, readonly) const WebKit::WKAutoCorrectionData& autocorrectionData;
    125127@property (nonatomic, readonly) const WebKit::AssistedNodeInformation& assistedNodeInformation;
     128@property (nonatomic, readonly) UIWebFormAccessory *formAccessoryView;
     129
    126130- (void)setupInteraction;
    127131- (void)cleanupInteraction;
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r166900 r166933  
    4040#import "WKFormInputControl.h"
    4141#import "WKFormSelectControl.h"
     42#import "WKWebViewPrivate.h"
     43#import "_WKFormDelegate.h"
     44#import "_WKFormInputSession.h"
    4245#import <DataDetectorsUI/DDDetectionController.h>
    4346#import <UIKit/_UIHighlightView.h>
     
    131134@end
    132135
     136@interface WKFormInputSession : NSObject <_WKFormInputSession>
     137
     138- (instancetype)initWithContentView:(WKContentView *)view userObject:(NSObject <NSSecureCoding> *)userObject;
     139- (void)invalidate;
     140
     141@end
     142
     143@implementation WKFormInputSession {
     144    WKContentView *_contentView;
     145    RetainPtr<NSObject <NSSecureCoding>> _userObject;
     146}
     147
     148- (instancetype)initWithContentView:(WKContentView *)view userObject:(NSObject <NSSecureCoding> *)userObject
     149{
     150    if (!(self = [super init]))
     151        return nil;
     152
     153    _contentView = view;
     154    _userObject = userObject;
     155
     156    return self;
     157}
     158
     159- (NSObject <NSSecureCoding> *)userObject
     160{
     161    return _userObject.get();
     162}
     163
     164- (BOOL)isValid
     165{
     166    return _contentView != nil;
     167}
     168
     169- (NSString *)accessoryViewCustomButtonTitle
     170{
     171    return [[[_contentView formAccessoryView] _autofill] title];
     172}
     173
     174- (void)setAccessoryViewCustomButtonTitle:(NSString *)title
     175{
     176    if (title.length)
     177        [[_contentView formAccessoryView] showAutoFillButtonWithTitle:title];
     178    else
     179        [[_contentView formAccessoryView] hideAutoFillButton];
     180}
     181
     182- (void)invalidate
     183{
     184    _contentView = nil;
     185}
     186
     187@end
     188
    133189@implementation WKContentView (WKInteraction)
    134190
     
    180236    _textSelectionAssistant = nil;
    181237    _actionSheetAssistant = nil;
     238    [_formInputSession invalidate];
     239    _formInputSession = nil;
    182240    [_touchEventGestureRecognizer setDelegate:nil];
    183241    [_singleTapGestureRecognizer setDelegate:nil];
     
    18751933}
    18761934
     1935- (UIWebFormAccessory *)formAccessoryView
     1936{
     1937    return _formAccessoryView.get();
     1938}
     1939
    18771940- (void)_startAssistingNode:(const AssistedNodeInformation&)information userObject:(NSObject <NSSecureCoding> *)userObject
    18781941{
     
    19001963    // _inputPeripheral has been initialized in inputView called by reloadInputViews.
    19011964    [_inputPeripheral beginEditing];
     1965
     1966    id <_WKFormDelegate> formDelegate = [_webView _formDelegate];
     1967    if ([formDelegate respondsToSelector:@selector(_webView:didStartInputSession:)]) {
     1968        _formInputSession = adoptNS([[WKFormInputSession alloc] initWithContentView:self userObject:userObject]);
     1969        [formDelegate _webView:_webView didStartInputSession:_formInputSession.get()];
     1970    }
    19021971}
    19031972
    19041973- (void)_stopAssistingNode
    19051974{
     1975    [_formInputSession invalidate];
     1976    _formInputSession = nil;
    19061977    _isEditable = NO;
    19071978    _assistedNodeInformation.elementType = WKTypeNone;
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r166890 r166933  
    689689                37A5E01318BBF937000A081E /* _WKActivatedElementInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37A5E01118BBF937000A081E /* _WKActivatedElementInfo.mm */; };
    690690                37A5E01418BBF93F000A081E /* _WKActivatedElementInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 37A5E01218BBF937000A081E /* _WKActivatedElementInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
     691                37A64E5518F38E3C00EB30F1 /* _WKFormDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 37A64E5418F38E3C00EB30F1 /* _WKFormDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
     692                37A64E5718F38F4600EB30F1 /* _WKFormInputSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 37A64E5618F38F4600EB30F1 /* _WKFormInputSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
    691693                37C4C08618149C5B003688B9 /* WKBackForwardListItem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37C4C08418149C5B003688B9 /* WKBackForwardListItem.mm */; };
    692694                37C4C08718149C5B003688B9 /* WKBackForwardListItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C4C08518149C5B003688B9 /* WKBackForwardListItem.h */; settings = {ATTRIBUTES = (Public, ); }; };
     
    25082510                37A5E01118BBF937000A081E /* _WKActivatedElementInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKActivatedElementInfo.mm; sourceTree = "<group>"; };
    25092511                37A5E01218BBF937000A081E /* _WKActivatedElementInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKActivatedElementInfo.h; sourceTree = "<group>"; };
     2512                37A64E5418F38E3C00EB30F1 /* _WKFormDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKFormDelegate.h; sourceTree = "<group>"; };
     2513                37A64E5618F38F4600EB30F1 /* _WKFormInputSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKFormInputSession.h; sourceTree = "<group>"; };
    25102514                37C4C08418149C5B003688B9 /* WKBackForwardListItem.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKBackForwardListItem.mm; sourceTree = "<group>"; };
    25112515                37C4C08518149C5B003688B9 /* WKBackForwardListItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBackForwardListItem.h; sourceTree = "<group>"; };
     
    46634667                                379A873B18BBFF0700588AF2 /* _WKElementActionInternal.h */,
    46644668                                005D158E18E4C4EB00734619 /* _WKFindDelegate.h */,
     4669                                37A64E5418F38E3C00EB30F1 /* _WKFormDelegate.h */,
     4670                                37A64E5618F38F4600EB30F1 /* _WKFormInputSession.h */,
    46654671                                1A43E828188F3CDC009E4D30 /* _WKProcessPoolConfiguration.h */,
    46664672                                1A43E827188F3CDC009E4D30 /* _WKProcessPoolConfiguration.mm */,
     
    70027008                                1AB8A1F418400B8F00E9AE69 /* WKPageFindClient.h in Headers */,
    70037009                                75E749EA180DBB9800088BA6 /* WebOriginDataManagerMessages.h in Headers */,
     7010                                37A64E5518F38E3C00EB30F1 /* _WKFormDelegate.h in Headers */,
    70047011                                51ACBBA0127A8F2C00D203B9 /* WebContextMenuProxyMac.h in Headers */,
    70057012                                BCCB75C61203A1CE00222D1B /* WebContextMessageKinds.h in Headers */,
     
    73297336                                BC407604124FF0270068F20A /* WKSerializedScriptValue.h in Headers */,
    73307337                                0FCB4E4C18BBE044000FCFC9 /* WKContentView.h in Headers */,
     7338                                37A64E5718F38F4600EB30F1 /* _WKFormInputSession.h in Headers */,
    73317339                                1F604BAA1889FBB800EE0395 /* WKRenderingProgressEventsInternal.h in Headers */,
    73327340                                1F7506B81859165D00EC0FF7 /* WKWebProcessPlugInFrameInternal.h in Headers */,
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFormDelegatePrivate.h

    r166900 r166933  
    3838- (void)_webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller didFocusTextField:(WKWebProcessPlugInNodeHandle *)textField inFrame:(WKWebProcessPlugInFrame *)frame;
    3939- (void)_webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller willSubmitForm:(WKWebProcessPlugInNodeHandle *)form toFrame:(WKWebProcessPlugInFrame *)frame fromFrame:(WKWebProcessPlugInFrame *)sourceFrame withValues:(NSDictionary *)values;
     40
     41// The return value is exposed in the UI process via the userObject property of the _WKFormInputSession object.
    4042- (NSObject <NSSecureCoding> *)_webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller willBeginInputSessionForElement:(WKWebProcessPlugInNodeHandle *)node inFrame:(WKWebProcessPlugInFrame *)frame;
    4143
Note: See TracChangeset for help on using the changeset viewer.