Bug 1310833: Modify PContentParent::SendActivateA11y to accept the content process's MSAA ID as a parameter; r=tbsaunde

MozReview-Commit-ID: 9OIpO0G0Q7j
This commit is contained in:
Aaron Klotz 2016-10-20 12:34:16 -06:00
Родитель 710cd95c09
Коммит 40b7b97fd0
7 изменённых файлов: 39 добавлений и 35 удалений

Просмотреть файл

@ -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;
}
/**

Просмотреть файл

@ -48,7 +48,6 @@ private:
private:
IDSet mIDSet;
uint32_t mContentProcessID;
};
} // namespace a11y

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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

Просмотреть файл

@ -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.

Просмотреть файл

@ -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);