From e97105dc3a9a1afcabed26528b74ffa52eaad9e6 Mon Sep 17 00:00:00 2001 From: Aaron Klotz Date: Thu, 20 Oct 2016 12:34:16 -0600 Subject: [PATCH] Bug 1310833: Modify PContentParent::SendActivateA11y to accept the content process's MSAA ID as a parameter; r=tbsaunde MozReview-Commit-ID: DCnYvWQRA5W --HG-- extra : rebase_source : 7f1ebc6d4aabdaec3ea51421c26621f90c8e61e6 --- accessible/windows/msaa/MsaaIdGenerator.cpp | 15 ++++++-------- accessible/windows/msaa/MsaaIdGenerator.h | 1 - dom/ipc/ContentChild.cpp | 12 +++++++++-- dom/ipc/ContentChild.h | 14 ++++++++++++- dom/ipc/ContentParent.cpp | 22 ++++++--------------- dom/ipc/ContentParent.h | 3 --- dom/ipc/PContent.ipdl | 7 ++++--- 7 files changed, 39 insertions(+), 35 deletions(-) diff --git a/accessible/windows/msaa/MsaaIdGenerator.cpp b/accessible/windows/msaa/MsaaIdGenerator.cpp index 847f5f112a72..5f4b333fa3db 100644 --- a/accessible/windows/msaa/MsaaIdGenerator.cpp +++ b/accessible/windows/msaa/MsaaIdGenerator.cpp @@ -85,16 +85,14 @@ private: constexpr MsaaIdGenerator::MsaaIdGenerator() : mIDSet(kNumUniqueIDBits) - , mContentProcessID(0) {} uint32_t MsaaIdGenerator::GetID() { - static const uint32_t kContentProcessId = ResolveContentProcessID(); uint32_t id = mIDSet.GetID(); MOZ_ASSERT(id <= ((1UL << kNumUniqueIDBits) - 1UL)); - return detail::BuildMsaaID(id, kContentProcessId); + return detail::BuildMsaaID(id, ResolveContentProcessID()); } void @@ -104,7 +102,7 @@ MsaaIdGenerator::ReleaseID(AccessibleWrap* aAccWrap) uint32_t id = aAccWrap->GetExistingID(); MOZ_ASSERT(id != AccessibleWrap::kNoID); detail::MsaaIDCracker cracked(id); - if (cracked.GetContentProcessId() != mContentProcessID) { + if (cracked.GetContentProcessId() != ResolveContentProcessID()) { // This may happen if chrome holds a proxy whose ID was originally generated // by a content process. Since ReleaseID only has meaning in the process // that originally generated that ID, we ignore ReleaseID calls for any ID @@ -126,9 +124,8 @@ bool MsaaIdGenerator::IsIDForThisContentProcess(uint32_t aID) { MOZ_ASSERT(XRE_IsContentProcess()); - static const uint32_t kContentProcessId = ResolveContentProcessID(); detail::MsaaIDCracker cracked(aID); - return cracked.GetContentProcessId() == kContentProcessId; + return cracked.GetContentProcessId() == ResolveContentProcessID(); } bool @@ -158,10 +155,10 @@ MsaaIdGenerator::ResolveContentProcessID() } dom::ContentChild* contentChild = dom::ContentChild::GetSingleton(); - Unused << contentChild->SendGetA11yContentId(&mContentProcessID); + uint32_t result = contentChild->GetMsaaID(); - MOZ_ASSERT(mContentProcessID); - return mContentProcessID; + MOZ_ASSERT(result); + return result; } /** diff --git a/accessible/windows/msaa/MsaaIdGenerator.h b/accessible/windows/msaa/MsaaIdGenerator.h index 1b05342286c0..b845e8473168 100644 --- a/accessible/windows/msaa/MsaaIdGenerator.h +++ b/accessible/windows/msaa/MsaaIdGenerator.h @@ -48,7 +48,6 @@ private: private: IDSet mIDSet; - uint32_t mContentProcessID; }; } // namespace a11y diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 14d56b455062..465d48e2c0c6 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -502,6 +502,9 @@ ContentChild* ContentChild::sSingleton; ContentChild::ContentChild() : mID(uint64_t(-1)) +#if defined(XP_WIN) && defined(ACCESSIBILITY) + , mMsaaID(0) +#endif , mCanOverrideProcessName(true) , mIsAlive(true) , mShuttingDown(false) @@ -2415,13 +2418,18 @@ ContentChild::RecvFlushMemory(const nsString& reason) } bool -ContentChild::RecvActivateA11y() +ContentChild::RecvActivateA11y(const uint32_t& aMsaaID) { #ifdef ACCESSIBILITY +#ifdef XP_WIN + MOZ_ASSERT(aMsaaID != 0); + mMsaaID = aMsaaID; +#endif // XP_WIN + // Start accessibility in content process if it's running in chrome // process. GetOrCreateAccService(nsAccessibilityService::eMainProcess); -#endif +#endif // ACCESSIBILITY return true; } diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index 58db4fe37345..40b52e05007e 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -434,7 +434,7 @@ public: virtual bool RecvFlushMemory(const nsString& reason) override; - virtual bool RecvActivateA11y() override; + virtual bool RecvActivateA11y(const uint32_t& aMsaaID) override; virtual bool RecvShutdownA11y() override; virtual bool RecvGarbageCollect() override; @@ -555,6 +555,10 @@ public: ContentParentId GetID() const { return mID; } +#if defined(XP_WIN) && defined(ACCESSIBILITY) + uint32_t GetMsaaID() const { return mMsaaID; } +#endif + bool IsForApp() const { return mIsForApp; } bool IsForBrowser() const { return mIsForBrowser; } @@ -675,6 +679,14 @@ private: */ ContentParentId mID; +#if defined(XP_WIN) && defined(ACCESSIBILITY) + /** + * This is an a11y-specific unique id for the content process that is + * generated by the chrome process. + */ + uint32_t mMsaaID; +#endif + AppInfo mAppInfo; bool mIsForApp; diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 58ef1d29d791..5053cfcd9f86 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -1356,10 +1356,11 @@ ContentParent::Init() if (nsIPresShell::IsAccessibilityActive()) { #if defined(XP_WIN) if (IsVistaOrLater()) { - Unused << SendActivateA11y(); + Unused << + SendActivateA11y(a11y::AccessibleWrap::GetContentProcessIdFor(ChildID())); } #else - Unused << SendActivateA11y(); + Unused << SendActivateA11y(0); #endif } #endif @@ -2781,10 +2782,11 @@ ContentParent::Observe(nsISupports* aSubject, // accessibility gets initiated in chrome process. #if defined(XP_WIN) if (IsVistaOrLater()) { - Unused << SendActivateA11y(); + Unused << + SendActivateA11y(a11y::AccessibleWrap::GetContentProcessIdFor(ChildID())); } #else - Unused << SendActivateA11y(); + Unused << SendActivateA11y(0); #endif } else { // If possible, shut down accessibility in content process when @@ -5144,18 +5146,6 @@ 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 ca6a57dc5edf..87c650d5a0b4 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -552,9 +552,6 @@ 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 175752b2494d..15fd4f2cd5f3 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -505,8 +505,11 @@ child: /** * Start accessibility engine in content process. + * @param aMsaaID is an a11y-specific unique id for the content process + * that is generated by the chrome process. Only used on + * Windows; pass 0 on other platforms. */ - async ActivateA11y(); + async ActivateA11y(uint32_t aMsaaID); /** * Shutdown accessibility engine in content process (if not in use). @@ -1175,8 +1178,6 @@ 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);