Bug 1629078 part 1: For eNameFromSubtreeIfReqRule, don't walk into the descendants of the Accessible for which the text equiv is being calculated. r=MarcoZ
authorJames Teh <jteh@mozilla.com>
Thu, 23 Apr 2020 04:38:19 +0000
changeset 525538 305e91b012119051b51a91be0eb83e032e02ebd6
parent 525537 53f15b782246921ece046091eb28b952f270639e
child 525539 73607b44ad6b837ba2de1f4d01fa26b86d81cda0
push id37339
push usernerli@mozilla.com
push dateThu, 23 Apr 2020 09:52:48 +0000
treeherdermozilla-central@47426d145e24 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMarcoZ
bugs1629078
milestone77.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 1629078 part 1: For eNameFromSubtreeIfReqRule, don't walk into the descendants of the Accessible for which the text equiv is being calculated. r=MarcoZ We already skipped descendants for eNameFromSubtreeIfReqRule when the element wasn't labelled by something else; i.e. when calling GetNameFromSubtree. However, when such an element is labelled/described by an ancestor, we compute the text equiv for the label using AppendTextEquivFromContent. Previously, when descending from the ancestor down into the element itself, we would descend into its subtree despite eNameFromSubtreeIfReqRule. This meant that groupings labelled/described by ancestor would include the content of the grouping itself in its label/description. This was causing problems for time inputs (once those can accept an ancestor label in the next patch). Differential Revision: https://phabricator.services.mozilla.com/D72079
accessible/base/nsTextEquivUtils.cpp
accessible/tests/mochitest/name/test_general.html
--- a/accessible/base/nsTextEquivUtils.cpp
+++ b/accessible/base/nsTextEquivUtils.cpp
@@ -189,17 +189,19 @@ nsresult nsTextEquivUtils::AppendFromAcc
 
   if (rv != NS_OK_NO_NAME_CLAUSE_HANDLED) isEmptyTextEquiv = false;
 
   // Implementation of g) step of text equivalent computation guide. Go down
   // into subtree if accessible allows "text equivalent from subtree rule" or
   // it's not root and not control.
   if (isEmptyTextEquiv) {
     uint32_t nameRule = GetRoleRule(aAccessible->Role());
-    if (nameRule & eNameFromSubtreeIfReqRule) {
+    if (nameRule == eNameFromSubtreeRule ||
+        (nameRule & eNameFromSubtreeIfReqRule &&
+         aAccessible != sInitiatorAcc)) {
       rv = AppendFromAccessibleChildren(aAccessible, aString);
       NS_ENSURE_SUCCESS(rv, rv);
 
       if (rv != NS_OK_NO_NAME_CLAUSE_HANDLED) isEmptyTextEquiv = false;
     }
   }
 
   // Implementation of h. step
--- a/accessible/tests/mochitest/name/test_general.html
+++ b/accessible/tests/mochitest/name/test_general.html
@@ -239,16 +239,19 @@
       // But not if it is a weak (landmark) ARIA role
       testName("NoNameForTRBecauseWeakARIA", null);
 
       // Name from sub tree of grouping if requested by other accessible.
       testName("grouping", null);
       testName("requested_name_from_grouping", "label");
       testName("listitem_containing_block_tbody", "label");
 
+      // Name from subtree of grouping labelled by an ancestor.
+      testName("grouping_labelledby_ancestor", "label");
+
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 
 </head>
@@ -678,10 +681,17 @@
   <!-- Name from sub tree of tbody marked as display:block;, which is also a grouping -->
   <div id="listitem_containing_block_tbody" role="listitem">
     <table>
       <tbody style="display: block;">
         <tr><td>label</td></tr>
       </tbody>
     </table>
   </div>
+
+  <!-- Name from subtree of grouping labelled by an ancestor. -->
+  <div id="grouping_ancestor_label">label
+    <div id="grouping_labelledby_ancestor" role="group" aria-labelledby="grouping_ancestor_label">
+      This content should not be included in the grouping's label.
+    </div>
+  </div>
 </body>
 </html>