Bug 1617308 - Provide AXDescription for named groupings. r=morgan
authorEitan Isaacson <eitan@monotonous.org>
Wed, 11 Mar 2020 22:54:35 +0000
changeset 518294 743667e67c249057c3e16d6a9de675b65c7b7118
parent 518293 f792d895cdf8f3819b987389301e98b5873123d8
child 518295 28a6cdfc84067f11f84fd6cc35e9996bdd4ce477
push id109877
push usereisaacson@mozilla.com
push dateWed, 11 Mar 2020 22:55:44 +0000
treeherderautoland@28a6cdfc8406 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmorgan
bugs1617308
milestone76.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 1617308 - Provide AXDescription for named groupings. r=morgan Differential Revision: https://phabricator.services.mozilla.com/D66336
accessible/mac/mozAccessible.mm
--- a/accessible/mac/mozAccessible.mm
+++ b/accessible/mac/mozAccessible.mm
@@ -490,44 +490,51 @@ static inline NSMutableArray* ConvertToN
 
 - (NSString*)accessibilityLabel {
   AccessibleWrap* accWrap = [self getGeckoAccessible];
   ProxyAccessible* proxy = [self getProxyAccessible];
   if (!accWrap && !proxy) {
     return nil;
   }
 
-  /* If our accessible is labelled by exactly one item, or if its
-   * name is obtained from a subtree, we should let
-   * NSAccessibilityTitleUIElementAttribute determine its label. */
+  nsAutoString name;
+
+  /* If our accessible is:
+   * 1. Named by invisible text, or
+   * 2. Has more than one labeling relation, or
+   * 3. Is a grouping
+   *   ... return its name as a label (AXDescription).
+   */
   if (accWrap) {
-    nsAutoString name;
     ENameValueFlag flag = accWrap->Name(name);
     if (flag == eNameFromSubtree) {
       return nil;
     }
 
-    Relation rel = accWrap->RelationByType(RelationType::LABELLED_BY);
-    if (rel.Next() && !rel.Next()) {
-      return nil;
+    if (mRole != roles::GROUPING) {
+      Relation rel = accWrap->RelationByType(RelationType::LABELLED_BY);
+      if (rel.Next() && !rel.Next()) {
+        return nil;
+      }
     }
   } else if (proxy) {
-    nsAutoString name;
     uint32_t flag = proxy->Name(name);
     if (flag == eNameFromSubtree) {
       return nil;
     }
 
-    nsTArray<ProxyAccessible*> rels = proxy->RelationByType(RelationType::LABELLED_BY);
-    if (rels.Length() == 1) {
-      return nil;
+  if (mRole != roles::GROUPING) {
+      nsTArray<ProxyAccessible*> rels = proxy->RelationByType(RelationType::LABELLED_BY);
+      if (rels.Length() == 1) {
+        return nil;
+      }
     }
   }
 
-  return [self title];
+  return nsCocoaUtils::ToNSString(name);
 }
 
 - (void)accessibilityPerformAction:(NSString*)action {
   if ([action isEqualToString:NSAccessibilityScrollToVisibleAction]) {
     RefPtr<AccessibleWrap> accWrap = [self getGeckoAccessible];
     ProxyAccessible* proxy = [self getProxyAccessible];
     if (accWrap) {
       accWrap->ScrollTo(nsIAccessibleScrollType::SCROLL_TYPE_ANYWHERE);
@@ -962,16 +969,21 @@ struct RoleDescrComparator {
   }
 
   return NSAccessibilityRoleDescription([self role], subrole);
 }
 
 - (NSString*)title {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
 
+  // If this is a grouping we provide the name in the label (AXDescription).
+  if (mRole == roles::GROUPING) {
+    return nil;
+  }
+
   nsAutoString title;
   if (AccessibleWrap* accWrap = [self getGeckoAccessible])
     accWrap->Name(title);
   else if (ProxyAccessible* proxy = [self getProxyAccessible])
     proxy->Name(title);
 
   return nsCocoaUtils::ToNSString(title);