Title: [169095] trunk/Source/WebKit2
Revision
169095
Author
[email protected]
Date
2014-05-19 19:22:35 -0700 (Mon, 19 May 2014)

Log Message

WebKit2/iOS: parented view should be considered hidden if app is backgrounded
https://bugs.webkit.org/show_bug.cgi?id=133099
radar://16942183

Reviewed by Simon Fraser.

* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::isViewWindowActive):
    - implemented in terms of isViewVisible.
    - FIXME: https://bugs.webkit.org/show_bug.cgi?id=133098
(WebKit::PageClientImpl::isViewFocused):
    - implemented in terms of isViewWindowActive.
    - FIXME: https://bugs.webkit.org/show_bug.cgi?id=133098
(WebKit::PageClientImpl::isViewVisible):
    - take UIApplication applicationState into account in determining visibility.
(WebKit::PageClientImpl::isViewVisibleOrOccluded):
    - implemented in terms of isViewVisible.
(WebKit::PageClientImpl::isVisuallyIdle):
    - implemented in terms of isViewVisible.
* UIProcess/ios/WKContentView.mm:
(-[WKContentView initWithFrame:context:WebKit::configuration:WebKit::webView:]):
    - register for UIApplicationDidEnterBackgroundNotification.
(-[WKContentView _applicationDidEnterBackground:]):
(-[WKContentView _applicationWillEnterForeground:]):
    - when the application state changes all flags except IsInWindow may be affected.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (169094 => 169095)


--- trunk/Source/WebKit2/ChangeLog	2014-05-20 02:03:47 UTC (rev 169094)
+++ trunk/Source/WebKit2/ChangeLog	2014-05-20 02:22:35 UTC (rev 169095)
@@ -1,3 +1,31 @@
+2014-05-19  Gavin Barraclough  <[email protected]>
+
+        WebKit2/iOS: parented view should be considered hidden if app is backgrounded
+        https://bugs.webkit.org/show_bug.cgi?id=133099
+        radar://16942183
+
+        Reviewed by Simon Fraser.
+
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::isViewWindowActive):
+            - implemented in terms of isViewVisible.
+            - FIXME: https://bugs.webkit.org/show_bug.cgi?id=133098
+        (WebKit::PageClientImpl::isViewFocused):
+            - implemented in terms of isViewWindowActive.
+            - FIXME: https://bugs.webkit.org/show_bug.cgi?id=133098
+        (WebKit::PageClientImpl::isViewVisible):
+            - take UIApplication applicationState into account in determining visibility.
+        (WebKit::PageClientImpl::isViewVisibleOrOccluded):
+            - implemented in terms of isViewVisible.
+        (WebKit::PageClientImpl::isVisuallyIdle):
+            - implemented in terms of isViewVisible.
+        * UIProcess/ios/WKContentView.mm:
+        (-[WKContentView initWithFrame:context:WebKit::configuration:WebKit::webView:]):
+            - register for UIApplicationDidEnterBackgroundNotification.
+        (-[WKContentView _applicationDidEnterBackground:]):
+        (-[WKContentView _applicationWillEnterForeground:]):
+            - when the application state changes all flags except IsInWindow may be affected.
+
 2014-05-19  Enrica Casucci  <[email protected]>
 
         WK2 iOS: Pressing the form navigation button causes the keyboard to be dismissed.

Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (169094 => 169095)


--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2014-05-20 02:03:47 UTC (rev 169094)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm	2014-05-20 02:22:35 UTC (rev 169095)
@@ -110,17 +110,19 @@
 
 bool PageClientImpl::isViewWindowActive()
 {
-    return [m_webView window];
+    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=133098
+    return isViewVisible();
 }
 
 bool PageClientImpl::isViewFocused()
 {
-    return [m_webView window];
+    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=133098
+    return isViewWindowActive();
 }
 
 bool PageClientImpl::isViewVisible()
 {
-    return [m_webView window];
+    return [m_webView window] && [UIApplication sharedApplication].applicationState != UIApplicationStateBackground;
 }
 
 bool PageClientImpl::isViewInWindow()
@@ -130,12 +132,12 @@
 
 bool PageClientImpl::isViewVisibleOrOccluded()
 {
-    return [m_webView window];
+    return isViewVisible();
 }
 
 bool PageClientImpl::isVisuallyIdle()
 {
-    return ![m_webView window];
+    return !isViewVisible();
 }
 
 void PageClientImpl::processDidExit()

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm (169094 => 169095)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm	2014-05-20 02:03:47 UTC (rev 169094)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm	2014-05-20 02:22:35 UTC (rev 169095)
@@ -208,10 +208,9 @@
 
     self.layer.hitTestsAsOpaque = YES;
 
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:[UIApplication sharedApplication]];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillEnterForeground:) name:UIApplicationWillEnterForegroundNotification object:[UIApplication sharedApplication]];
-
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillResignActive:) name:UIApplicationWillResignActiveNotification object:[UIApplication sharedApplication]];
-
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:[UIApplication sharedApplication]];
 
     return self;
@@ -461,9 +460,15 @@
     _page->applicationWillResignActive();
 }
 
+- (void)_applicationDidEnterBackground:(NSNotification*)notification
+{
+    _page->viewStateDidChange(ViewState::AllFlags & ~ViewState::IsInWindow);
+}
+
 - (void)_applicationWillEnterForeground:(NSNotification*)notification
 {
     _page->applicationWillEnterForeground();
+    _page->viewStateDidChange(ViewState::AllFlags & ~ViewState::IsInWindow);
 }
 
 - (void)_applicationDidBecomeActive:(NSNotification*)notification
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to