[iOS] Improve detection of when web views go to background / foreground
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Apr 2019 22:26:07 +0000 (22:26 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Apr 2019 22:26:07 +0000 (22:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197035
<rdar://problem/45281182>

Reviewed by Tim Horton.

Source/WebKit:

Improve detection of when web views go to background / foreground on iOS.

* UIProcess/ApplicationStateTracker.mm:
(WebKit::ApplicationStateTracker::ApplicationStateTracker): Deleted.
(WebKit::ApplicationStateTracker::~ApplicationStateTracker): Deleted.
(WebKit::ApplicationStateTracker::applicationDidEnterBackground): Deleted.
(WebKit::ApplicationStateTracker::applicationDidFinishSnapshottingAfterEnteringBackground): Deleted.
(WebKit::ApplicationStateTracker::applicationWillEnterForeground): Deleted.

Source/WTF:

Add build time flag.

* wtf/FeatureDefines.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244441 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/FeatureDefines.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ApplicationStateTracker.mm

index 57a0f30..d9914fc 100644 (file)
@@ -1,3 +1,15 @@
+2019-04-18  Chris Dumez  <cdumez@apple.com>
+
+        [iOS] Improve detection of when web views go to background / foreground
+        https://bugs.webkit.org/show_bug.cgi?id=197035
+        <rdar://problem/45281182>
+
+        Reviewed by Tim Horton.
+
+        Add build time flag.
+
+        * wtf/FeatureDefines.h:
+
 2019-04-18  Jer Noble  <jer.noble@apple.com>
 
         Add support for parsing FairPlayStreaming PSSH boxes.
index e76e8dc..515ffff 100644 (file)
@@ -183,6 +183,12 @@ the public iOS SDK. See <https://webkit.org/b/179167>. */
 #endif
 #endif
 
+#if !defined(HAVE_UISCENE)
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000
+#define HAVE_UISCENE 1
+#endif
+#endif
+
 #if !defined(HAVE_AVSTREAMSESSION)
 #define HAVE_AVSTREAMSESSION 0
 #endif
index d91083c..b77e3f6 100644 (file)
@@ -1,3 +1,20 @@
+2019-04-18  Chris Dumez  <cdumez@apple.com>
+
+        [iOS] Improve detection of when web views go to background / foreground
+        https://bugs.webkit.org/show_bug.cgi?id=197035
+        <rdar://problem/45281182>
+
+        Reviewed by Tim Horton.
+
+        Improve detection of when web views go to background / foreground on iOS.
+
+        * UIProcess/ApplicationStateTracker.mm:
+        (WebKit::ApplicationStateTracker::ApplicationStateTracker): Deleted.
+        (WebKit::ApplicationStateTracker::~ApplicationStateTracker): Deleted.
+        (WebKit::ApplicationStateTracker::applicationDidEnterBackground): Deleted.
+        (WebKit::ApplicationStateTracker::applicationDidFinishSnapshottingAfterEnteringBackground): Deleted.
+        (WebKit::ApplicationStateTracker::applicationWillEnterForeground): Deleted.
+
 2019-04-18  Jer Noble  <jer.noble@apple.com>
 
         Refactoring: Pull all fullscreen code out of Document and into its own helper class
index 645d5f5..a23d4bf 100644 (file)
@@ -105,11 +105,19 @@ ApplicationStateTracker::ApplicationStateTracker(UIView *view, SEL didEnterBackg
     case ApplicationType::Application: {
         m_isInBackground = application.applicationState == UIApplicationStateBackground;
 
+#if HAVE(UISCENE)
+        m_didEnterBackgroundObserver = [notificationCenter addObserverForName:UISceneDidEnterBackgroundNotification object:window.windowScene queue:nil usingBlock:[this](NSNotification *) {
+#else
         m_didEnterBackgroundObserver = [notificationCenter addObserverForName:UIApplicationDidEnterBackgroundNotification object:application queue:nil usingBlock:[this](NSNotification *) {
+#endif
             applicationDidEnterBackground();
         }];
 
+#if HAVE(UISCENE)
+        m_willEnterForegroundObserver = [notificationCenter addObserverForName:UISceneWillEnterForegroundNotification object:window.windowScene queue:nil usingBlock:[this](NSNotification *) {
+#else
         m_willEnterForegroundObserver = [notificationCenter addObserverForName:UIApplicationWillEnterForegroundNotification object:application queue:nil usingBlock:[this](NSNotification *) {
+#endif
             applicationWillEnterForeground();
         }];
         break;