From 3184ccc8f2f8ebe21f6839d9ea48c4b753292c8f Mon Sep 17 00:00:00 2001 From: Alexander Surkov Date: Thu, 21 Jul 2011 13:37:32 +0900 Subject: [PATCH] Bug 671510 - make sure accessible tree is created for content processes, r=jones.chris.g, sr=Olli.Pettay, f=felipc --- dom/ipc/ContentChild.cpp | 16 ++++++++++++++++ dom/ipc/ContentChild.h | 2 ++ dom/ipc/ContentParent.cpp | 23 +++++++++++++++++++++++ dom/ipc/PContent.ipdl | 5 +++++ 4 files changed, 46 insertions(+) diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index c6148a23789..7df66b27877 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -104,6 +104,10 @@ #define getpid _getpid #endif +#ifdef ACCESSIBILITY +#include "nsIAccessibilityService.h" +#endif + using namespace mozilla::ipc; using namespace mozilla::net; using namespace mozilla::places; @@ -734,6 +738,18 @@ ContentChild::RecvFlushMemory(const nsString& reason) return true; } +bool +ContentChild::RecvActivateA11y() +{ +#ifdef ACCESSIBILITY + // Start accessibility in content process if it's running in chrome + // process. + nsCOMPtr accService = + do_GetService("@mozilla.org/accessibilityService;1"); +#endif + return true; +} + nsString& ContentChild::GetIndexedDBPath() { diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index ab3000f49bc..db220eeaeec 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -146,6 +146,8 @@ public: virtual bool RecvFlushMemory(const nsString& reason); + virtual bool RecvActivateA11y(); + #ifdef ANDROID gfxIntSize GetScreenSize() { return mScreenSize; } #endif diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 45758f7b509..6c9cc16940e 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -62,6 +62,7 @@ #include "nsExternalHelperAppService.h" #include "nsCExternalHandlerService.h" #include "nsFrameMessageManager.h" +#include "nsIPresShell.h" #include "nsIAlertsService.h" #include "nsToolkitCompsCID.h" #include "nsIDOMGeoGeolocation.h" @@ -179,6 +180,9 @@ ContentParent::Init() obs->AddObserver(this, NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC, PR_FALSE); obs->AddObserver(this, "child-memory-reporter-request", PR_FALSE); obs->AddObserver(this, "memory-pressure", PR_FALSE); +#ifdef ACCESSIBILITY + obs->AddObserver(this, "a11y-init-or-shutdown", PR_FALSE); +#endif } nsCOMPtr prefs(do_GetService(NS_PREFSERVICE_CONTRACTID)); if (prefs) { @@ -193,6 +197,14 @@ ContentParent::Init() if (obs) { obs->NotifyObservers(nsnull, "ipc:content-created", nsnull); } + +#ifdef ACCESSIBILITY + // If accessibility is running in chrome process then start it in content + // process. + if (nsIPresShell::IsAccessibilityActive()) { + SendActivateA11y(); + } +#endif } void @@ -257,6 +269,9 @@ ContentParent::ActorDestroy(ActorDestroyReason why) obs->RemoveObserver(static_cast(this), "memory-pressure"); obs->RemoveObserver(static_cast(this), "child-memory-reporter-request"); obs->RemoveObserver(static_cast(this), NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC); +#ifdef ACCESSIBILITY + obs->RemoveObserver(static_cast(this), "a11y-init-or-shutdown"); +#endif } // clear the child memory reporters @@ -656,6 +671,14 @@ ContentParent::Observe(nsISupports* aSubject, else if (!strcmp(aTopic, "child-memory-reporter-request")) { SendPMemoryReportRequestConstructor(); } +#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")) { + SendActivateA11y(); + } +#endif return NS_OK; } diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 597a2e12a80..f158b72911e 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -129,6 +129,11 @@ child: FlushMemory(nsString reason); + /** + * Start accessibility engine in content process. + */ + ActivateA11y(); + parent: PNecko(); PCrashReporter();