Changeset 198046 in webkit


Ignore:
Timestamp:
Mar 11, 2016 2:13:42 PM (8 years ago)
Author:
mitz@apple.com
Message:

[iOS] Allow clients to specify text suggestions to be used for a form input session
https://bugs.webkit.org/show_bug.cgi?id=155343

Patch by Chelsea Pugh <cpugh@apple.com> on 2016-03-11
Reviewed by Dan Bernstein.

  • UIProcess/API/Cocoa/_WKFormInputSession.h:
  • UIProcess/API/Cocoa/_WKInputDelegate.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKFormInputSession suggestions]): Add a getter for suggestions.
(-[WKFormInputSession setSuggestions:]): Add a setter, which calls setSuggestions with our suggestions on the input delegate.
(-[WKContentView insertTextSuggestion:]): Call _webView:insertTextSuggestion:inInputSession: on our input delegate so clients know
a text suggestion was tapped.

Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r198041 r198046  
     12016-03-11  Chelsea Pugh  <cpugh@apple.com>
     2
     3        [iOS] Allow clients to specify text suggestions to be used for a form input session
     4        https://bugs.webkit.org/show_bug.cgi?id=155343
     5
     6        Reviewed by Dan Bernstein.
     7
     8        * UIProcess/API/Cocoa/_WKFormInputSession.h:
     9        * UIProcess/API/Cocoa/_WKInputDelegate.h:
     10        * UIProcess/ios/WKContentViewInteraction.mm:
     11        (-[WKFormInputSession suggestions]): Add a getter for suggestions.
     12        (-[WKFormInputSession setSuggestions:]): Add a setter, which calls setSuggestions with our suggestions on the input delegate.
     13        (-[WKContentView insertTextSuggestion:]): Call _webView:insertTextSuggestion:inInputSession: on our input delegate so clients know
     14        a text suggestion was tapped.
     15
    1162016-03-11  Anders Carlsson  <andersca@apple.com>
    217
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKFormInputSession.h

    r191535 r198046  
    3131#import <WebKit/_WKFocusedElementInfo.h>
    3232
     33@class UITextSuggestion;
     34
    3335@protocol _WKFormInputSession <NSObject>
    3436
     
    4042@property (nonatomic, copy) NSString *accessoryViewCustomButtonTitle;
    4143@property (nonatomic, strong) UIView *customInputView WK_AVAILABLE(NA, WK_IOS_TBA);
     44@property (nonatomic, copy) NSArray<UITextSuggestion *> *suggestions WK_AVAILABLE(NA, WK_IOS_TBA);
    4245#endif
    4346
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKInputDelegate.h

    r191228 r198046  
    3030#import <Foundation/Foundation.h>
    3131
     32@class UITextSuggestion;
    3233@class WKWebView;
    3334@protocol _WKFocusedElementInfo;
     
    4647- (BOOL)_webView:(WKWebView *)webView hasSuggestionsForCurrentStringInInputSession:(id <_WKFormInputSession>)inputSession;
    4748- (NSArray *)_webView:(WKWebView *)webView suggestionsForString:(NSString *)string inInputSession:(id <_WKFormInputSession>)inputSession;
     49- (void)_webView:(WKWebView *)webView insertTextSuggestion:(UITextSuggestion *)suggestion inInputSession:(id <_WKFormInputSession>)inputSession WK_AVAILABLE(NA, WK_IOS_TBA);
    4850#endif
    4951
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r198033 r198046  
    261261    RetainPtr<WKFocusedElementInfo> _focusedElementInfo;
    262262    RetainPtr<UIView> _customInputView;
     263    RetainPtr<NSArray<UITextSuggestion *>> _suggestions;
    263264}
    264265
     
    317318    _customInputView = customInputView;
    318319    [_contentView reloadInputViews];
     320}
     321
     322- (NSArray<UITextSuggestion *> *)suggestions
     323{
     324    return _suggestions.get();
     325}
     326
     327- (void)setSuggestions:(NSArray<UITextSuggestion *> *)suggestions
     328{
     329#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
     330    id <UITextInputSuggestionDelegate> suggestionDelegate = (id <UITextInputSuggestionDelegate>)_contentView.inputDelegate;
     331    _suggestions = adoptNS([suggestions copy]);
     332    // FIXME 25102224: Remove this dispatch_after once race condition causing keyboard suggestions to overwrite
     333    // the suggestions being set is resolved
     334    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(20 * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{
     335        [suggestionDelegate setSuggestions:suggestions];
     336    });
     337#endif
    319338}
    320339
     
    26042623    [self.inputDelegate selectionDidChange:self];
    26052624}
     2625   
     2626#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
     2627- (void)insertTextSuggestion:(UITextSuggestion *)textSuggestion
     2628{
     2629    id <_WKInputDelegate> inputDelegate = [_webView _inputDelegate];
     2630    if ([inputDelegate respondsToSelector:@selector(_webView:insertTextSuggestion:inInputSession:)])
     2631        [inputDelegate _webView:_webView insertTextSuggestion:textSuggestion inInputSession:_formInputSession.get()];
     2632}
     2633#endif
    26062634
    26072635- (NSString *)textInRange:(UITextRange *)range
Note: See TracChangeset for help on using the changeset viewer.