Title: [240757] trunk/Source/WebKit
- Revision
- 240757
- Author
- [email protected]
- Date
- 2019-01-30 20:41:35 -0800 (Wed, 30 Jan 2019)
Log Message
[iOS] REGRESSION (r238635): Text area fails to re-focus after dismissal of keyboard on support.apple.com
https://bugs.webkit.org/show_bug.cgi?id=193987
<rdar://problem/47230785>
Reviewed by Tim Horton.
It is unnecessary to relinquish first responder status when a user explicitly dismissing
the keyboard. Moreover, doing so prevents key commands from being intercepted when a
hardware keyboard is subsequently attached.
Following r238635 a page becomes focused (accepting of keyboard input) and defocused
when the WKContentView becomes first responder and resigns first responder, respectively.
When a user explicitly dismisses the keyboard by tapping Done (iPhone) or the hide keyboard
button (iPad) then UIKit tells WKContentView to resign its first responder status only
to make its superview, WKWebView, first responder. When a person subsequently taps on the
page again, the WKContentView requests to become the first responder. However changes to
page focus are not guaranteed to be sent to the WebProcess immediately (WebPageProxy::activityStateDidChange()
will schedule an update). In particular, they are not guaranteed to be sent before the
WebProcess is told about a tap. Therefore, the WebProcess has out-of-date information on
focus state of the page. Instead we should detect when WKWebView is being asked to resign
as a result of the keyboard dismissal and refuse the request, taking care to end the current
editing session, blur the focused element, and dismiss the on-screen keyboard.
* Platform/spi/ios/UIKitSPI.h: Expose some SPI.
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView setupInteraction]): Register to receive notifications whenever a user
explicitly dismisses the keyboard.
(-[WKContentView resignFirstResponderForWebView]): If we are being asked to resign as a
result of a user explicitly dismissing the keyboard then refuse to resign.
(-[WKContentView _keyboardDidRequestDismissal:]): Update state, if applicable.
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (240756 => 240757)
--- trunk/Source/WebKit/ChangeLog 2019-01-31 03:56:19 UTC (rev 240756)
+++ trunk/Source/WebKit/ChangeLog 2019-01-31 04:41:35 UTC (rev 240757)
@@ -1,3 +1,37 @@
+2019-01-30 Daniel Bates <[email protected]>
+
+ [iOS] REGRESSION (r238635): Text area fails to re-focus after dismissal of keyboard on support.apple.com
+ https://bugs.webkit.org/show_bug.cgi?id=193987
+ <rdar://problem/47230785>
+
+ Reviewed by Tim Horton.
+
+ It is unnecessary to relinquish first responder status when a user explicitly dismissing
+ the keyboard. Moreover, doing so prevents key commands from being intercepted when a
+ hardware keyboard is subsequently attached.
+
+ Following r238635 a page becomes focused (accepting of keyboard input) and defocused
+ when the WKContentView becomes first responder and resigns first responder, respectively.
+ When a user explicitly dismisses the keyboard by tapping Done (iPhone) or the hide keyboard
+ button (iPad) then UIKit tells WKContentView to resign its first responder status only
+ to make its superview, WKWebView, first responder. When a person subsequently taps on the
+ page again, the WKContentView requests to become the first responder. However changes to
+ page focus are not guaranteed to be sent to the WebProcess immediately (WebPageProxy::activityStateDidChange()
+ will schedule an update). In particular, they are not guaranteed to be sent before the
+ WebProcess is told about a tap. Therefore, the WebProcess has out-of-date information on
+ focus state of the page. Instead we should detect when WKWebView is being asked to resign
+ as a result of the keyboard dismissal and refuse the request, taking care to end the current
+ editing session, blur the focused element, and dismiss the on-screen keyboard.
+
+ * Platform/spi/ios/UIKitSPI.h: Expose some SPI.
+ * UIProcess/ios/WKContentViewInteraction.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView setupInteraction]): Register to receive notifications whenever a user
+ explicitly dismisses the keyboard.
+ (-[WKContentView resignFirstResponderForWebView]): If we are being asked to resign as a
+ result of a user explicitly dismissing the keyboard then refuse to resign.
+ (-[WKContentView _keyboardDidRequestDismissal:]): Update state, if applicable.
+
2019-01-30 Keith Rollin <[email protected]>
Add default constructor for NetworkActivityTracker
Modified: trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h (240756 => 240757)
--- trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2019-01-31 03:56:19 UTC (rev 240756)
+++ trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h 2019-01-31 04:41:35 UTC (rev 240757)
@@ -1145,6 +1145,8 @@
extern NSString * const UIWindowNewScreenUserInfoKey;
extern NSString * const UIWindowWillRotateNotification;
+extern NSString * const UIKeyboardPrivateDidRequestDismissalNotification;
+
extern NSString * const UIKeyboardIsLocalUserInfoKey;
extern UIApplication *UIApp;
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (240756 => 240757)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2019-01-31 03:56:19 UTC (rev 240756)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2019-01-31 04:41:35 UTC (rev 240757)
@@ -306,6 +306,8 @@
BOOL _showDebugTapHighlightsForFastClicking;
BOOL _isZoomingToRevealFocusedElement;
+ BOOL _keyboardDidRequestDismissal;
+
BOOL _becomingFirstResponder;
BOOL _resigningFirstResponder;
BOOL _needsDeferredEndScrollingSelectionUpdate;
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (240756 => 240757)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2019-01-31 03:56:19 UTC (rev 240756)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2019-01-31 04:41:35 UTC (rev 240757)
@@ -741,7 +741,10 @@
[self _registerPreview];
#endif
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_resetShowingTextStyle:) name:UIMenuControllerDidHideMenuNotification object:nil];
+ NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+ [center addObserver:self selector:@selector(_resetShowingTextStyle:) name:UIMenuControllerDidHideMenuNotification object:nil];
+ [center addObserver:self selector:@selector(_keyboardDidRequestDismissal:) name:UIKeyboardPrivateDidRequestDismissalNotification object:nil];
+
_showingTextStyleOptions = NO;
// FIXME: This should be called when we get notified that loading has completed.
@@ -1115,7 +1118,8 @@
// FIXME: Maybe we should call resignFirstResponder on the superclass
// and do nothing if the return value is NO.
- _resigningFirstResponder = YES;
+ SetForScope<BOOL> resigningFirstResponderScope { _resigningFirstResponder, YES };
+
if (!_webView._retainingActiveFocusedState) {
// We need to complete the editing operation before we blur the element.
[self _endEditing];
@@ -1127,13 +1131,18 @@
_inputViewUpdateDeferrer = nullptr;
+ // If the user explicitly dismissed the keyboard then we will lose first responder
+ // status only to gain it back again. Just don't resign in that case.
+ if (_keyboardDidRequestDismissal) {
+ _keyboardDidRequestDismissal = NO;
+ return NO;
+ }
+
bool superDidResign = [super resignFirstResponder];
if (superDidResign)
_page->activityStateDidChange(WebCore::ActivityState::IsFocused);
- _resigningFirstResponder = NO;
-
return superDidResign;
}
@@ -2789,6 +2798,13 @@
[_textSelectionAssistant hideTextStyleOptions];
}
+- (void)_keyboardDidRequestDismissal:(NSNotification *)notification
+{
+ if (![self isFirstResponder])
+ return;
+ _keyboardDidRequestDismissal = YES;
+}
+
- (void)copyForWebView:(id)sender
{
_page->executeEditCommand("copy"_s);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes