Bug 1145366 - IPC Proxy for HyperLink, r=tbsaunde

This commit is contained in:
Olli Pettay 2015-03-25 16:03:13 +02:00
parent ee5a170144
commit c95a64e29f
5 changed files with 197 additions and 0 deletions

View File

@ -52,6 +52,13 @@ DocAccessibleChild::IdToAccessible(const uint64_t& aID) const
return mDoc->GetAccessibleByUniqueID(reinterpret_cast<void*>(aID));
}
Accessible*
DocAccessibleChild::IdToAccessibleLink(const uint64_t& aID) const
{
Accessible* acc = IdToAccessible(aID);
return acc && acc->IsLink() ? acc : nullptr;
}
HyperTextAccessible*
DocAccessibleChild::IdToHyperTextAccessible(const uint64_t& aID) const
{
@ -618,5 +625,109 @@ DocAccessibleChild::RecvImageSize(const uint64_t& aID,
return true;
}
bool
DocAccessibleChild::RecvStartOffset(const uint64_t& aID,
uint32_t* aRetVal,
bool* aOk)
{
Accessible* acc = IdToAccessibleLink(aID);
if (acc) {
*aRetVal = acc->StartOffset();
*aOk = true;
} else {
*aRetVal = 0;
*aOk = false;
}
return true;
}
bool
DocAccessibleChild::RecvEndOffset(const uint64_t& aID,
uint32_t* aRetVal,
bool* aOk)
{
Accessible* acc = IdToAccessibleLink(aID);
if (acc) {
*aRetVal = acc->EndOffset();
*aOk = true;
} else {
*aRetVal = 0;
*aOk = false;
}
return true;
}
bool
DocAccessibleChild::RecvIsLinkValid(const uint64_t& aID,
bool* aRetVal)
{
Accessible* acc = IdToAccessibleLink(aID);
if (acc) {
*aRetVal = acc->IsLinkValid();
} else {
*aRetVal = false;
}
return true;
}
bool
DocAccessibleChild::RecvAnchorCount(const uint64_t& aID,
uint32_t* aRetVal,
bool* aOk)
{
Accessible* acc = IdToAccessibleLink(aID);
if (acc) {
*aRetVal = acc->AnchorCount();
*aOk = true;
} else {
*aRetVal = 0;
*aOk = false;
}
return true;
}
bool
DocAccessibleChild::RecvAnchorURIAt(const uint64_t& aID,
const uint32_t& aIndex,
nsCString* aURI,
bool* aOk)
{
Accessible* acc = IdToAccessibleLink(aID);
*aOk = false;
if (acc) {
nsCOMPtr<nsIURI> uri = acc->AnchorURIAt(aIndex);
if (uri) {
uri->GetSpec(*aURI);
*aOk = true;
}
}
return true;
}
bool
DocAccessibleChild::RecvAnchorAt(const uint64_t& aID,
const uint32_t& aIndex,
uint64_t* aIDOfAnchor,
bool* aOk)
{
*aIDOfAnchor = 0;
*aOk = false;
Accessible* acc = IdToAccessibleLink(aID);
if (acc) {
Accessible* anchor = acc->AnchorAt(aIndex);
if (anchor) {
*aIDOfAnchor = reinterpret_cast<uint64_t>(anchor->UniqueID());
*aOk = true;
}
}
return true;
}
}
}

View File

@ -189,9 +189,29 @@ public:
virtual bool RecvImageSize(const uint64_t& aID,
nsIntSize* aRetVal) override;
virtual bool RecvStartOffset(const uint64_t& aID,
uint32_t* aRetVal,
bool* aOk) override;
virtual bool RecvEndOffset(const uint64_t& aID,
uint32_t* aRetVal,
bool* aOk) override;
virtual bool RecvIsLinkValid(const uint64_t& aID,
bool* aRetVal) override;
virtual bool RecvAnchorCount(const uint64_t& aID,
uint32_t* aRetVal, bool* aOk) override;
virtual bool RecvAnchorURIAt(const uint64_t& aID,
const uint32_t& aIndex,
nsCString* aURI,
bool* aOk) override;
virtual bool RecvAnchorAt(const uint64_t& aID,
const uint32_t& aIndex,
uint64_t* aIDOfAnchor,
bool* aOk) override;
private:
Accessible* IdToAccessible(const uint64_t& aID) const;
Accessible* IdToAccessibleLink(const uint64_t& aID) const;
HyperTextAccessible* IdToHyperTextAccessible(const uint64_t& aID) const;
ImageAccessible* IdToImageAccessible(const uint64_t& aID) const;

View File

@ -132,6 +132,13 @@ child:
prio(high) sync ImagePosition(uint64_t aID, uint32_t aCoordType) returns(nsIntPoint aRetVal);
prio(high) sync ImageSize(uint64_t aID) returns(nsIntSize aRetVal);
prio(high) sync StartOffset(uint64_t aID) returns(uint32_t aRetVal, bool aOk);
prio(high) sync EndOffset(uint64_t aID) returns(uint32_t aRetVal, bool aOk);
prio(high) sync IsLinkValid(uint64_t aID) returns(bool aRetVal);
prio(high) sync AnchorCount(uint64_t aID) returns(uint32_t aRetVal, bool aOk);
prio(high) sync AnchorURIAt(uint64_t aID, uint32_t aIndex) returns(nsCString aURI, bool aOk);
prio(high) sync AnchorAt(uint64_t aID, uint32_t aIndex) returns(uint64_t aIDOfAnchor, bool aOk);
};
}

View File

@ -379,5 +379,52 @@ ProxyAccessible::ImageSize()
return retVal;
}
uint32_t
ProxyAccessible::StartOffset(bool* aOk)
{
uint32_t retVal = 0;
unused << mDoc->SendStartOffset(mID, &retVal, aOk);
return retVal;
}
uint32_t
ProxyAccessible::EndOffset(bool* aOk)
{
uint32_t retVal = 0;
unused << mDoc->SendEndOffset(mID, &retVal, aOk);
return retVal;
}
bool
ProxyAccessible::IsLinkValid()
{
bool retVal = false;
unused << mDoc->SendIsLinkValid(mID, &retVal);
return retVal;
}
uint32_t
ProxyAccessible::AnchorCount(bool* aOk)
{
uint32_t retVal = 0;
unused << mDoc->SendAnchorCount(mID, &retVal, aOk);
return retVal;
}
void
ProxyAccessible::AnchorURIAt(uint32_t aIndex, nsCString& aURI, bool* aOk)
{
unused << mDoc->SendAnchorURIAt(mID, aIndex, &aURI, aOk);
}
ProxyAccessible*
ProxyAccessible::AnchorAt(uint32_t aIndex)
{
uint64_t id = 0;
bool ok = false;
unused << mDoc->SendAnchorAt(mID, aIndex, &id, &ok);
return ok ? mDoc->GetAccessible(id) : nullptr;
}
}
}

View File

@ -181,6 +181,18 @@ public:
nsIntSize ImageSize();
uint32_t StartOffset(bool* aOk);
uint32_t EndOffset(bool* aOk);
bool IsLinkValid();
uint32_t AnchorCount(bool* aOk);
void AnchorURIAt(uint32_t aIndex, nsCString& aURI, bool* aOk);
ProxyAccessible* AnchorAt(uint32_t aIndex);
/**
* Allow the platform to store a pointers worth of data on us.
*/