From f48235cf49cbe6b23617253e860bb3a80e2070e1 Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Wed, 13 May 2015 11:57:14 -0400 Subject: [PATCH] bug 1164976 - Make DocAccessibleParent::GetAccessible return itself when appropriate r=davidb --- accessible/ipc/DocAccessibleParent.cpp | 20 ++++---------------- accessible/ipc/DocAccessibleParent.h | 8 +++++++- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/accessible/ipc/DocAccessibleParent.cpp b/accessible/ipc/DocAccessibleParent.cpp index fce7207a1c3..c705fa1ee43 100644 --- a/accessible/ipc/DocAccessibleParent.cpp +++ b/accessible/ipc/DocAccessibleParent.cpp @@ -23,14 +23,7 @@ DocAccessibleParent::RecvShowEvent(const ShowEventData& aData) return false; } - ProxyAccessible* parent = nullptr; - if (aData.ID()) { - ProxyEntry* e = mAccessibles.GetEntry(aData.ID()); - if (e) - parent = e->mProxy; - } else { - parent = this; - } + ProxyAccessible* parent = GetAccessible(aData.ID()); // XXX This should really never happen, but sometimes we fail to fire the // required show events. @@ -123,18 +116,13 @@ DocAccessibleParent::RecvHideEvent(const uint64_t& aRootID) bool DocAccessibleParent::RecvEvent(const uint64_t& aID, const uint32_t& aEventType) { - if (!aID) { - ProxyEvent(this, aEventType); - return true; - } - - ProxyEntry* e = mAccessibles.GetEntry(aID); - if (!e) { + ProxyAccessible* proxy = GetAccessible(aID); + if (!proxy) { NS_ERROR("no proxy for event!"); return true; } - ProxyEvent(e->mProxy, aEventType); + ProxyEvent(proxy, aEventType); return true; } diff --git a/accessible/ipc/DocAccessibleParent.h b/accessible/ipc/DocAccessibleParent.h index 80fcea072f4..10b02eecc2d 100644 --- a/accessible/ipc/DocAccessibleParent.h +++ b/accessible/ipc/DocAccessibleParent.h @@ -94,12 +94,18 @@ public: /** * Return the accessible for given id. */ - ProxyAccessible* GetAccessible(uintptr_t aID) const + ProxyAccessible* GetAccessible(uintptr_t aID) { + if (!aID) + return this; + ProxyEntry* e = mAccessibles.GetEntry(aID); return e ? e->mProxy : nullptr; } + const ProxyAccessible* GetAccessible(uintptr_t aID) const + { return const_cast(this)->GetAccessible(aID); } + private: class ProxyEntry : public PLDHashEntryHdr