AX: [iOS] Post accessibility notification when a web process changes its suspended...
authorn_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Dec 2017 21:02:30 +0000 (21:02 +0000)
committern_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Dec 2017 21:02:30 +0000 (21:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180458
<rdar://problem/35869115>

Reviewed by Chris Dumez.

Post accessibility notification with the pid information when a web process
becomes suspended or resumes running.

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::actualPrepareToSuspend):
(WebKit::WebProcess::processDidResume):
* WebProcess/WebProcess.h:
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::accessibilityProcessSuspendedNotification):

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

Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebProcess.cpp
Source/WebKit/WebProcess/WebProcess.h
Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

index 69610e7..aabb795 100644 (file)
@@ -1,3 +1,21 @@
+2017-12-06  Nan Wang  <n_wang@apple.com>
+
+        AX: [iOS] Post accessibility notification when a web process changes its suspended state
+        https://bugs.webkit.org/show_bug.cgi?id=180458
+        <rdar://problem/35869115>
+
+        Reviewed by Chris Dumez.
+
+        Post accessibility notification with the pid information when a web process
+        becomes suspended or resumes running.
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::actualPrepareToSuspend):
+        (WebKit::WebProcess::processDidResume):
+        * WebProcess/WebProcess.h:
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::accessibilityProcessSuspendedNotification):
+
 2017-12-06  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed build fix, removed unused lambda capture.
index f02c53b..eed7002 100644 (file)
@@ -1332,6 +1332,10 @@ void WebProcess::actualPrepareToSuspend(ShouldAcknowledgeWhenReadyToSuspend shou
     destroyRenderingResources();
 #endif
 
+#if PLATFORM(IOS)
+    accessibilityProcessSuspendedNotification(true);
+#endif
+
     markAllLayersVolatile([this, shouldAcknowledgeWhenReadyToSuspend] {
         RELEASE_LOG(ProcessSuspension, "%p - WebProcess::markAllLayersVolatile() Successfuly marked all layers as volatile", this);
 
@@ -1418,6 +1422,10 @@ void WebProcess::processDidResume()
 
     cancelMarkAllLayersVolatile();
     setAllLayerTreeStatesFrozen(false);
+    
+#if PLATFORM(IOS)
+    accessibilityProcessSuspendedNotification(false);
+#endif
 }
 
 void WebProcess::pageDidEnterWindow(uint64_t pageID)
index 1556efc..ef6aa12 100644 (file)
@@ -232,6 +232,10 @@ public:
 
     WebCacheStorageProvider& cacheStorageProvider() { return m_cacheStorageProvider.get(); }
 
+#if PLATFORM(IOS)
+    void accessibilityProcessSuspendedNotification(bool);
+#endif
+
 private:
     WebProcess();
     ~WebProcess();
index 71acd05..9fde200 100644 (file)
 #import <stdio.h>
 
 #if PLATFORM(IOS)
+#import <UIKit/UIAccessibility.h>
 #import <pal/spi/ios/GraphicsServicesSPI.h>
+
+#if USE(APPLE_INTERNAL_SDK)
+#import <AXRuntime/AXDefines.h>
+#import <AXRuntime/AXNotificationConstants.h>
+#else
+#define kAXPidStatusChangedNotification 0
+#endif
+
 #endif
 
 #if USE(OS_STATE)
@@ -523,4 +532,11 @@ void _WKSetCrashReportApplicationSpecificInformation(NSString *infoString)
     return setCrashReportApplicationSpecificInformation((__bridge CFStringRef)infoString);
 }
 
+#if PLATFORM(IOS)
+void WebProcess::accessibilityProcessSuspendedNotification(bool suspended)
+{
+    UIAccessibilityPostNotification(kAXPidStatusChangedNotification, @{ @"pid" : @(getpid()), @"suspended" : @(suspended) });
+}
+#endif
+
 } // namespace WebKit