Bug 527003 - making sure a11y shutdown and start work with e10s. r=surkov, tbsaunde
MozReview-Commit-ID: 9r5ARjh1DG1
--- a/accessible/base/nsAccessibilityService.h
+++ b/accessible/base/nsAccessibilityService.h
@@ -19,16 +19,21 @@
class nsImageFrame;
class nsIArray;
class nsIPersistentProperties;
class nsPluginFrame;
class nsITreeView;
namespace mozilla {
+
+namespace dom {
+ class ContentChild;
+}
+
namespace a11y {
class ApplicationAccessible;
class xpcAccessibleApplication;
/**
* Return focus manager.
*/
@@ -290,16 +295,17 @@ private:
friend nsAccessibilityService* GetAccService();
friend nsAccessibilityService* GetOrCreateAccService(bool);
friend bool CanShutdownAccService();
friend mozilla::a11y::FocusManager* mozilla::a11y::FocusMgr();
friend mozilla::a11y::SelectionManager* mozilla::a11y::SelectionMgr();
friend mozilla::a11y::ApplicationAccessible* mozilla::a11y::ApplicationAcc();
friend mozilla::a11y::xpcAccessibleApplication* mozilla::a11y::XPCApplicationAcc();
+ friend class mozilla::dom::ContentChild;
friend class xpcAccessibilityService;
};
/**
* Return the accessibility service instance. (Handy global function)
*/
inline nsAccessibilityService*
GetAccService()
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -2459,22 +2459,35 @@ ContentChild::RecvFlushMemory(const nsSt
mozilla::services::GetObserverService();
if (os) {
os->NotifyObservers(nullptr, "memory-pressure", reason.get());
}
return true;
}
bool
-ContentChild::RecvActivateA11y()
+ContentChild::RecvActivateA11y(const bool& aIsPlatformCaller)
{
#ifdef ACCESSIBILITY
// Start accessibility in content process if it's running in chrome
// process.
- GetOrCreateAccService();
+ GetOrCreateAccService(aIsPlatformCaller);
+#endif
+ return true;
+}
+
+bool
+ContentChild::RecvShutdownA11y()
+{
+#ifdef ACCESSIBILITY
+ // Shutdown accessibility in content process if it's shutting down in chrome
+ // process.
+ if (CanShutdownAccService()) {
+ GetAccService()->Shutdown();
+ }
#endif
return true;
}
bool
ContentChild::RecvGarbageCollect()
{
// Rebroadcast the "child-gc-request" so that workers will GC.
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -435,17 +435,19 @@ public:
virtual bool RecvGeolocationError(const uint16_t& errorCode) override;
virtual bool RecvUpdateDictionaryList(InfallibleTArray<nsString>&& aDictionaries) override;
virtual bool RecvAddPermission(const IPC::Permission& permission) override;
virtual bool RecvFlushMemory(const nsString& reason) override;
- virtual bool RecvActivateA11y() override;
+ virtual bool RecvActivateA11y(const bool& aIsPlatformCaller) override;
+
+ virtual bool RecvShutdownA11y() override;
virtual bool RecvGarbageCollect() override;
virtual bool RecvCycleCollect() override;
virtual bool RecvAppInfo(const nsCString& version, const nsCString& buildID,
const nsCString& name, const nsCString& UAName,
const nsCString& ID, const nsCString& vendor) override;
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -270,16 +270,20 @@ using namespace mozilla::system;
#ifdef XP_WIN
#include "mozilla/widget/AudioSession.h"
#endif
#ifdef MOZ_CRASHREPORTER
#include "nsThread.h"
#endif
+#ifdef ACCESSIBILITY
+#include "nsAccessibilityService.h"
+#endif
+
// For VP9Benchmark::sBenchmarkFpsPref
#include "Benchmark.h"
static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID);
#if defined(XP_WIN)
// e10s forced enable pref, defined in nsAppRunner.cpp
extern const char* kForceEnableE10sPref;
@@ -1373,22 +1377,22 @@ ContentParent::Init()
obs->NotifyObservers(static_cast<nsIObserver*>(this), "ipc:content-created", cpId.get());
}
#ifdef ACCESSIBILITY
// If accessibility is running in chrome process then start it in content
// process.
if (nsIPresShell::IsAccessibilityActive()) {
#if !defined(XP_WIN)
- Unused << SendActivateA11y();
+ Unused << SendActivateA11y(nsAccessibilityService::IsPlatformCaller());
#else
// On Windows we currently only enable a11y in the content process
// for testing purposes.
if (Preferences::GetBool(kForceEnableE10sPref, false)) {
- Unused << SendActivateA11y();
+ Unused << SendActivateA11y(nsAccessibilityService::IsPlatformCaller());
}
#endif
}
#endif
#ifdef MOZ_ENABLE_PROFILER_SPS
nsCOMPtr<nsIProfiler> profiler(do_GetService("@mozilla.org/tools/profiler;1"));
bool profilerActive = false;
@@ -2868,29 +2872,34 @@ ContentParent::Observe(nsISupports* aSub
Unused << SendNotifyPhoneStateChange(state);
}
else if(!strcmp(aTopic, NS_VOLUME_REMOVED)) {
nsString volName(aData);
Unused << SendVolumeRemoved(volName);
}
#endif
#ifdef ACCESSIBILITY
- // Make sure accessibility is running in content process when accessibility
- // gets initiated in chrome process.
- else if (aData && (*aData == '1') &&
- !strcmp(aTopic, "a11y-init-or-shutdown")) {
+ else if (aData && !strcmp(aTopic, "a11y-init-or-shutdown")) {
+ if (*aData == '1') {
+ // Make sure accessibility is running in content process when
+ // accessibility gets initiated in chrome process.
#if !defined(XP_WIN)
- Unused << SendActivateA11y();
+ Unused << SendActivateA11y(nsAccessibilityService::IsPlatformCaller());
#else
- // On Windows we currently only enable a11y in the content process
- // for testing purposes.
- if (Preferences::GetBool(kForceEnableE10sPref, false)) {
- Unused << SendActivateA11y();
+ // On Windows we currently only enable a11y in the content process
+ // for testing purposes.
+ if (Preferences::GetBool(kForceEnableE10sPref, false)) {
+ Unused << SendActivateA11y(nsAccessibilityService::IsPlatformCaller());
+ }
+#endif
+ } else {
+ // If possible, shut down accessibility in content process when
+ // accessibility gets shutdown in chrome process.
+ Unused << SendShutdownA11y();
}
-#endif
}
#endif
else if (!strcmp(aTopic, "app-theme-changed")) {
Unused << SendOnAppThemeChanged();
}
#ifdef MOZ_ENABLE_PROFILER_SPS
else if (!strcmp(aTopic, "profiler-started")) {
nsCOMPtr<nsIProfilerStartParams> params(do_QueryInterface(aSubject));
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -541,17 +541,22 @@ child:
async FlushMemory(nsString reason);
async GarbageCollect();
async CycleCollect();
/**
* Start accessibility engine in content process.
*/
- async ActivateA11y();
+ async ActivateA11y(bool isPlatformCaller);
+
+ /**
+ * Shutdown accessibility engine in content process.
+ */
+ async ShutdownA11y();
async AppInfo(nsCString version, nsCString buildID, nsCString name, nsCString UAName,
nsCString ID, nsCString vendor);
async AppInit();
/**
* Send ServiceWorkerRegistrationData to child process.
*/