Bug 1304449: Part 4 - Change Windows a11y MSAA id generation to partition based on content process id; r=tbsaunde

MozReview-Commit-ID: 1IBkP20uc1f

--HG--
extra : rebase_source : d0861da3419534f04f2e9de66157b8cde57c1ccd
This commit is contained in:
Aaron Klotz 2016-10-05 15:56:20 -06:00
Родитель 5dea7c01ee
Коммит a90989b900
15 изменённых файлов: 66 добавлений и 163 удалений

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

@ -35,4 +35,6 @@ else:
'/accessible/other',
]
include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul'

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

@ -425,8 +425,8 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
static_cast<TabChild*>(tabChild.get())->
SendPDocAccessibleConstructor(ipcDoc, parentIPCDoc, id);
#if defined(XP_WIN)
IAccessibleHolder holder(CreateHolderFromAccessible(childDoc));
ipcDoc->SendCOMProxy(holder);
MOZ_ASSERT(parentIPCDoc);
ipcDoc->SendMsaaID(AccessibleWrap::GetChildIDFor(childDoc));
#endif
}
}

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

@ -42,6 +42,8 @@ else:
'/accessible/other',
]
include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul'
if CONFIG['GNU_CXX']:

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

@ -54,14 +54,13 @@ DocAccessibleChildBase::SerializeTree(Accessible* aRoot,
nsTArray<AccessibleData>& aTree)
{
uint64_t id = reinterpret_cast<uint64_t>(aRoot->UniqueID());
#if defined(XP_WIN)
int32_t msaaId = AccessibleWrap::GetChildIDFor(aRoot);
#endif
uint32_t role = aRoot->Role();
uint32_t childCount = aRoot->ChildCount();
uint32_t interfaces = InterfacesFor(aRoot);
#if defined(XP_WIN)
IAccessibleHolder holder(CreateHolderFromAccessible(aRoot));
#endif
// OuterDocAccessibles are special because we don't want to serialize the
// child doc here, we'll call PDocAccessibleConstructor in
// NotificationController.
@ -71,8 +70,7 @@ DocAccessibleChildBase::SerializeTree(Accessible* aRoot,
}
#if defined(XP_WIN)
aTree.AppendElement(AccessibleData(id, role, childCount, interfaces,
holder));
aTree.AppendElement(AccessibleData(id, msaaId, role, childCount, interfaces));
#else
aTree.AppendElement(AccessibleData(id, role, childCount, interfaces));
#endif
@ -82,29 +80,6 @@ DocAccessibleChildBase::SerializeTree(Accessible* aRoot,
}
}
#if defined(XP_WIN)
/* static */ void
DocAccessibleChildBase::SetMsaaIds(Accessible* aRoot,
uint32_t& aMsaaIdIndex,
const nsTArray<MsaaMapping>& aNewMsaaIds)
{
const MsaaMapping& mapping = aNewMsaaIds[aMsaaIdIndex];
#if defined(DEBUG)
uint64_t id = reinterpret_cast<uint64_t>(aRoot->UniqueID());
MOZ_ASSERT(mapping.ID() == id);
#endif // defined(DEBUG)
static_cast<AccessibleWrap*>(aRoot)->SetID(mapping.MsaaID());
++aMsaaIdIndex;
if (aRoot->IsOuterDoc()) {
// This needs to match the tree traversal in SerializeTree
return;
}
for (uint32_t i = 0, n = aRoot->ChildCount(); i < n; ++i) {
SetMsaaIds(aRoot->GetChildAt(i), aMsaaIdIndex, aNewMsaaIds);
}
}
#endif // defined(XP_WIN)
void
DocAccessibleChildBase::ShowEvent(AccShowEvent* aShowEvent)
{
@ -114,22 +89,7 @@ DocAccessibleChildBase::ShowEvent(AccShowEvent* aShowEvent)
nsTArray<AccessibleData> shownTree;
ShowEventData data(parentID, idxInParent, shownTree);
SerializeTree(aShowEvent->GetAccessible(), data.NewTree());
#if defined(XP_WIN)
nsTArray<MsaaMapping> newMsaaIds;
SendShowEventInfo(data, &newMsaaIds);
// newMsaaIds could be empty if something went wrong in SendShowEvent()
if (!newMsaaIds.IsEmpty()) {
uint32_t index = 0;
SetMsaaIds(aShowEvent->GetAccessible(), index, newMsaaIds);
}
// NB: On Windows, SendShowEvent attaches the subtree and generates new IDs,
// but does *NOT* fire the native event. We need to do that after
// we've called SetMsaaIds.
SendEvent(reinterpret_cast<uint64_t>(aShowEvent->GetAccessible()->UniqueID()),
nsIAccessibleEvent::EVENT_SHOW);
#else
SendShowEvent(data, aShowEvent->IsFromUserInput());
#endif // defined(XP_WIN)
}
} // namespace a11y

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

@ -60,10 +60,6 @@ public:
protected:
static uint32_t InterfacesFor(Accessible* aAcc);
static void SerializeTree(Accessible* aRoot, nsTArray<AccessibleData>& aTree);
#if defined(XP_WIN)
static void SetMsaaIds(Accessible* aRoot, uint32_t& aMsaaIdIndex,
const nsTArray<MsaaMapping>& aNewMsaaIds);
#endif
DocAccessible* mDoc;
};

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

@ -16,13 +16,8 @@ namespace mozilla {
namespace a11y {
bool
#if defined(XP_WIN)
DocAccessibleParent::RecvShowEventInfo(const ShowEventData& aData,
nsTArray<MsaaMapping>* aNewMsaaIds)
#else
DocAccessibleParent::RecvShowEvent(const ShowEventData& aData,
const bool& aFromUser)
#endif // defined(XP_WIN)
{
if (mShutdown)
return true;
@ -49,13 +44,7 @@ DocAccessibleParent::RecvShowEvent(const ShowEventData& aData,
return true;
}
#if defined(XP_WIN)
aNewMsaaIds->SetCapacity(aData.NewTree().Length());
uint32_t consumed = AddSubtree(parent, aData.NewTree(), 0, newChildIdx,
aNewMsaaIds);
#else
uint32_t consumed = AddSubtree(parent, aData.NewTree(), 0, newChildIdx);
#endif
MOZ_ASSERT(consumed == aData.NewTree().Length());
// XXX This shouldn't happen, but if we failed to add children then the below
@ -73,9 +62,6 @@ DocAccessibleParent::RecvShowEvent(const ShowEventData& aData,
MOZ_DIAGNOSTIC_ASSERT(CheckDocTree());
// NB: On Windows we dispatch the native event via a subsequent call to
// RecvEvent().
#if !defined(XP_WIN)
ProxyAccessible* target = parent->ChildAt(newChildIdx);
ProxyShowHideEvent(target, parent, true, aFromUser);
@ -90,7 +76,6 @@ DocAccessibleParent::RecvShowEvent(const ShowEventData& aData,
RefPtr<xpcAccEvent> event = new xpcAccEvent(type, xpcAcc, doc, node,
aFromUser);
nsCoreUtils::DispatchAccEvent(Move(event));
#endif
return true;
}
@ -98,11 +83,7 @@ DocAccessibleParent::RecvShowEvent(const ShowEventData& aData,
uint32_t
DocAccessibleParent::AddSubtree(ProxyAccessible* aParent,
const nsTArray<a11y::AccessibleData>& aNewTree,
uint32_t aIdx, uint32_t aIdxInParent
#if defined(XP_WIN)
, nsTArray<MsaaMapping>* aNewMsaaIds
#endif
)
uint32_t aIdx, uint32_t aIdxInParent)
{
if (aNewTree.Length() <= aIdx) {
NS_ERROR("bad index in serialized tree!");
@ -122,43 +103,22 @@ DocAccessibleParent::AddSubtree(ProxyAccessible* aParent,
auto role = static_cast<a11y::role>(newChild.Role());
#if defined(XP_WIN)
const IAccessibleHolder& proxyStream = newChild.COMProxy();
RefPtr<IAccessible> comPtr(proxyStream.Get());
if (!comPtr) {
NS_ERROR("Could not obtain remote IAccessible interface");
return 0;
}
ProxyAccessible* newProxy =
new ProxyAccessible(newChild.ID(), aParent, this, role,
newChild.Interfaces(), comPtr);
#else
ProxyAccessible* newProxy =
new ProxyAccessible(newChild.ID(), aParent, this, role,
newChild.Interfaces());
#endif
aParent->AddChildAt(aIdxInParent, newProxy);
mAccessibles.PutEntry(newChild.ID())->mProxy = newProxy;
ProxyCreated(newProxy, newChild.Interfaces());
#if defined(XP_WIN)
Accessible* idForAcc = WrapperFor(newProxy);
MOZ_ASSERT(idForAcc);
uint32_t newMsaaId = AccessibleWrap::GetChildIDFor(idForAcc);
MOZ_ASSERT(newMsaaId);
aNewMsaaIds->AppendElement(MsaaMapping(newChild.ID(), newMsaaId));
#endif // defined(XP_WIN)
WrapperFor(newProxy)->SetID(newChild.MsaaID());
#endif
uint32_t accessibles = 1;
uint32_t kids = newChild.ChildrenCount();
for (uint32_t i = 0; i < kids; i++) {
uint32_t consumed = AddSubtree(newProxy, aNewTree, aIdx + accessibles, i
#if defined(XP_WIN)
, aNewMsaaIds
#endif
);
uint32_t consumed = AddSubtree(newProxy, aNewTree, aIdx + accessibles, i);
if (!consumed)
return 0;
@ -500,16 +460,20 @@ DocAccessibleParent::GetXPCAccessible(ProxyAccessible* aProxy)
#if defined(XP_WIN)
/**
* @param aMsaaID The MSAA ID that was generated by content that the chrome
* process should assign to this DocAccessibleParent.
* @param aCOMProxy COM Proxy to the document in the content process.
* @param aParentCOMProxy COM Proxy to the OuterDocAccessible that is
* the parent of the document. The content process will use this
* proxy when traversing up across the content/chrome boundary.
*/
bool
DocAccessibleParent::RecvCOMProxy(const IAccessibleHolder& aCOMProxy,
IAccessibleHolder* aParentCOMProxy,
uint32_t* aMsaaID)
DocAccessibleParent::RecvCOMProxy(const int32_t& aMsaaID,
const IAccessibleHolder& aCOMProxy,
IAccessibleHolder* aParentCOMProxy)
{
WrapperFor(this)->SetID(aMsaaID);
RefPtr<IAccessible> ptr(aCOMProxy.Get());
SetCOMInterface(ptr);
@ -520,8 +484,13 @@ DocAccessibleParent::RecvCOMProxy(const IAccessibleHolder& aCOMProxy,
}
aParentCOMProxy->Set(IAccessibleHolder::COMPtrType(rawNative));
Accessible* wrapper = WrapperFor(this);
*aMsaaID = AccessibleWrap::GetChildIDFor(wrapper);
return true;
}
bool
DocAccessibleParent::RecvMsaaID(const int32_t& aMsaaID)
{
WrapperFor(this)->SetID(aMsaaID);
return true;
}
#endif // defined(XP_WIN)

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

@ -50,13 +50,8 @@ public:
virtual bool RecvEvent(const uint64_t& aID, const uint32_t& aType)
override;
#if defined(XP_WIN)
virtual bool RecvShowEventInfo(const ShowEventData& aData,
nsTArray<MsaaMapping>* aNewMsaaIds) override;
#else
virtual bool RecvShowEvent(const ShowEventData& aData, const bool& aFromUser)
override;
#endif // defined(XP_WIN)
virtual bool RecvHideEvent(const uint64_t& aRootID, const bool& aFromUser)
override;
virtual bool RecvStateChangeEvent(const uint64_t& aID,
@ -78,6 +73,7 @@ public:
virtual bool RecvRoleChangedEvent(const uint32_t& aRole) override final;
virtual bool RecvBindChildDoc(PDocAccessibleParent* aChildDoc, const uint64_t& aID) override;
void Unbind()
{
mParent = nullptr;
@ -148,9 +144,11 @@ public:
{ return mChildDocs[aIdx]; }
#if defined(XP_WIN)
virtual bool RecvCOMProxy(const IAccessibleHolder& aCOMProxy,
IAccessibleHolder* aParentCOMProxy,
uint32_t* aMsaaID) override;
virtual bool RecvCOMProxy(const int32_t& aMsaaID,
const IAccessibleHolder& aCOMProxy,
IAccessibleHolder* aParentCOMProxy) override;
virtual bool RecvMsaaID(const int32_t& aMsaaID) override;
#endif
private:
@ -180,11 +178,7 @@ private:
uint32_t AddSubtree(ProxyAccessible* aParent,
const nsTArray<AccessibleData>& aNewTree, uint32_t aIdx,
uint32_t aIdxInParent
#if defined(XP_WIN)
, nsTArray<MsaaMapping>* aNewMsaaIds
#endif // defined(XP_WIN)
);
uint32_t aIdxInParent);
MOZ_MUST_USE bool CheckDocTree() const;
xpcAccessibleGeneric* GetXPCAccessible(ProxyAccessible* aProxy);

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

@ -33,11 +33,10 @@ DocAccessibleChild::~DocAccessibleChild()
void
DocAccessibleChild::SendCOMProxy(const IAccessibleHolder& aProxy)
{
int32_t msaaID = AccessibleWrap::GetChildIDFor(mDoc);
IAccessibleHolder parentProxy;
uint32_t msaaID = AccessibleWrap::kNoID;
PDocAccessibleChild::SendCOMProxy(aProxy, &parentProxy, &msaaID);
PDocAccessibleChild::SendCOMProxy(msaaID, aProxy, &parentProxy);
mParentProxy.reset(parentProxy.Release());
mDoc->SetID(msaaID);
}
} // namespace a11y

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

@ -15,10 +15,10 @@ namespace a11y {
struct AccessibleData
{
uint64_t ID;
int32_t MsaaID;
uint32_t Role;
uint32_t ChildrenCount;
uint32_t Interfaces;
IAccessibleHolder COMProxy;
};
struct ShowEventData
@ -28,12 +28,6 @@ struct ShowEventData
AccessibleData[] NewTree;
};
struct MsaaMapping
{
uint64_t ID;
uint32_t MsaaID;
};
struct Attribute
{
nsCString Name;
@ -52,7 +46,7 @@ parent:
* event.
*/
async Event(uint64_t aID, uint32_t type);
sync ShowEventInfo(ShowEventData data) returns (MsaaMapping[] aNewMsaaIds);
async ShowEvent(ShowEventData data, bool aFromUser);
async HideEvent(uint64_t aRootID, bool aFromUser);
async StateChangeEvent(uint64_t aID, uint64_t aState, bool aEnabled);
async CaretMoveEvent(uint64_t aID, int32_t aOffset);
@ -69,8 +63,10 @@ parent:
// For now we'll add the command to send the proxy here. This might move to
// PDocAccessible constructor in PBrowser.
sync COMProxy(IAccessibleHolder aDocCOMProxy)
returns(IAccessibleHolder aParentCOMProxy, uint32_t aMsaaID);
sync COMProxy(int32_t aMsaaID, IAccessibleHolder aDocCOMProxy)
returns(IAccessibleHolder aParentCOMProxy);
async MsaaID(int32_t aMsaaID);
child:
async __delete__();

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

@ -19,6 +19,8 @@
#include <comutil.h>
static const VARIANT kChildIdSelf = {VT_I4};
namespace mozilla {
namespace a11y {
@ -28,6 +30,15 @@ ProxyAccessible::GetCOMInterface(void** aOutAccessible) const
if (!aOutAccessible) {
return false;
}
if (!mCOMProxy) {
// See if we can lazily obtain a COM proxy
AccessibleWrap* wrap = WrapperFor(this);
bool isDefunct = false;
ProxyAccessible* thisPtr = const_cast<ProxyAccessible*>(this);
thisPtr->mCOMProxy = wrap->GetIAccessibleFor(kChildIdSelf, &isDefunct);
}
RefPtr<IAccessible> addRefed = mCOMProxy;
addRefed.forget(aOutAccessible);
return !!mCOMProxy;
@ -42,11 +53,8 @@ ProxyAccessible::Name(nsString& aName) const
return;
}
VARIANT id;
id.vt = VT_I4;
id.lVal = CHILDID_SELF;
BSTR result;
HRESULT hr = acc->get_accName(id, &result);
HRESULT hr = acc->get_accName(kChildIdSelf, &result);
_bstr_t resultWrap(result, false);
if (FAILED(hr)) {
return;
@ -63,11 +71,8 @@ ProxyAccessible::Value(nsString& aValue) const
return;
}
VARIANT id;
id.vt = VT_I4;
id.lVal = CHILDID_SELF;
BSTR result;
HRESULT hr = acc->get_accValue(id, &result);
HRESULT hr = acc->get_accValue(kChildIdSelf, &result);
_bstr_t resultWrap(result, false);
if (FAILED(hr)) {
return;
@ -84,11 +89,8 @@ ProxyAccessible::Description(nsString& aDesc) const
return;
}
VARIANT id;
id.vt = VT_I4;
id.lVal = CHILDID_SELF;
BSTR result;
HRESULT hr = acc->get_accDescription(id, &result);
HRESULT hr = acc->get_accDescription(kChildIdSelf, &result);
_bstr_t resultWrap(result, false);
if (FAILED(hr)) {
return;
@ -105,11 +107,8 @@ ProxyAccessible::State() const
return state;
}
VARIANT id;
id.vt = VT_I4;
id.lVal = CHILDID_SELF;
VARIANT varState;
HRESULT hr = acc->get_accState(id, &varState);
HRESULT hr = acc->get_accState(kChildIdSelf, &varState);
if (FAILED(hr)) {
return state;
}
@ -130,10 +129,7 @@ ProxyAccessible::Bounds()
long top;
long width;
long height;
VARIANT id;
id.vt = VT_I4;
id.lVal = CHILDID_SELF;
HRESULT hr = acc->accLocation(&left, &top, &width, &height, id);
HRESULT hr = acc->accLocation(&left, &top, &width, &height, kChildIdSelf);
if (FAILED(hr)) {
return rect;
}

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

@ -25,11 +25,8 @@ class ProxyAccessible : public ProxyAccessibleBase<ProxyAccessible>
{
public:
ProxyAccessible(uint64_t aID, ProxyAccessible* aParent,
DocAccessibleParent* aDoc, role aRole, uint32_t aInterfaces,
const RefPtr<IAccessible>& aIAccessible)
DocAccessibleParent* aDoc, role aRole, uint32_t aInterfaces)
: ProxyAccessibleBase(aID, aParent, aDoc, aRole, aInterfaces)
, mCOMProxy(aIAccessible)
{
MOZ_COUNT_CTOR(ProxyAccessible);
}

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

@ -85,20 +85,6 @@ a11y::ProxyDestroyed(ProxyAccessible* aProxy)
if (!wrapper)
return;
auto doc =
static_cast<DocProxyAccessibleWrap*>(WrapperFor(aProxy->Document()));
MOZ_ASSERT(doc);
if (doc) {
#ifdef _WIN64
uint32_t id = wrapper->GetExistingID();
if (id != AccessibleWrap::kNoID) {
doc->RemoveID(id);
}
#else
doc->RemoveID(-reinterpret_cast<int32_t>(wrapper));
#endif
}
wrapper->Shutdown();
aProxy->SetWrapper(0);
wrapper->Release();

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

@ -19,4 +19,6 @@ LOCAL_INCLUDES += [
'/accessible/xul',
]
include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul'

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

@ -17,4 +17,6 @@ LOCAL_INCLUDES += [
'/accessible/xul',
]
include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul'

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

@ -47,6 +47,8 @@ else:
'/accessible/other',
]
include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul'
if CONFIG['GNU_CXX']: