Changeset 277386 in webkit
- Timestamp:
- May 12, 2021, 1:40:15 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/ios/WKContentView.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r277380 r277386 1 2021-05-12 Aditya Keerthi <akeerthi@apple.com> 2 3 REGRESSION (r275297): Unexpected autofocus when switching tabs 4 https://bugs.webkit.org/show_bug.cgi?id=225710 5 <rdar://problem/77542939> 6 7 Reviewed by Wenson Hsieh. 8 9 r275297 introduced logic to handle a focus environment change by 10 advancing to the next or previous focusable element, depending on the 11 focus context's heading direction. This logic enables a tab or a 12 shift+tab to change the focus from browser chrome directly to an 13 element on a web page. 14 15 However, the focus environment can change through mechanisms other than 16 tab / shift+tab. One example of this is when a user switches tabs. In 17 these cases, the UIFocusHeading supplied by the focus context is 18 UIFocusHeadingNone. Nevertheless, we unconditionally call 19 `-[WKContentView _becomeFirstResponderWithSelectionMovingForward:completionHandler:]` 20 when the focus context changes. Consequently, an element on the web page 21 is always focused when the WKContentView gains focus. 22 23 * UIProcess/ios/WKContentView.mm: 24 (-[WKContentView didUpdateFocusInContext:withAnimationCoordinator:]): 25 26 To fix, ensure we only focus an element on the page if the focus heading 27 is UIFocusHeadingNext or UIFocusHeadingPrevious. UIFocusHeadingNext will 28 focus the first focusable element, while UIFocusHeadingPrevious will focus 29 the last focusable element. 30 31 Note that a call to `-[WKContentView becomeFirstResponder]` is not made 32 if the focus heading is UIFocusHeadingNone. From my testing, I observed 33 that the view already was the first responder in that case. 34 1 35 2021-05-12 Chris Dumez <cdumez@apple.com> 2 36 -
trunk/Source/WebKit/UIProcess/ios/WKContentView.mm
r276523 r277386 556 556 - (void)didUpdateFocusInContext:(UIFocusUpdateContext *)context withAnimationCoordinator:(UIFocusAnimationCoordinator *)coordinator 557 557 { 558 if (context.nextFocusedView == self) 559 [self _becomeFirstResponderWithSelectionMovingForward:context.focusHeading == UIFocusHeadingNext completionHandler:nil]; 558 if (context.nextFocusedView == self) { 559 if (context.focusHeading & UIFocusHeadingNext) 560 [self _becomeFirstResponderWithSelectionMovingForward:YES completionHandler:nil]; 561 else if (context.focusHeading & UIFocusHeadingPrevious) 562 [self _becomeFirstResponderWithSelectionMovingForward:NO completionHandler:nil]; 563 } 560 564 } 561 565
Note:
See TracChangeset
for help on using the changeset viewer.