From 40b7b97fd0451ffe4e31ee4178af7023bcb725e1 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: 9OIpO0G0Q7j --- 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 006735001033..4072ae59a668 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -507,6 +507,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) @@ -2445,13 +2448,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 57ab3579c31c..49dd46ac70f4 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -446,7 +446,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; @@ -567,6 +567,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; } @@ -687,6 +691,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 834a234b90c7..93d5ce7c5268 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -1361,10 +1361,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 @@ -2790,10 +2791,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 @@ -5198,18 +5200,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 395dbde270e4..c24e28132058 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -553,9 +553,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 32790ac3ef02..119e4a7c4a77 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -511,8 +511,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). @@ -1185,8 +1188,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);