Changeset 243153 in webkit
- Timestamp:
- Mar 19, 2019 11:25:21 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r243149 r243153 1 2019-03-19 Daniel Bates <dabates@apple.com> 2 3 [iOS] Focus not preserved when switching between tabs 4 https://bugs.webkit.org/show_bug.cgi?id=195820 5 <rdar://problem/43614450> 6 7 Reviewed by Brent Fulgham. 8 9 Fixes a usability annoyance when using a hardware keyboard; focus is not preserved when switching between tabs. 10 Do not unconditionally tell the WebProcess to blur the currently focused element when the content view (WKContentView) 11 resigns first responder. Instead only tell it to blur when the content view is resigning because either the 12 accessory view was dismissed (Done button was pressed) or the keyboard was dismissed (the hide keyboard button 13 was pressed). 14 15 * UIProcess/ios/WKContentViewInteraction.h: 16 * UIProcess/ios/WKContentViewInteraction.mm: Add new ivar to track whether the content view is resigning 17 first responder status because the accessory view is being dismissed. 18 (-[WKContentView resignFirstResponderForWebView]): Only tell WebKit to blur the focused element if we are 19 resigning because the accessory view is being dismissed or the keyboard was hidden. We continue to do all 20 other steps when resigning, including hiding the keyboard. Note that by not telling WebKit to blur the 21 focused element we let it's focus controller manage the focused element with respect to the current 22 page activation state (i.e. whether the content view is first responder or not). When the content view 23 becomes the first responder then WebKit's focus controller will be told that the page has become activated 24 and will tell the UIProcess to focus the currently focused element, which will bring up the keyboard. 25 (-[WKContentView accessoryDone]): Update state so we know that a subsequent call to resign first responder 26 was due to the accessory view being dismissed. 27 1 28 2019-03-19 Per Arne Vollan <pvollan@apple.com> 2 29 -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
r243102 r243153 312 312 BOOL _becomingFirstResponder; 313 313 BOOL _resigningFirstResponder; 314 BOOL _dismissingAccessory; 314 315 BOOL _needsDeferredEndScrollingSelectionUpdate; 315 316 BOOL _isChangingFocus; -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r243102 r243153 1175 1175 // We need to complete the editing operation before we blur the element. 1176 1176 [self _endEditing]; 1177 _page->blurFocusedElement(); 1177 if (_dismissingAccessory || _keyboardDidRequestDismissal) 1178 _page->blurFocusedElement(); 1178 1179 } 1179 1180 … … 3692 3693 - (void)accessoryDone 3693 3694 { 3695 SetForScope<BOOL> dismissingAccessoryScope { _dismissingAccessory, YES }; 3694 3696 [self resignFirstResponder]; 3695 3697 } -
trunk/Tools/ChangeLog
r243141 r243153 1 2019-03-19 Daniel Bates <dabates@apple.com> 2 3 [iOS] Focus not preserved when switching between tabs 4 https://bugs.webkit.org/show_bug.cgi?id=195820 5 <rdar://problem/43614450> 6 7 Reviewed by Brent Fulgham. 8 9 Add tests to ensure that we restore focus when resigning and becoming first responder. 10 11 * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm: 12 (TestWebKitAPI::TEST): 13 1 14 2019-03-19 Alex Christensen <achristensen@webkit.org> 2 15 -
trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm
r242339 r243153 275 275 } 276 276 277 TEST(KeyboardInputTests, CaretSelectionRectAfterRestoringFirstResponder )277 TEST(KeyboardInputTests, CaretSelectionRectAfterRestoringFirstResponderWithRetainActiveFocusedState) 278 278 { 279 279 auto expectedCaretRect = CGRectMake(16, 13, 2, 15); … … 291 291 } 292 292 293 TEST(KeyboardInputTests, RangedSelectionRectAfterRestoringFirstResponder )293 TEST(KeyboardInputTests, RangedSelectionRectAfterRestoringFirstResponderWithRetainActiveFocusedState) 294 294 { 295 295 NSArray *expectedSelectionRects = @[ [NSValue valueWithCGRect:CGRectMake(16, 13, 24, 15)] ]; … … 304 304 [webView resignFirstResponder]; 305 305 restoreActiveFocusState(); 306 [webView waitForSelectionViewRectsToBecome:@[ ]]; 307 308 [webView becomeFirstResponder]; 309 [webView waitForSelectionViewRectsToBecome:expectedSelectionRects]; 310 } 311 312 TEST(KeyboardInputTests, CaretSelectionRectAfterRestoringFirstResponder) 313 { 314 auto expectedCaretRect = CGRectMake(16, 13, 2, 15); 315 auto webView = webViewWithAutofocusedInput(); 316 EXPECT_WK_STREQ("INPUT", [webView stringByEvaluatingJavaScript:@"document.activeElement.tagName"]); 317 [webView waitForCaretViewFrameToBecome:expectedCaretRect]; 318 319 [webView resignFirstResponder]; 320 [webView waitForCaretViewFrameToBecome:CGRectZero]; 321 322 [webView becomeFirstResponder]; 323 [webView waitForCaretViewFrameToBecome:expectedCaretRect]; 324 } 325 326 TEST(KeyboardInputTests, RangedSelectionRectAfterRestoringFirstResponder) 327 { 328 NSArray *expectedSelectionRects = @[ [NSValue valueWithCGRect:CGRectMake(16, 13, 24, 15)] ]; 329 330 auto webView = webViewWithAutofocusedInput(); 331 [[webView textInputContentView] insertText:@"hello"]; 332 [webView selectAll:nil]; 333 EXPECT_WK_STREQ("INPUT", [webView stringByEvaluatingJavaScript:@"document.activeElement.tagName"]); 334 [webView waitForSelectionViewRectsToBecome:expectedSelectionRects]; 335 336 [webView resignFirstResponder]; 306 337 [webView waitForSelectionViewRectsToBecome:@[ ]]; 307 338
Note: See TracChangeset
for help on using the changeset viewer.