Title: [195702] branches/safari-601.1.46-branch/Source/WebKit2

Diff

Modified: branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog (195701 => 195702)


--- branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog	2016-01-27 23:45:46 UTC (rev 195701)
+++ branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog	2016-01-27 23:55:43 UTC (rev 195702)
@@ -1,3 +1,35 @@
+2016-01-27  Babak Shafiei  <[email protected]>
+
+        Merge r195651.
+
+    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-25  Matthew Hanson  <[email protected]>
 
         Merge r195424. rdar://problem/24222456

Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (195701 => 195702)


--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-01-27 23:45:46 UTC (rev 195701)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2016-01-27 23:55:43 UTC (rev 195702)
@@ -767,6 +767,8 @@
 
 - (BOOL)canBecomeFirstResponder
 {
+    if (self._currentContentView == _contentView && [_contentView isResigningFirstResponder])
+        return NO;
     return YES;
 }
 

Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentView.h (195701 => 195702)


--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentView.h	2016-01-27 23:45:46 UTC (rev 195701)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentView.h	2016-01-27 23:55:43 UTC (rev 195702)
@@ -60,6 +60,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:(WebKit::WebPageConfiguration)webPageConfiguration webView:(WKWebView *)webView;
 - (instancetype)initWithFrame:(CGRect)frame processPool:(WebKit::WebProcessPool&)processPool configuration:(WebKit::WebPageConfiguration)webPageConfiguration wkView:(WKView *)webView;

Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (195701 => 195702)


--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2016-01-27 23:45:46 UTC (rev 195701)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2016-01-27 23:55:43 UTC (rev 195702)
@@ -165,6 +165,8 @@
     BOOL _didAccessoryTabInitiateFocus;
     BOOL _isExpectingFastSingleTapCommit;
     BOOL _showDebugTapHighlightsForFastClicking;
+
+    BOOL _resigningFirstResponder;
 }
 
 @end

Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (195701 => 195702)


--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2016-01-27 23:45:46 UTC (rev 195701)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2016-01-27 23:55:43 UTC (rev 195702)
@@ -562,6 +562,8 @@
 
 - (BOOL)canBecomeFirstResponder
 {
+    if (_resigningFirstResponder)
+        return NO;
     // We might want to return something else
     // if we decide to enable/disable interaction programmatically.
     return YES;
@@ -569,6 +571,8 @@
 
 - (BOOL)becomeFirstResponder
 {
+    if (_resigningFirstResponder)
+        return NO;
     BOOL didBecomeFirstResponder = [super becomeFirstResponder];
     if (didBecomeFirstResponder)
         [_textSelectionAssistant activateSelection];
@@ -581,6 +585,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];
@@ -591,7 +597,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