bug 1087481 - teach atk to get the name for proxies r=davidb

This commit is contained in:
Trevor Saunders 2014-09-23 05:53:03 -04:00
parent a3a396a01e
commit 7d98bdbafa
7 changed files with 39 additions and 14 deletions

View File

@ -600,12 +600,14 @@ finalizeCB(GObject *aObj)
const gchar* const gchar*
getNameCB(AtkObject* aAtkObj) getNameCB(AtkObject* aAtkObj)
{ {
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
if (!accWrap)
return nullptr;
nsAutoString name; nsAutoString name;
accWrap->Name(name); AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
if (accWrap)
accWrap->Name(name);
else if (ProxyAccessible* proxy = GetProxy(aAtkObj))
proxy->Name(name);
else
return nullptr;
// XXX Firing an event from here does not seem right // XXX Firing an event from here does not seem right
MaybeFireNameChange(aAtkObj, name); MaybeFireNameChange(aAtkObj, name);

View File

@ -18,9 +18,7 @@ SerializeTree(Accessible* aRoot, nsTArray<AccessibleData>& aTree)
uint32_t role = aRoot->Role(); uint32_t role = aRoot->Role();
uint32_t childCount = aRoot->ChildCount(); uint32_t childCount = aRoot->ChildCount();
nsString name; aTree.AppendElement(AccessibleData(id, role, childCount));
aRoot->Name(name);
aTree.AppendElement(AccessibleData(id, role, childCount, name));
for (uint32_t i = 0; i < childCount; i++) for (uint32_t i = 0; i < childCount; i++)
SerializeTree(aRoot->GetChildAt(i), aTree); SerializeTree(aRoot->GetChildAt(i), aTree);
} }
@ -50,5 +48,16 @@ DocAccessibleChild::RecvState(const uint64_t& aID, uint64_t* aState)
return true; return true;
} }
bool
DocAccessibleChild::RecvName(const uint64_t& aID, nsString* aName)
{
Accessible* acc = mDoc->GetAccessibleByUniqueID((void*)aID);
if (!acc)
return true;
acc->Name(*aName);
return true;
}
} }
} }

View File

@ -38,6 +38,11 @@ public:
*/ */
virtual bool RecvState(const uint64_t& aID, uint64_t* aState) MOZ_OVERRIDE; virtual bool RecvState(const uint64_t& aID, uint64_t* aState) MOZ_OVERRIDE;
/*
* Get the name for the accessible with given id.
*/
virtual bool RecvName(const uint64_t& aID, nsString* aName) MOZ_OVERRIDE;
private: private:
DocAccessible* mDoc; DocAccessible* mDoc;
}; };

View File

@ -69,7 +69,7 @@ DocAccessibleParent::AddSubtree(ProxyAccessible* aParent,
auto role = static_cast<a11y::role>(newChild.Role()); auto role = static_cast<a11y::role>(newChild.Role());
ProxyAccessible* newProxy = ProxyAccessible* newProxy =
new ProxyAccessible(newChild.ID(), aParent, this, role, newChild.Name()); new ProxyAccessible(newChild.ID(), aParent, this, role);
aParent->AddChildAt(aIdxInParent, newProxy); aParent->AddChildAt(aIdxInParent, newProxy);
mAccessibles.PutEntry(newChild.ID())->mProxy = newProxy; mAccessibles.PutEntry(newChild.ID())->mProxy = newProxy;
ProxyCreated(newProxy); ProxyCreated(newProxy);

View File

@ -14,7 +14,6 @@ struct AccessibleData
uint64_t ID; uint64_t ID;
uint32_t Role; uint32_t Role;
uint32_t ChildrenCount; uint32_t ChildrenCount;
nsString Name;
}; };
struct ShowEventData struct ShowEventData
@ -41,6 +40,7 @@ parent:
child: child:
prio(high) sync State(uint64_t aID) returns(uint64_t states); prio(high) sync State(uint64_t aID) returns(uint64_t states);
prio(high) sync Name(uint64_t aID) returns(nsString name);
}; };
} }

View File

@ -47,5 +47,11 @@ ProxyAccessible::State() const
unused << mDoc->SendState(mID, &state); unused << mDoc->SendState(mID, &state);
return state; return state;
} }
void
ProxyAccessible::Name(nsString& aName) const
{
unused << mDoc->SendName(mID, &aName);
}
} }
} }

View File

@ -21,9 +21,8 @@ class ProxyAccessible
public: public:
ProxyAccessible(uint64_t aID, ProxyAccessible* aParent, ProxyAccessible(uint64_t aID, ProxyAccessible* aParent,
DocAccessibleParent* aDoc, role aRole, DocAccessibleParent* aDoc, role aRole) :
const nsString& aName) : mParent(aParent), mDoc(aDoc), mID(aID), mRole(aRole), mOuterDoc(false)
mParent(aParent), mDoc(aDoc), mID(aID), mRole(aRole), mOuterDoc(false), mName(aName)
{ {
MOZ_COUNT_CTOR(ProxyAccessible); MOZ_COUNT_CTOR(ProxyAccessible);
} }
@ -59,6 +58,11 @@ public:
*/ */
uint64_t State() const; uint64_t State() const;
/*
* Set aName to the name of the proxied accessible.
*/
void Name(nsString& aName) const;
/** /**
* Allow the platform to store a pointers worth of data on us. * Allow the platform to store a pointers worth of data on us.
*/ */
@ -85,7 +89,6 @@ private:
uint64_t mID; uint64_t mID;
role mRole : 31; role mRole : 31;
bool mOuterDoc : 1; bool mOuterDoc : 1;
nsString mName;
}; };
} }