Title: [181511] trunk/Source/WebKit2
Revision
181511
Author
[email protected]
Date
2015-03-15 12:30:09 -0700 (Sun, 15 Mar 2015)

Log Message

[iOS] Presenting a modal sheet on top of a WKWebView causes it to lose focused, active state
https://bugs.webkit.org/show_bug.cgi?id=142702

Reviewed by Anders Carlsson.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView becomeFirstResponder]): Override to delegate first responder status to the
WKContentView if possible.
(-[WKWebView _retainActiveFocusedState]): New SPI that prevents view hierarchy changes from
affecting the active and focused state of the view. Increments a counter ivar and returns a
completion block (which callers must call when they’re done) that decrements it back.
* UIProcess/API/Cocoa/WKWebViewInternal.h: Declared new _activeFocusedStateRetainCount ivar
with @package access.
* UIProcess/API/Cocoa/WKWebViewPrivate.h: Declared new method.

* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::isViewWindowActive): Return true if active/focused state is to be
maintained despite not being visible.
(WebKit::PageClientImpl::isViewFocused): Return true if active/focused state is to be
maintained despite not being active.

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView resignFirstResponder]): Don’t blur the assisted node if active/focused
state is to be maintained.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (181510 => 181511)


--- trunk/Source/WebKit2/ChangeLog	2015-03-15 19:13:36 UTC (rev 181510)
+++ trunk/Source/WebKit2/ChangeLog	2015-03-15 19:30:09 UTC (rev 181511)
@@ -1,3 +1,30 @@
+2015-03-15  Dan Bernstein  <[email protected]>
+
+        [iOS] Presenting a modal sheet on top of a WKWebView causes it to lose focused, active state
+        https://bugs.webkit.org/show_bug.cgi?id=142702
+
+        Reviewed by Anders Carlsson.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView becomeFirstResponder]): Override to delegate first responder status to the
+        WKContentView if possible.
+        (-[WKWebView _retainActiveFocusedState]): New SPI that prevents view hierarchy changes from
+        affecting the active and focused state of the view. Increments a counter ivar and returns a
+        completion block (which callers must call when they’re done) that decrements it back.
+        * UIProcess/API/Cocoa/WKWebViewInternal.h: Declared new _activeFocusedStateRetainCount ivar
+        with @package access.
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h: Declared new method.
+
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::isViewWindowActive): Return true if active/focused state is to be
+        maintained despite not being visible.
+        (WebKit::PageClientImpl::isViewFocused): Return true if active/focused state is to be
+        maintained despite not being active.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView resignFirstResponder]): Don’t blur the assisted node if active/focused
+        state is to be maintained.
+
 2015-03-14  Simon Fraser  <[email protected]>
 
         Clean up use of flags in localToContainer-type functions

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


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-03-15 19:13:36 UTC (rev 181510)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2015-03-15 19:30:09 UTC (rev 181511)
@@ -650,6 +650,11 @@
     return [_contentView browsingContextController];
 }
 
+- (BOOL)becomeFirstResponder
+{
+    return [_contentView becomeFirstResponder] || [super becomeFirstResponder];
+}
+
 static inline CGFloat floorToDevicePixel(CGFloat input, float deviceScaleFactor)
 {
     return CGFloor(input * deviceScaleFactor) / deviceScaleFactor;
@@ -1770,6 +1775,17 @@
 {
     return webView->_overridesInterfaceOrientation ? deviceOrientationForUIInterfaceOrientation(webView->_interfaceOrientationOverride) : webView->_page->deviceOrientation();
 }
+
+- (void (^)(void))_retainActiveFocusedState
+{
+    ++_activeFocusedStateRetainCount;
+
+    // FIXME: Use something like CompletionHandlerCallChecker to ensure that the returned block is called before it's released.
+    return [[[self] {
+        --_activeFocusedStateRetainCount;
+    } copy] autorelease];
+}
+
 #endif
 
 - (void)_didRelaunchProcess

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h (181510 => 181511)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h	2015-03-15 19:13:36 UTC (rev 181510)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h	2015-03-15 19:30:09 UTC (rev 181511)
@@ -60,6 +60,10 @@
     RetainPtr<WKWebViewConfiguration> _configuration;
 
     RefPtr<WebKit::WebPageProxy> _page;
+
+#if PLATFORM(IOS)
+    NSUInteger _activeFocusedStateRetainCount;
+#endif
 }
 
 #if PLATFORM(IOS)

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (181510 => 181511)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2015-03-15 19:13:36 UTC (rev 181510)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2015-03-15 19:30:09 UTC (rev 181511)
@@ -151,6 +151,10 @@
 - (void)_killWebContentProcess;
 - (void)_didRelaunchProcess;
 
+// Puts the view into a state where being taken out of the view hierarchy and resigning first responder
+// will not count as becoming inactive and unfocused. The returned block must be called to exit the state.
+- (void (^)(void))_retainActiveFocusedState WK_AVAILABLE(NA, WK_IOS_TBA);
+
 #else
 @property (readonly) NSColor *_pageExtendedBackgroundColor;
 @property (nonatomic, setter=_setDrawsTransparentBackground:) BOOL _drawsTransparentBackground;

Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (181510 => 181511)


--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2015-03-15 19:13:36 UTC (rev 181510)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2015-03-15 19:30:09 UTC (rev 181511)
@@ -171,13 +171,13 @@
 bool PageClientImpl::isViewWindowActive()
 {
     // FIXME: https://bugs.webkit.org/show_bug.cgi?id=133098
-    return isViewVisible();
+    return isViewVisible() || m_webView->_activeFocusedStateRetainCount;
 }
 
 bool PageClientImpl::isViewFocused()
 {
     // FIXME: https://bugs.webkit.org/show_bug.cgi?id=133098
-    return isViewWindowActive();
+    return isViewWindowActive() || m_webView->_activeFocusedStateRetainCount;
 }
 
 bool PageClientImpl::isViewVisible()

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (181510 => 181511)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2015-03-15 19:13:36 UTC (rev 181510)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2015-03-15 19:30:09 UTC (rev 181511)
@@ -517,9 +517,13 @@
 {
     // FIXME: Maybe we should call resignFirstResponder on the superclass
     // and do nothing if the return value is NO.
-    // We need to complete the editing operation before we blur the element.
-    [_inputPeripheral endEditing];
-    _page->blurAssistedNode();
+
+    if (!_webView->_activeFocusedStateRetainCount) {
+        // We need to complete the editing operation before we blur the element.
+        [_inputPeripheral endEditing];
+        _page->blurAssistedNode();
+    }
+
     [self _cancelInteraction];
     [_webSelectionAssistant resignedFirstResponder];
     [_textSelectionAssistant deactivateSelection];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to