Bug 1429940 - Part 1 - Use the first "label" element instead of the one inside "caption" to describe the "groupbox" element. r=Jamie
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Thu, 15 Nov 2018 12:05:09 +0000
changeset 503839 781e474c75714b384c3246a257e9389a2771c505
parent 503838 82e8d51e41a5febd002c00fe1d33c282a58d48bb
child 503840 004331df8823ee887cc787e29ef7efe4fa4e596f
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersJamie
bugs1429940
milestone65.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 1429940 - Part 1 - Use the first "label" element instead of the one inside "caption" to describe the "groupbox" element. r=Jamie Differential Revision: https://phabricator.services.mozilla.com/D11793
accessible/tests/mochitest/name/test_general.xul
accessible/tests/mochitest/relations/test_general.xul
accessible/tests/mochitest/tree/test_groupbox.xul
accessible/xul/XULElementAccessibles.cpp
accessible/xul/XULFormControlAccessible.cpp
--- a/accessible/tests/mochitest/name/test_general.xul
+++ b/accessible/tests/mochitest/name/test_general.xul
@@ -169,17 +169,17 @@
       testName("lb_opt1_children_hidden", "i am visible");
 
 
       //////////////////////////////////////////////////////////////////////////
       // Name from aria-labelledby: menuitem label+ listitem label
       testName("li_labelledby", "Show an Alert The moment the event starts");
 
       //////////////////////////////////////////////////////////////////////////
-      // groupbox labeling from caption sub tree
+      // groupbox labeling from first label
       testName("groupbox", "Some caption");
 
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   ]]>
@@ -343,17 +343,17 @@
   <vbox role="listbox" tabindex="0">
     <hbox id="lb_opt1_children_hidden" role="option" tabindex="0">
       <description>i am visible</description>
       <description style="display:none">i am hidden</description>
     </hbox>
 
     <!-- Name from caption sub tree -->
     <groupbox id="groupbox">
-      <caption><label>Some caption</label></caption>
+      <label>Some caption</label>
       <checkbox label="some checkbox label" />
     </groupbox>
   </vbox>
 
   <!-- bug 441991; create name from other menuitem label listitem's own label -->
   <hbox>
     <richlistbox>
       <richlistitem id="li_labelledby"
--- a/accessible/tests/mochitest/relations/test_general.xul
+++ b/accessible/tests/mochitest/relations/test_general.xul
@@ -98,18 +98,17 @@
       // aria-flowto, multiple relations
       testRelation("flowto1", RELATION_FLOWS_TO, ["flowfrom1", "flowfrom2"]);
       testRelation("flowfrom1", RELATION_FLOWS_FROM, "flowto1");
       testRelation("flowfrom2", RELATION_FLOWS_FROM, "flowto1");
 
       // 'default button' relation
       testRelation("textbox", RELATION_DEFAULT_BUTTON, "submit");
 
-      // 'labelled by'/'label for' relation for xul:goupbox and xul:label of
-      // xul:caption
+      // 'labelled by'/'label for' relation for xul:groupbox and xul:label
       var groupboxAcc = getAccessible("groupbox");
       var labelAcc = groupboxAcc.firstChild;
       testRelation(labelAcc, RELATION_LABEL_FOR, groupboxAcc);
       testRelation(groupboxAcc, RELATION_LABELLED_BY, labelAcc);
 
       // 'labelled by'/'label for' relations for xul:tab and xul:tabpanel
       // (fixed in bug 366527)
       testRelation("tabpanel1", RELATION_LABELLED_BY, "tab1");
@@ -206,17 +205,17 @@
 
     <description id="flowto" aria-flowto="flowfrom">flow to</description>
     <description id="flowfrom">flow from</description>
 
     <textbox id="textbox"/>
     <button id="submit" default="true" label="Default"/>
 
     <groupbox id="groupbox">
-      <caption><label id="groupboxlabel" value="caption"/></caption>
+      <label value="caption"/>
     </groupbox>
 
     <tabbox>
       <tabs>
         <tab label="tab1" id="tab1"/>
         <tab label="tab2" id="tab2" linkedpanel="tabpanel2"/>
         <tab label="tab3" id="tab3" linkedpanel="tabpanel3"/>
       </tabs>
--- a/accessible/tests/mochitest/tree/test_groupbox.xul
+++ b/accessible/tests/mochitest/tree/test_groupbox.xul
@@ -49,16 +49,16 @@
       <div id="content" style="display: none">
       </div>
       <pre id="test">
       </pre>
     </body>
 
     <vbox flex="1">
       <groupbox id="groupbox">
-        <caption><label value="Some caption"/></caption>
+        <label value="Some caption"/>
         <checkbox label="some checkbox label" />
     </groupbox>
     </vbox>
   </hbox>
 
 </window>
 
--- a/accessible/xul/XULElementAccessibles.cpp
+++ b/accessible/xul/XULElementAccessibles.cpp
@@ -84,23 +84,24 @@ XULLabelAccessible::NativeState() const
   // They are not focusable or selectable
   return HyperTextAccessibleWrap::NativeState() | states::READONLY;
 }
 
 Relation
 XULLabelAccessible::RelationByType(RelationType aType) const
 {
   Relation rel = HyperTextAccessibleWrap::RelationByType(aType);
+
+  // The label for xul:groupbox is generated from the first xul:label
   if (aType == RelationType::LABEL_FOR) {
-    // Caption is the label for groupbox
-    nsIContent* parent = mContent->GetFlattenedTreeParent();
-    if (parent && parent->IsXULElement(nsGkAtoms::caption)) {
-      Accessible* parent = Parent();
-      if (parent && parent->Role() == roles::GROUPING)
-        rel.AppendTarget(parent);
+    Accessible* parent = Parent();
+    if (parent && parent->Role() == roles::GROUPING &&
+        parent->GetContent()->IsXULElement(nsGkAtoms::groupbox) &&
+        parent->GetChildAt(0) == this) {
+      rel.AppendTarget(parent);
     }
   }
 
   return rel;
 }
 
 void
 XULLabelAccessible::UpdateLabelValue(const nsString& aValue)
--- a/accessible/xul/XULFormControlAccessible.cpp
+++ b/accessible/xul/XULFormControlAccessible.cpp
@@ -281,34 +281,23 @@ XULGroupboxAccessible::NativeName(nsStri
 
   return eNameOK;
 }
 
 Relation
 XULGroupboxAccessible::RelationByType(RelationType aType) const
 {
   Relation rel = AccessibleWrap::RelationByType(aType);
-  if (aType != RelationType::LABELLED_BY)
-    return rel;
 
-  // The label for xul:groupbox is generated from xul:label that is
-  // inside the anonymous content of the xul:caption.
-  // The xul:label has an accessible object but the xul:caption does not
-  uint32_t childCount = ChildCount();
-  for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
-    Accessible* childAcc = GetChildAt(childIdx);
-    if (childAcc->Role() == roles::LABEL) {
-      // Ensure that it's our label
-      Relation reverseRel = childAcc->RelationByType(RelationType::LABEL_FOR);
-      Accessible* testGroupbox = nullptr;
-      while ((testGroupbox = reverseRel.Next()))
-        if (testGroupbox == this) {
-          // The <label> points back to this groupbox
-          rel.AppendTarget(childAcc);
-        }
+  // The label for xul:groupbox is generated from the first xul:label
+  if (aType == RelationType::LABELLED_BY && ChildCount() > 0) {
+    Accessible* childAcc = GetChildAt(0);
+    if (childAcc->Role() == roles::LABEL &&
+        childAcc->GetContent()->IsXULElement(nsGkAtoms::label)) {
+      rel.AppendTarget(childAcc);
     }
   }
 
   return rel;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULRadioButtonAccessible