Title: [198046] trunk/Source/WebKit2
- Revision
- 198046
- Author
- [email protected]
- Date
- 2016-03-11 14:13:42 -0800 (Fri, 11 Mar 2016)
Log 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 <[email protected]> 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.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (198045 => 198046)
--- trunk/Source/WebKit2/ChangeLog 2016-03-11 21:53:34 UTC (rev 198045)
+++ trunk/Source/WebKit2/ChangeLog 2016-03-11 22:13:42 UTC (rev 198046)
@@ -1,3 +1,18 @@
+2016-03-11 Chelsea Pugh <[email protected]>
+
+ [iOS] Allow clients to specify text suggestions to be used for a form input session
+ https://bugs.webkit.org/show_bug.cgi?id=155343
+
+ 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.
+
2016-03-11 Anders Carlsson <[email protected]>
Creating and releasing a WKBackForwardListItem crashes
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKFormInputSession.h (198045 => 198046)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKFormInputSession.h 2016-03-11 21:53:34 UTC (rev 198045)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKFormInputSession.h 2016-03-11 22:13:42 UTC (rev 198046)
@@ -30,6 +30,8 @@
#import <Foundation/Foundation.h>
#import <WebKit/_WKFocusedElementInfo.h>
+@class UITextSuggestion;
+
@protocol _WKFormInputSession <NSObject>
@property (nonatomic, readonly, getter=isValid) BOOL valid;
@@ -39,6 +41,7 @@
#if TARGET_OS_IPHONE
@property (nonatomic, copy) NSString *accessoryViewCustomButtonTitle;
@property (nonatomic, strong) UIView *customInputView WK_AVAILABLE(NA, WK_IOS_TBA);
+@property (nonatomic, copy) NSArray<UITextSuggestion *> *suggestions WK_AVAILABLE(NA, WK_IOS_TBA);
#endif
@end
Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKInputDelegate.h (198045 => 198046)
--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKInputDelegate.h 2016-03-11 21:53:34 UTC (rev 198045)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKInputDelegate.h 2016-03-11 22:13:42 UTC (rev 198046)
@@ -29,6 +29,7 @@
#import <Foundation/Foundation.h>
+@class UITextSuggestion;
@class WKWebView;
@protocol _WKFocusedElementInfo;
@protocol _WKFormInputSession;
@@ -45,6 +46,7 @@
- (void)_webView:(WKWebView *)webView accessoryViewCustomButtonTappedInFormInputSession:(id <_WKFormInputSession>)inputSession;
- (BOOL)_webView:(WKWebView *)webView hasSuggestionsForCurrentStringInInputSession:(id <_WKFormInputSession>)inputSession;
- (NSArray *)_webView:(WKWebView *)webView suggestionsForString:(NSString *)string inInputSession:(id <_WKFormInputSession>)inputSession;
+- (void)_webView:(WKWebView *)webView insertTextSuggestion:(UITextSuggestion *)suggestion inInputSession:(id <_WKFormInputSession>)inputSession WK_AVAILABLE(NA, WK_IOS_TBA);
#endif
@end
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (198045 => 198046)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2016-03-11 21:53:34 UTC (rev 198045)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2016-03-11 22:13:42 UTC (rev 198046)
@@ -260,6 +260,7 @@
RetainPtr<NSObject <NSSecureCoding>> _userObject;
RetainPtr<WKFocusedElementInfo> _focusedElementInfo;
RetainPtr<UIView> _customInputView;
+ RetainPtr<NSArray<UITextSuggestion *>> _suggestions;
}
- (instancetype)initWithContentView:(WKContentView *)view focusedElementInfo:(WKFocusedElementInfo *)elementInfo userObject:(NSObject <NSSecureCoding> *)userObject
@@ -318,6 +319,24 @@
[_contentView reloadInputViews];
}
+- (NSArray<UITextSuggestion *> *)suggestions
+{
+ return _suggestions.get();
+}
+
+- (void)setSuggestions:(NSArray<UITextSuggestion *> *)suggestions
+{
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
+ id <UITextInputSuggestionDelegate> suggestionDelegate = (id <UITextInputSuggestionDelegate>)_contentView.inputDelegate;
+ _suggestions = adoptNS([suggestions copy]);
+ // FIXME 25102224: Remove this dispatch_after once race condition causing keyboard suggestions to overwrite
+ // the suggestions being set is resolved
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(20 * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{
+ [suggestionDelegate setSuggestions:suggestions];
+ });
+#endif
+}
+
- (void)invalidate
{
_contentView = nil;
@@ -2603,6 +2622,15 @@
{
[self.inputDelegate selectionDidChange:self];
}
+
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
+- (void)insertTextSuggestion:(UITextSuggestion *)textSuggestion
+{
+ id <_WKInputDelegate> inputDelegate = [_webView _inputDelegate];
+ if ([inputDelegate respondsToSelector:@selector(_webView:insertTextSuggestion:inInputSession:)])
+ [inputDelegate _webView:_webView insertTextSuggestion:textSuggestion inInputSession:_formInputSession.get()];
+}
+#endif
- (NSString *)textInRange:(UITextRange *)range
{
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes