Changeset 246229 in webkit
- Timestamp:
- Jun 7, 2019 6:37:37 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r246228 r246229 1 2019-06-07 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Allow clients to vend custom -inputView and -inputAccessoryView by overriding WKWebView methods 4 https://bugs.webkit.org/show_bug.cgi?id=198631 5 <rdar://problem/51505431> 6 7 Reviewed by Tim Horton. 8 9 Allow WKWebView API clients to override WKContentView's default input view and/or input accessory view by 10 subclassing WKWebView and implementing -inputView or -inputAccessoryView. 11 12 * UIProcess/API/Cocoa/WKWebView.mm: 13 (-[WKWebView inputAccessoryView]): 14 (-[WKWebView inputView]): 15 * UIProcess/ios/WKContentViewInteraction.h: 16 * UIProcess/ios/WKContentViewInteraction.mm: 17 (-[WKContentView inputView]): 18 (-[WKContentView inputViewForWebView]): 19 (-[WKContentView inputAccessoryView]): 20 (-[WKContentView inputAccessoryViewForWebView]): 21 1 22 2019-06-07 Tim Horton <timothy_horton@apple.com> 2 23 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
r245993 r246229 4586 4586 } 4587 4587 4588 - (UIView *)inputAccessoryView 4589 { 4590 return [_contentView inputAccessoryViewForWebView]; 4591 } 4592 4593 - (UIView *)inputView 4594 { 4595 return [_contentView inputViewForWebView]; 4596 } 4597 4588 4598 #endif // PLATFORM(IOS_FAMILY) 4589 4599 -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
r245998 r246229 384 384 @property (nonatomic, readonly) UIWebFormAccessory *formAccessoryView; 385 385 @property (nonatomic, readonly) UITextInputAssistantItem *inputAssistantItemForWebView; 386 @property (nonatomic, readonly) UIView *inputViewForWebView; 387 @property (nonatomic, readonly) UIView *inputAccessoryViewForWebView; 386 388 #if ENABLE(POINTER_EVENTS) 387 389 @property (nonatomic, readonly) BOOL preventsPanningInXAxis; -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r246226 r246229 1716 1716 - (UIView *)inputView 1717 1717 { 1718 return [_webView inputView]; 1719 } 1720 1721 - (UIView *)inputViewForWebView 1722 { 1718 1723 if (!hasFocusedElement(_focusedElementInformation)) 1719 1724 return nil; … … 2573 2578 2574 2579 - (UIView *)inputAccessoryView 2580 { 2581 return [_webView inputAccessoryView]; 2582 } 2583 2584 - (UIView *)inputAccessoryViewForWebView 2575 2585 { 2576 2586 if (![self requiresAccessoryView]) -
trunk/Tools/ChangeLog
r246222 r246229 1 2019-06-07 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Allow clients to vend custom -inputView and -inputAccessoryView by overriding WKWebView methods 4 https://bugs.webkit.org/show_bug.cgi?id=198631 5 <rdar://problem/51505431> 6 7 Reviewed by Tim Horton. 8 9 Add an API test that overrides -[WKWebView inputView] and -[WKWebView inputAccessoryView]. 10 11 * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm: 12 (-[CustomInputWebView initWithFrame:configuration:inputView:inputAccessoryView:]): 13 (-[CustomInputWebView inputView]): 14 (-[CustomInputWebView inputAccessoryView]): 15 (TestWebKitAPI::TEST): 16 1 17 2019-06-07 Daniel Bates <dabates@apple.com> 2 18 -
trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm
r245338 r246229 149 149 @end 150 150 151 @interface CustomInputWebView : TestWKWebView 152 - (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration inputView:(UIView *)inputView inputAccessoryView:(UIView *)inputAccessoryView; 153 @end 154 155 @implementation CustomInputWebView { 156 RetainPtr<UIView> _customInputView; 157 RetainPtr<UIView> _customInputAccessoryView; 158 } 159 160 - (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration inputView:(UIView *)inputView inputAccessoryView:(UIView *)inputAccessoryView 161 { 162 if (self = [super initWithFrame:frame configuration:configuration]) { 163 _customInputView = inputView; 164 _customInputAccessoryView = inputAccessoryView; 165 } 166 return self; 167 } 168 169 - (UIView *)inputView 170 { 171 return _customInputView.get(); 172 } 173 174 - (UIView *)inputAccessoryView 175 { 176 return _customInputAccessoryView.get(); 177 } 178 179 @end 180 151 181 static RetainPtr<TestWKWebView> webViewWithAutofocusedInput(const RetainPtr<TestInputDelegate>& inputDelegate) 152 182 { … … 432 462 } 433 463 464 TEST(KeyboardInputTests, OverrideInputViewAndInputAccessoryView) 465 { 466 auto inputView = adoptNS([[UIView alloc] init]); 467 auto inputAccessoryView = adoptNS([[UIView alloc] init]); 468 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 469 auto webView = adoptNS([[CustomInputWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 568) configuration:configuration.get() inputView:inputView.get() inputAccessoryView:inputAccessoryView.get()]); 470 auto contentView = [webView textInputContentView]; 471 472 EXPECT_EQ(inputAccessoryView.get(), [contentView inputAccessoryView]); 473 EXPECT_EQ(inputView.get(), [contentView inputView]); 474 } 475 434 476 } // namespace TestWebKitAPI 435 477
Note: See TracChangeset
for help on using the changeset viewer.