From 291c2322bb90815b96ffca07833f3b2bf4c8b5c4 Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Thu, 7 May 2015 12:59:17 -0400 Subject: [PATCH] bug 1162621 - proxy Accessible::IndexOfEmbeddedChild r=davidb This is a bit dirty, we should be able to implement this just in the main process by looking at the role of the children. However doing it this way is simpler and allows us to share code with the non e10s case. --- accessible/atk/AccessibleWrap.cpp | 7 +++++++ accessible/ipc/DocAccessibleChild.cpp | 16 ++++++++++++++++ accessible/ipc/DocAccessibleChild.h | 4 ++++ accessible/ipc/PDocAccessible.ipdl | 2 ++ accessible/ipc/ProxyAccessible.cpp | 9 +++++++++ accessible/ipc/ProxyAccessible.h | 1 + 6 files changed, 39 insertions(+) diff --git a/accessible/atk/AccessibleWrap.cpp b/accessible/atk/AccessibleWrap.cpp index dddd1ff6e92d..523f615757e5 100644 --- a/accessible/atk/AccessibleWrap.cpp +++ b/accessible/atk/AccessibleWrap.cpp @@ -855,6 +855,13 @@ getIndexInParentCB(AtkObject* aAtkObj) { // We don't use Accessible::IndexInParent() because we don't include text // leaf nodes as children in ATK. + if (ProxyAccessible* proxy = GetProxy(aAtkObj)) { + if (ProxyAccessible* parent = proxy->Parent()) + return parent->IndexOfEmbeddedChild(proxy); + + return -1; + } + AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj); if (!accWrap) { return -1; diff --git a/accessible/ipc/DocAccessibleChild.cpp b/accessible/ipc/DocAccessibleChild.cpp index e5f3d3db4dce..c4657c89d892 100644 --- a/accessible/ipc/DocAccessibleChild.cpp +++ b/accessible/ipc/DocAccessibleChild.cpp @@ -1618,6 +1618,22 @@ DocAccessibleChild::RecvTakeFocus(const uint64_t& aID) return true; } +bool +DocAccessibleChild::RecvIndexOfEmbeddedChild(const uint64_t& aID, + const uint64_t& aChildID, + uint32_t* aChildIdx) +{ + *aChildIdx = 0; + + Accessible* parent = IdToAccessible(aID); + Accessible* child = IdToAccessible(aChildID); + if (!parent || !child) + return true; + + *aChildIdx = parent->GetIndexOfEmbeddedChild(child); + return true; +} + bool DocAccessibleChild::RecvChildAtPoint(const uint64_t& aID, const int32_t& aX, diff --git a/accessible/ipc/DocAccessibleChild.h b/accessible/ipc/DocAccessibleChild.h index ebd07f44f4c8..b7bca4f93f40 100644 --- a/accessible/ipc/DocAccessibleChild.h +++ b/accessible/ipc/DocAccessibleChild.h @@ -393,6 +393,10 @@ public: virtual bool RecvTakeFocus(const uint64_t& aID) override; + virtual bool RecvIndexOfEmbeddedChild(const uint64_t& aID, + const uint64_t& aChildID, + uint32_t* aChildIdx) override final; + virtual bool RecvChildAtPoint(const uint64_t& aID, const int32_t& aX, const int32_t& aY, diff --git a/accessible/ipc/PDocAccessible.ipdl b/accessible/ipc/PDocAccessible.ipdl index eddd7e64420b..f8e4e3c907f6 100644 --- a/accessible/ipc/PDocAccessible.ipdl +++ b/accessible/ipc/PDocAccessible.ipdl @@ -211,6 +211,8 @@ child: prio(high) sync Step(uint64_t aID) returns(double aStep); prio(high) sync TakeFocus(uint64_t aID); + prio(high) sync IndexOfEmbeddedChild(uint64_t aID, uint64_t aChildID) + returns(uint32_t childIdx); prio(high) sync ChildAtPoint(uint64_t aID, int32_t aX, int32_t aY, uint32_t aWhich) returns(uint64_t aChild, bool aOk); prio(high) sync Bounds(uint64_t aID) returns(nsIntRect aRect); diff --git a/accessible/ipc/ProxyAccessible.cpp b/accessible/ipc/ProxyAccessible.cpp index be1bc1676736..877536601daf 100644 --- a/accessible/ipc/ProxyAccessible.cpp +++ b/accessible/ipc/ProxyAccessible.cpp @@ -903,6 +903,15 @@ ProxyAccessible::TakeFocus() unused << mDoc->SendTakeFocus(mID); } +int32_t +ProxyAccessible::IndexOfEmbeddedChild(const ProxyAccessible* aChild) +{ + uint64_t childID = aChild->mID; + uint32_t childIdx; + unused << mDoc->SendIndexOfEmbeddedChild(mID, childID, &childIdx); + return childIdx; +} + ProxyAccessible* ProxyAccessible::ChildAtPoint(int32_t aX, int32_t aY, Accessible::EWhichChildAtPoint aWhichChild) diff --git a/accessible/ipc/ProxyAccessible.h b/accessible/ipc/ProxyAccessible.h index cc36ab90c654..7645ae984914 100644 --- a/accessible/ipc/ProxyAccessible.h +++ b/accessible/ipc/ProxyAccessible.h @@ -47,6 +47,7 @@ public: // XXX evaluate if this is fast enough. size_t IndexInParent() const { return mParent->mChildren.IndexOf(this); } + int32_t IndexOfEmbeddedChild(const ProxyAccessible*); bool MustPruneChildren() const; void Shutdown();