Title: [195651] trunk/Source/WebKit2
Revision
195651
Author
[email protected]
Date
2016-01-26 19:16:06 -0800 (Tue, 26 Jan 2016)

Log Message

REGRESSION (r194557): Keyboard shortcuts stop working after the WKWebView is unparented and reparented
https://bugs.webkit.org/show_bug.cgi?id=153492
<rdar://problem/24138989>

Reviewed by Dan Bernstein.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView canBecomeFirstResponder]):
(-[WKContentView becomeFirstResponder]):
(-[WKContentView resignFirstResponder]):
When WKWebView is unparented, WKContentView will attempt to resignFirstResponder upwards,
first asking WKWebView. After r194557, WKWebView will accept first responder and forward
it on to the WKContentView, which will happily accept it again, despite being the view
that's trying to resign. This will cause us to completely lose first responder,
where it was actually supposed to propagate up above WKWebView to the client.

Keep track of when WKContentView is resigning first responder, and don't
let it become first responder while it is doing so, breaking the cycle.

* UIProcess/ios/WKContentView.h:
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView canBecomeFirstResponder]):
If the WKContentView is currently in the process of resigning first responder status,
we shouldn't accept it, because clients expect to receive it.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (195650 => 195651)


--- trunk/Source/WebKit2/ChangeLog	2016-01-27 03:05:49 UTC (rev 195650)
+++ trunk/Source/WebKit2/ChangeLog	2016-01-27 03:16:06 UTC (rev 195651)
@@ -1,3 +1,31 @@
+2016-01-26  Tim Horton  <[email protected]>
+
+        REGRESSION (r194557): Keyboard shortcuts stop working after the WKWebView is unparented and reparented
+        https://bugs.webkit.org/show_bug.cgi?id=153492
+        <rdar://problem/24138989>
+
+        Reviewed by Dan Bernstein.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView canBecomeFirstResponder]):
+        (-[WKContentView becomeFirstResponder]):
+        (-[WKContentView resignFirstResponder]):
+        When WKWebView is unparented, WKContentView will attempt to resignFirstResponder upwards,
+        first asking WKWebView. After r194557, WKWebView will accept first responder and forward
+        it on to the WKContentView, which will happily accept it again, despite being the view
+        that's trying to resign. This will cause us to completely lose first responder,
+        where it was actually supposed to propagate up above WKWebView to the client.
+
+        Keep track of when WKContentView is resigning first responder, and don't
+        let it become first responder while it is doing so, breaking the cycle.
+
+        * UIProcess/ios/WKContentView.h:
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView canBecomeFirstResponder]):
+        If the WKContentView is currently in the process of resigning first responder status,
+        we shouldn't accept it, because clients expect to receive it.
+
 2016-01-26  I-Ting Liu  <[email protected]>
 
         Implement wildcard matching for plug-in policy host.

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (195650 => 195651)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-01-27 03:05:49 UTC (rev 195650)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-01-27 03:16:06 UTC (rev 195651)
@@ -841,6 +841,8 @@
 
 - (BOOL)canBecomeFirstResponder
 {
+    if (self._currentContentView == _contentView && [_contentView isResigningFirstResponder])
+        return NO;
     return YES;
 }
 

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentView.h (195650 => 195651)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentView.h	2016-01-27 03:05:49 UTC (rev 195650)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentView.h	2016-01-27 03:16:06 UTC (rev 195651)
@@ -62,6 +62,7 @@
 @property (nonatomic, readonly) BOOL isAssistingNode;
 @property (nonatomic, getter=isShowingInspectorIndication) BOOL showingInspectorIndication;
 @property (nonatomic, readonly) BOOL isBackground;
+@property (nonatomic, readonly, getter=isResigningFirstResponder) BOOL resigningFirstResponder;
 
 - (instancetype)initWithFrame:(CGRect)frame processPool:(WebKit::WebProcessPool&)processPool configuration:(Ref<API::PageConfiguration>&&)configuration webView:(WKWebView *)webView;
 

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (195650 => 195651)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2016-01-27 03:05:49 UTC (rev 195650)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2016-01-27 03:16:06 UTC (rev 195651)
@@ -161,6 +161,8 @@
     BOOL _didAccessoryTabInitiateFocus;
     BOOL _isExpectingFastSingleTapCommit;
     BOOL _showDebugTapHighlightsForFastClicking;
+
+    BOOL _resigningFirstResponder;
 }
 
 @end

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (195650 => 195651)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2016-01-27 03:05:49 UTC (rev 195650)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2016-01-27 03:16:06 UTC (rev 195651)
@@ -669,6 +669,8 @@
 
 - (BOOL)canBecomeFirstResponder
 {
+    if (_resigningFirstResponder)
+        return NO;
     // We might want to return something else
     // if we decide to enable/disable interaction programmatically.
     return YES;
@@ -676,6 +678,8 @@
 
 - (BOOL)becomeFirstResponder
 {
+    if (_resigningFirstResponder)
+        return NO;
     BOOL didBecomeFirstResponder = [super becomeFirstResponder];
     if (didBecomeFirstResponder)
         [_textSelectionAssistant activateSelection];
@@ -688,6 +692,8 @@
     // FIXME: Maybe we should call resignFirstResponder on the superclass
     // and do nothing if the return value is NO.
 
+    _resigningFirstResponder = YES;
+
     if (!_webView->_activeFocusedStateRetainCount) {
         // We need to complete the editing operation before we blur the element.
         [_inputPeripheral endEditing];
@@ -698,7 +704,11 @@
     [_webSelectionAssistant resignedFirstResponder];
     [_textSelectionAssistant deactivateSelection];
 
-    return [super resignFirstResponder];
+    bool superDidResign = [super resignFirstResponder];
+
+    _resigningFirstResponder = NO;
+
+    return superDidResign;
 }
 
 #if ENABLE(TOUCH_EVENTS)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to