bug 1243077 - add ToXPC{,Document} overloads for proxied accessibles r=davidb
authorTrevor Saunders <tbsaunde@tbsaunde.org>
Fri, 22 Jan 2016 05:52:53 -0500
changeset 318362 c32e7fc59790e787ed8d154ab61f5ede8740f07d
parent 318361 d599cfd59baea9fe8d41a98d120b5b2b714e5d7f
child 318363 fd9f45122aac0a33425af7598aeca538276cd564
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdavidb
bugs1243077
milestone47.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 1243077 - add ToXPC{,Document} overloads for proxied accessibles r=davidb
accessible/xpcom/xpcAccessibleDocument.cpp
accessible/xpcom/xpcAccessibleDocument.h
--- a/accessible/xpcom/xpcAccessibleDocument.cpp
+++ b/accessible/xpcom/xpcAccessibleDocument.cpp
@@ -8,16 +8,17 @@
 #include "xpcAccessibleImage.h"
 #include "xpcAccessibleTable.h"
 #include "xpcAccessibleTableCell.h"
 
 #include "mozilla/a11y/DocAccessibleParent.h"
 #include "DocAccessible-inl.h"
 #include "nsIDOMDocument.h"
 
+using namespace mozilla;
 using namespace mozilla::a11y;
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsISupports and cycle collection
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(xpcAccessibleDocument)
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(xpcAccessibleDocument,
@@ -222,8 +223,23 @@ void
 xpcAccessibleDocument::Shutdown()
 {
   for (auto iter = mCache.Iter(); !iter.Done(); iter.Next()) {
     iter.Data()->Shutdown();
     iter.Remove();
   }
   xpcAccessibleGeneric::Shutdown();
 }
+
+xpcAccessibleGeneric*
+a11y::ToXPC(AccessibleOrProxy aAcc)
+{
+  if (aAcc.IsNull()) {
+    return nullptr;
+  }
+
+  if (aAcc.IsAccessible()) {
+    return ToXPC(aAcc.AsAccessible());
+  }
+
+ xpcAccessibleDocument* doc = ToXPCDocument(aAcc.AsProxy()->Document());
+ return doc->GetXPCAccessible(aAcc.AsProxy());
+}
--- a/accessible/xpcom/xpcAccessibleDocument.h
+++ b/accessible/xpcom/xpcAccessibleDocument.h
@@ -113,16 +113,18 @@ ToXPC(Accessible* aAccessible)
   if (aAccessible->IsApplication())
     return XPCApplicationAcc();
 
   xpcAccessibleDocument* xpcDoc =
     GetAccService()->GetXPCDocument(aAccessible->Document());
   return xpcDoc ? xpcDoc->GetAccessible(aAccessible) : nullptr;
 }
 
+xpcAccessibleGeneric* ToXPC(AccessibleOrProxy aAcc);
+
 inline xpcAccessibleHyperText*
 ToXPCText(HyperTextAccessible* aAccessible)
 {
   if (!aAccessible)
     return nullptr;
 
   xpcAccessibleDocument* xpcDoc =
     GetAccService()->GetXPCDocument(aAccessible->Document());
@@ -130,12 +132,18 @@ ToXPCText(HyperTextAccessible* aAccessib
 }
 
 inline xpcAccessibleDocument*
 ToXPCDocument(DocAccessible* aAccessible)
 {
   return GetAccService()->GetXPCDocument(aAccessible);
 }
 
+inline xpcAccessibleDocument*
+ToXPCDocument(DocAccessibleParent* aAccessible)
+{
+  return GetAccService()->GetXPCDocument(aAccessible);
+}
+
 } // namespace a11y
 } // namespace mozilla
 
 #endif