Title: [198047] tags/Safari-602.1.22/Source/WebKit2

Diff

Modified: tags/Safari-602.1.22/Source/WebKit2/ChangeLog (198046 => 198047)


--- tags/Safari-602.1.22/Source/WebKit2/ChangeLog	2016-03-11 22:13:42 UTC (rev 198046)
+++ tags/Safari-602.1.22/Source/WebKit2/ChangeLog	2016-03-11 22:25:21 UTC (rev 198047)
@@ -1,3 +1,22 @@
+2016-03-11  Babak Shafiei  <[email protected]>
+
+        Merge r198046.
+
+    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-10  David Kilzer  <[email protected]>
 
         REGRESSION (r197986): Don't try to link to undefined $(WEBKIT_SYSTEM_INTERFACE_LIBRARY)

Modified: tags/Safari-602.1.22/Source/WebKit2/UIProcess/API/Cocoa/_WKFormInputSession.h (198046 => 198047)


--- tags/Safari-602.1.22/Source/WebKit2/UIProcess/API/Cocoa/_WKFormInputSession.h	2016-03-11 22:13:42 UTC (rev 198046)
+++ tags/Safari-602.1.22/Source/WebKit2/UIProcess/API/Cocoa/_WKFormInputSession.h	2016-03-11 22:25:21 UTC (rev 198047)
@@ -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: tags/Safari-602.1.22/Source/WebKit2/UIProcess/API/Cocoa/_WKInputDelegate.h (198046 => 198047)


--- tags/Safari-602.1.22/Source/WebKit2/UIProcess/API/Cocoa/_WKInputDelegate.h	2016-03-11 22:13:42 UTC (rev 198046)
+++ tags/Safari-602.1.22/Source/WebKit2/UIProcess/API/Cocoa/_WKInputDelegate.h	2016-03-11 22:25:21 UTC (rev 198047)
@@ -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: tags/Safari-602.1.22/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (198046 => 198047)


--- tags/Safari-602.1.22/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2016-03-11 22:13:42 UTC (rev 198046)
+++ tags/Safari-602.1.22/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2016-03-11 22:25:21 UTC (rev 198047)
@@ -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

Reply via email to