Bug 1187742 - Handle proxies in mozAccessible {isEnabled,title,value,help,isExpired} r=tbsaunde
authorLorien Hu <lorien@lorienhu.com>
Tue, 04 Aug 2015 14:56:17 -0400
changeset 287838 01f5097128e5e0f49aad5781fdc4b12a6a11cbc2
parent 287837 c9580c329762e44b7aed191c075ac01a99605e4f
child 287839 2b0b584ce01f718c9c4807121b9096936857edb1
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs1187742
milestone42.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 1187742 - Handle proxies in mozAccessible {isEnabled,title,value,help,isExpired} r=tbsaunde
accessible/ipc/DocAccessibleChild.cpp
accessible/ipc/DocAccessibleChild.h
accessible/ipc/PDocAccessible.ipdl
accessible/ipc/ProxyAccessible.cpp
accessible/ipc/ProxyAccessible.h
accessible/mac/mozAccessible.mm
--- a/accessible/ipc/DocAccessibleChild.cpp
+++ b/accessible/ipc/DocAccessibleChild.cpp
@@ -163,16 +163,28 @@ DocAccessibleChild::RecvValue(const uint
     return true;
   }
 
   acc->Value(*aValue);
   return true;
 }
 
 bool
+DocAccessibleChild::RecvHelp(const uint64_t& aID, nsString* aHelp)
+{
+  Accessible* acc = IdToAccessible(aID);
+  if (!acc) {
+    return true;
+  }
+
+  acc->Help(*aHelp);
+  return true;
+}
+
+bool
 DocAccessibleChild::RecvDescription(const uint64_t& aID, nsString* aDesc)
 {
   Accessible* acc = IdToAccessible(aID);
   if (!acc)
     return true;
 
   acc->Description(*aDesc);
   return true;
--- a/accessible/ipc/DocAccessibleChild.h
+++ b/accessible/ipc/DocAccessibleChild.h
@@ -65,16 +65,18 @@ public:
 
   /*
    * Get the name for the accessible with given id.
    */
   virtual bool RecvName(const uint64_t& aID, nsString* aName) override;
 
   virtual bool RecvValue(const uint64_t& aID, nsString* aValue) override;
 
+  virtual bool RecvHelp(const uint64_t& aID, nsString* aHelp) override;
+
   /*
    * Get the description for the accessible with given id.
    */
   virtual bool RecvDescription(const uint64_t& aID, nsString* aDesc) override;
   virtual bool RecvRelationByType(const uint64_t& aID, const uint32_t& aType,
                                   nsTArray<uint64_t>* aTargets) override;
   virtual bool RecvRelations(const uint64_t& aID,
                              nsTArray<RelationTargets>* aRelations)
--- a/accessible/ipc/PDocAccessible.ipdl
+++ b/accessible/ipc/PDocAccessible.ipdl
@@ -70,16 +70,17 @@ parent:
 
 child:
   __delete__();
 
   // Accessible
   prio(high) sync State(uint64_t aID) returns(uint64_t states);
   prio(high) sync Name(uint64_t aID) returns(nsString name);
   prio(high) sync Value(uint64_t aID) returns(nsString value);
+  prio(high) sync Help(uint64_t aID) returns(nsString help);
   prio(high) sync Description(uint64_t aID) returns(nsString desc);
   prio(high) sync Attributes(uint64_t aID) returns(Attribute[] attributes);
   prio(high) sync RelationByType(uint64_t aID, uint32_t aRelationType)
     returns(uint64_t[] targets);
   prio(high) sync Relations(uint64_t aID) returns(RelationTargets[] relations);
   prio(high) sync IsSearchbox(uint64_t aID) returns(bool retval);
   prio(high) sync LandmarkRole(uint64_t aID) returns(nsString landmark);
   prio(high) sync ARIARoleAtom(uint64_t aID) returns(nsString role);
--- a/accessible/ipc/ProxyAccessible.cpp
+++ b/accessible/ipc/ProxyAccessible.cpp
@@ -91,16 +91,22 @@ ProxyAccessible::Name(nsString& aName) c
 
 void
 ProxyAccessible::Value(nsString& aValue) const
 {
   unused << mDoc->SendValue(mID, &aValue);
 }
 
 void
+ProxyAccessible::Help(nsString& aHelp) const
+{
+  unused << mDoc->SendHelp(mID, &aHelp);
+}
+
+void
 ProxyAccessible::Description(nsString& aDesc) const
 {
   unused << mDoc->SendDescription(mID, &aDesc);
 }
 
 void
 ProxyAccessible::Attributes(nsTArray<Attribute> *aAttrs) const
 {
--- a/accessible/ipc/ProxyAccessible.h
+++ b/accessible/ipc/ProxyAccessible.h
@@ -84,16 +84,21 @@ public:
    */
   void Name(nsString& aName) const;
 
   /*
    * Set aValue to the value of the proxied accessible.
    */
   void Value(nsString& aValue) const;
 
+  /*
+   * Set aHelp to the help string of the proxied accessible.
+   */
+  void Help(nsString& aHelp) const;
+
   /**
    * Set aDesc to the description of the proxied accessible.
    */
   void Description(nsString& aDesc) const;
 
   /**
    * Get the set of attributes on the proxied accessible.
    */
--- a/accessible/mac/mozAccessible.mm
+++ b/accessible/mac/mozAccessible.mm
@@ -1151,28 +1151,36 @@ struct RoleDescrComparator
   return NSAccessibilityRoleDescription([self role], subrole);
 }
 
 - (NSString*)title
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   nsAutoString title;
-  [self getGeckoAccessible]->Name(title);
+  if (AccessibleWrap* accWrap = [self getGeckoAccessible])
+    accWrap->Name(title);
+  else if (ProxyAccessible* proxy = [self getProxyAccessible])
+    proxy->Name(title);
+
   return nsCocoaUtils::ToNSString(title);
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (id)value
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   nsAutoString value;
-  [self getGeckoAccessible]->Value(value);
+  if (AccessibleWrap* accWrap = [self getGeckoAccessible])
+    accWrap->Value(value);
+  else if (ProxyAccessible* proxy = [self getProxyAccessible])
+    proxy->Value(value);
+
   return nsCocoaUtils::ToNSString(value);
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (void)valueDidChange
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
@@ -1208,17 +1216,21 @@ struct RoleDescrComparator
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 - (NSString*)help
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
   nsAutoString helpText;
-  [self getGeckoAccessible]->Help(helpText);
+  if (AccessibleWrap* accWrap = [self getGeckoAccessible])
+    accWrap->Help(helpText);
+  else if (ProxyAccessible* proxy = [self getProxyAccessible])
+    proxy->Help(helpText);
+
   return nsCocoaUtils::ToNSString(helpText);
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
 }
 
 // objc-style description (from NSObject); not to be confused with the accessible description above.
 - (NSString*)description
 {
@@ -1254,18 +1266,23 @@ struct RoleDescrComparator
   else
     return NO;
 
   return YES;
 }
 
 - (BOOL)isEnabled
 {
-  AccessibleWrap* accWrap = [self getGeckoAccessible];
-  return accWrap && ((accWrap->InteractiveState() & states::UNAVAILABLE) == 0);
+  if (AccessibleWrap* accWrap = [self getGeckoAccessible])
+    return ((accWrap->InteractiveState() & states::UNAVAILABLE) == 0);
+
+  if (ProxyAccessible* proxy = [self getProxyAccessible])
+    return ((proxy->State() & states::UNAVAILABLE) == 0);
+
+  return false;
 }
 
 // The root accessible calls this when the focused node was
 // changed to us.
 - (void)didReceiveFocus
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
@@ -1333,17 +1350,17 @@ struct RoleDescrComparator
 
   mGeckoAccessible = 0;
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 - (BOOL)isExpired
 {
-  return ![self getGeckoAccessible];
+  return ![self getGeckoAccessible] && ![self getProxyAccessible];
 }
 
 #pragma mark -
 #pragma mark Debug methods
 #pragma mark -
 
 #ifdef DEBUG