Changeset 236691 in webkit
- Timestamp:
- Oct 1, 2018 1:59:19 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r236690 r236691 1 2018-10-01 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] Add SPI to customize the input accessory view when focusing an element 4 https://bugs.webkit.org/show_bug.cgi?id=190152 5 <rdar://problem/42754975> 6 7 Reviewed by Dan Bernstein. 8 9 Adds SPI on WKFormInputSession to customize the input accessory view, alongside the input view. See below for 10 more details. 11 12 Test: KeyboardInputTests.CustomInputViewAndInputAccessoryView 13 14 * UIProcess/API/Cocoa/_WKFormInputSession.h: 15 * UIProcess/ios/WKContentViewInteraction.mm: 16 (-[WKFormInputSession customInputAccessoryView]): 17 (-[WKFormInputSession setCustomInputAccessoryView:]): 18 19 Reload input views when the custom input accessory view changes. 20 21 (-[WKContentView requiresAccessoryView]): 22 23 If a custom input accessory view is specified, return YES. 24 25 (-[WKContentView inputAccessoryView]): 26 27 Return the custom input accessory view if present, and fall back to the default web form accessory view. 28 1 29 2018-10-01 Sihui Liu <sihui_liu@apple.com> 2 30 -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKFormInputSession.h
r235961 r236691 42 42 @property (nonatomic, copy) NSString *accessoryViewCustomButtonTitle; 43 43 @property (nonatomic, strong) UIView *customInputView WK_API_AVAILABLE(ios(10.0)); 44 @property (nonatomic, strong) UIView *customInputAccessoryView WK_API_AVAILABLE(ios(WK_IOS_TBA)); 44 45 @property (nonatomic, copy) NSArray<UITextSuggestion *> *suggestions WK_API_AVAILABLE(ios(10.0)); 45 46 @property (nonatomic) BOOL accessoryViewShouldNotShow WK_API_AVAILABLE(ios(10.0)); -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r236669 r236691 294 294 RetainPtr<WKFocusedElementInfo> _focusedElementInfo; 295 295 RetainPtr<UIView> _customInputView; 296 RetainPtr<UIView> _customInputAccessoryView; 296 297 RetainPtr<NSArray<UITextSuggestion *>> _suggestions; 297 298 BOOL _accessoryViewShouldNotShow; … … 381 382 382 383 _customInputView = customInputView; 384 [_contentView reloadInputViews]; 385 } 386 387 - (UIView *)customInputAccessoryView 388 { 389 return _customInputAccessoryView.get(); 390 } 391 392 - (void)setCustomInputAccessoryView:(UIView *)customInputAccessoryView 393 { 394 if (_customInputAccessoryView == customInputAccessoryView) 395 return; 396 397 _customInputAccessoryView = customInputAccessoryView; 383 398 [_contentView reloadInputViews]; 384 399 } … … 2090 2105 return NO; 2091 2106 2107 if ([_formInputSession customInputAccessoryView]) 2108 return YES; 2109 2092 2110 if (_assistedNodeInformation.inputMode == InputMode::None) 2093 2111 return NO; … … 2134 2152 return nil; 2135 2153 2136 return self.formAccessoryView;2154 return [_formInputSession customInputAccessoryView] ?: self.formAccessoryView; 2137 2155 } 2138 2156 -
trunk/Tools/ChangeLog
r236690 r236691 1 2018-10-01 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [iOS] Add SPI to customize the input accessory view when focusing an element 4 https://bugs.webkit.org/show_bug.cgi?id=190152 5 <rdar://problem/42754975> 6 7 Reviewed by Dan Bernstein. 8 9 Add an API test to verify that setting a custom input accessory view and custom input view on the form input 10 session when focusing an element overrides the first responder's (i.e. WKContentView's) `-inputView` and 11 `-inputAccessoryView`. 12 13 * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm: 14 (webViewWithAutofocusedInput): 15 (TestWebKitAPI::TEST): 16 * TestWebKitAPI/Tests/ios/TestInputDelegate.h: 17 * TestWebKitAPI/Tests/ios/TestInputDelegate.mm: 18 (-[TestInputDelegate setWillStartInputSessionHandler:]): 19 (-[TestInputDelegate willStartInputSessionHandler]): 20 (-[TestInputDelegate _webView:willStartInputSession:]): 21 1 22 2018-10-01 Sihui Liu <sihui_liu@apple.com> 2 23 -
trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm
r235201 r236691 88 88 @end 89 89 90 static RetainPtr<TestWKWebView> webViewWithAutofocusedInput( )90 static RetainPtr<TestWKWebView> webViewWithAutofocusedInput(const RetainPtr<TestInputDelegate>& inputDelegate) 91 91 { 92 92 auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]); 93 auto inputDelegate = adoptNS([[TestInputDelegate alloc] init]);94 93 95 94 bool doneWaiting = false; … … 106 105 } 107 106 107 static RetainPtr<TestWKWebView> webViewWithAutofocusedInput() 108 { 109 auto inputDelegate = adoptNS([TestInputDelegate new]); 110 return webViewWithAutofocusedInput(inputDelegate); 111 } 112 108 113 namespace TestWebKitAPI { 114 115 TEST(KeyboardInputTests, CustomInputViewAndInputAccessoryView) 116 { 117 auto inputView = adoptNS([[UIView alloc] init]); 118 auto inputAccessoryView = adoptNS([[UIView alloc] init]); 119 auto inputDelegate = adoptNS([TestInputDelegate new]); 120 [inputDelegate setWillStartInputSessionHandler:[inputView, inputAccessoryView] (WKWebView *, id<_WKFormInputSession> session) { 121 session.customInputView = inputView.get(); 122 session.customInputAccessoryView = inputAccessoryView.get(); 123 }]; 124 125 auto webView = webViewWithAutofocusedInput(inputDelegate); 126 EXPECT_EQ(inputView.get(), [webView firstResponder].inputView); 127 EXPECT_EQ(inputAccessoryView.get(), [webView firstResponder].inputAccessoryView); 128 } 109 129 110 130 TEST(KeyboardInputTests, CanHandleKeyEventInCompletionHandler) -
trunk/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.h
r234504 r236691 29 29 30 30 #import <WebKit/_WKFocusedElementInfo.h> 31 #import <WebKit/_WKFormInputSession.h> 31 32 #import <WebKit/_WKInputDelegate.h> 32 33 … … 35 36 @interface TestInputDelegate : NSObject <_WKInputDelegate> 36 37 @property (nonatomic, copy) _WKFocusStartsInputSessionPolicy (^focusStartsInputSessionPolicyHandler)(WKWebView *, id <_WKFocusedElementInfo>); 38 @property (nonatomic, copy) void (^willStartInputSessionHandler)(WKWebView *, id <_WKFormInputSession>); 37 39 @end 38 40 -
trunk/Tools/TestWebKitAPI/Tests/ios/TestInputDelegate.mm
r234504 r236691 33 33 @implementation TestInputDelegate { 34 34 BlockPtr<_WKFocusStartsInputSessionPolicy(WKWebView *, id <_WKFocusedElementInfo>)> _focusStartsInputSessionPolicyHandler; 35 BlockPtr<void(WKWebView *, id <_WKFormInputSession>)> _willStartInputSessionHandler; 35 36 } 36 37 … … 45 46 } 46 47 48 - (void)setWillStartInputSessionHandler:(void (^)(WKWebView *, id<_WKFormInputSession>))willStartInputSessionHandler 49 { 50 _willStartInputSessionHandler = makeBlockPtr(willStartInputSessionHandler); 51 } 52 53 - (void (^)(WKWebView *, id<_WKFormInputSession>))willStartInputSessionHandler 54 { 55 return _willStartInputSessionHandler.get(); 56 } 57 47 58 - (_WKFocusStartsInputSessionPolicy)_webView:(WKWebView *)webView decidePolicyForFocusedElement:(id <_WKFocusedElementInfo>)info 48 59 { … … 50 61 } 51 62 63 - (void)_webView:(WKWebView *)webView willStartInputSession:(id<_WKFormInputSession>)inputSession 64 { 65 if (_willStartInputSessionHandler) 66 _willStartInputSessionHandler(webView, inputSession); 67 } 68 52 69 @end 53 70
Note: See TracChangeset
for help on using the changeset viewer.