From 7689dc3caa89e8d0a1cde14a6b658de3567aee40 Mon Sep 17 00:00:00 2001 From: Aaron Klotz Date: Thu, 27 Oct 2016 12:40:50 -0600 Subject: [PATCH] Bug 1310833: Make nsAccessibilityService synchronously query for its MSAA content process ID if the ID is not yet present; r=tbsaunde MozReview-Commit-ID: 9qZNzmwlBNC --HG-- extra : rebase_source : c9135cb54dd223aef28189957701199f17d63e46 --- accessible/base/nsAccessibilityService.cpp | 18 ++++++++++++++++-- dom/ipc/ContentChild.cpp | 7 +++++++ dom/ipc/ContentChild.h | 5 +++++ dom/ipc/ContentParent.cpp | 12 ++++++++++++ dom/ipc/ContentParent.h | 3 +++ dom/ipc/PContent.ipdl | 2 ++ 6 files changed, 45 insertions(+), 2 deletions(-) diff --git a/accessible/base/nsAccessibilityService.cpp b/accessible/base/nsAccessibilityService.cpp index 9a37b9509fcd..f46613115636 100644 --- a/accessible/base/nsAccessibilityService.cpp +++ b/accessible/base/nsAccessibilityService.cpp @@ -44,6 +44,7 @@ #ifdef XP_WIN #include "mozilla/a11y/Compatibility.h" +#include "mozilla/dom/ContentChild.h" #include "HTMLWin32ObjectAccessible.h" #include "mozilla/StaticPtr.h" #endif @@ -1264,10 +1265,23 @@ nsAccessibilityService::Init() gAccessibilityService = this; NS_ADDREF(gAccessibilityService); // will release in Shutdown() - if (XRE_IsParentProcess()) + if (XRE_IsParentProcess()) { gApplicationAccessible = new ApplicationAccessibleWrap(); - else + } else { +#if defined(XP_WIN) + dom::ContentChild* contentChild = dom::ContentChild::GetSingleton(); + MOZ_ASSERT(contentChild); + // If we were instantiated by the chrome process, GetMsaaID() will return + // a non-zero value and we may safely continue with initialization. + if (!contentChild->GetMsaaID()) { + // Since we were not instantiated by chrome, we need to synchronously + // obtain a MSAA content process id. + contentChild->SendGetA11yContentId(); + } +#endif // defined(XP_WIN) + gApplicationAccessible = new ApplicationAccessible(); + } NS_ADDREF(gApplicationAccessible); // will release in Shutdown() gApplicationAccessible->Init(); diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 465d48e2c0c6..60cf1831e153 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -3284,6 +3284,13 @@ ContentChild::RecvBlobURLUnregistration(const nsCString& aURI) return true; } +#if defined(XP_WIN) && defined(ACCESSIBILITY) +bool +ContentChild::SendGetA11yContentId() +{ + return PContentChild::SendGetA11yContentId(&mMsaaID); +} +#endif // defined(XP_WIN) && defined(ACCESSIBILITY) void ContentChild::CreateGetFilesRequest(const nsAString& aDirectoryPath, diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index 40b52e05007e..776f884a630b 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -645,6 +645,11 @@ public: virtual bool RecvBlobURLUnregistration(const nsCString& aURI) override; +#if defined(XP_WIN) && defined(ACCESSIBILITY) + bool + SendGetA11yContentId(); +#endif // defined(XP_WIN) && defined(ACCESSIBILITY) + /** * Helper function for protocols that use the GPU process when available. * Overrides FatalError to just be a warning when communicating with the diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 5053cfcd9f86..ad796cfa7a17 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -5146,6 +5146,18 @@ ContentParent::RecvUnstoreAndBroadcastBlobURLUnregistration(const nsCString& aUR return true; } +bool +ContentParent::RecvGetA11yContentId(uint32_t* aContentId) +{ +#if defined(XP_WIN32) && defined(ACCESSIBILITY) + *aContentId = a11y::AccessibleWrap::GetContentProcessIdFor(ChildID()); + MOZ_ASSERT(*aContentId); + return true; +#else + return false; +#endif +} + } // namespace dom } // namespace mozilla diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index 87c650d5a0b4..ca6a57dc5edf 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -552,6 +552,9 @@ public: virtual bool RecvUnstoreAndBroadcastBlobURLUnregistration(const nsCString& aURI) override; + virtual bool + RecvGetA11yContentId(uint32_t* aContentId) override; + virtual int32_t Pid() const override; // Use the PHangMonitor channel to ask the child to repaint a tab. diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 15fd4f2cd5f3..541a1972a9c9 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -1178,6 +1178,8 @@ parent: async AccumulateChildHistogram(Accumulation[] accumulations); async AccumulateChildKeyedHistogram(KeyedAccumulation[] accumulations); + sync GetA11yContentId() returns (uint32_t aContentId); + both: async AsyncMessage(nsString aMessage, CpowEntry[] aCpows, Principal aPrincipal, ClonedMessageData aData);