bug 1164976 - Make DocAccessibleParent::GetAccessible return itself when appropriate r=davidb
authorTrevor Saunders <tbsaunde@tbsaunde.org>
Wed, 13 May 2015 11:57:14 -0400
changeset 244091 661f089f73b53b4c5080188aa36a4d97469149c3
parent 244090 d9afa8ff148ecb258925faaa9b4447fef640ac2a
child 244092 e5649b9714d1c08effc7dd8e10598c8fe931f0ea
push id59840
push usertrev.saunders@gmail.com
push dateSat, 16 May 2015 00:30:46 +0000
treeherdermozilla-inbound@e5649b9714d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavidb
bugs1164976
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1164976 - Make DocAccessibleParent::GetAccessible return itself when appropriate r=davidb
accessible/ipc/DocAccessibleParent.cpp
accessible/ipc/DocAccessibleParent.h
--- a/accessible/ipc/DocAccessibleParent.cpp
+++ b/accessible/ipc/DocAccessibleParent.cpp
@@ -18,24 +18,17 @@ DocAccessibleParent::RecvShowEvent(const
   if (mShutdown)
     return true;
 
   if (aData.NewTree().IsEmpty()) {
     NS_ERROR("no children being added");
     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.
   if (!parent) {
     NS_ERROR("adding child to unknown accessible");
     return false;
   }
 
@@ -118,28 +111,23 @@ DocAccessibleParent::RecvHideEvent(const
   root->Shutdown();
 
   return true;
 }
 
 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;
 }
 
 bool
 DocAccessibleParent::RecvBindChildDoc(PDocAccessibleParent* aChildDoc, const uint64_t& aID)
 {
   auto childDoc = static_cast<DocAccessibleParent*>(aChildDoc);
   DebugOnly<bool> result = AddChildDoc(childDoc, aID, false);
--- a/accessible/ipc/DocAccessibleParent.h
+++ b/accessible/ipc/DocAccessibleParent.h
@@ -89,22 +89,28 @@ public:
   {
     MOZ_ASSERT(mAccessibles.GetEntry(aAccessible->ID()));
     mAccessibles.RemoveEntry(aAccessible->ID());
   }
 
   /**
    * 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<DocAccessibleParent*>(this)->GetAccessible(aID); }
+
 private:
 
   class ProxyEntry : public PLDHashEntryHdr
   {
   public:
     explicit ProxyEntry(const void*) : mProxy(nullptr) {}
     ProxyEntry(ProxyEntry&& aOther) :
       mProxy(aOther.mProxy) { aOther.mProxy = nullptr; }