Skip to content

Commit 5d6cbfc

Browse files
committed
Bug 1848909: Add a11y support for XUL toolbarbuttons labelled by a text leaf. r=eeejay
Normally, XUL toolbarbutton elements are labelled using the label attribute or a child label element. However, there are some instances such as in the Synced Tabs menu where a toolbarbutton contains only a text leaf. Previously, these buttons exposed no label to accessibility APIs. To fix this, we now allow a text leaf child in the accessibility tree. We already supported this for XUL button elements. Also, there was a bunch of existing common code in IsAcceptableChild for XULToolbarbuttonAccessible and XULButtonAccessible and the former subclasses the latter. Therefore, XULToolbarbuttonAccessible::IsAcceptableChild has been refactored to call the base class method, adding an additional check specific to toolbarbuttons. Differential Revision: https://phabricator.services.mozilla.com/D191713
1 parent 8fe0f11 commit 5d6cbfc

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

accessible/tests/mochitest/name/test_general.xhtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133

134134
// Button labelled by a text child.
135135
testName("button_text", "Text");
136+
testName("toolbarbutton_text", "Text");
136137

137138
// ARIA role option is presented allowing the name calculation from
138139
// the visible children (bug 443081)
@@ -303,6 +304,7 @@
303304
<!-- name from children -->
304305
<box id="box_children" role="button">14</box>
305306
<button id="button_text">Text</button>
307+
<toolbarbutton id="toolbarbutton_text">Text</toolbarbutton>
306308

307309
<!-- name from children, hidden children -->
308310
<vbox role="listbox" tabindex="0">

accessible/xul/XULFormControlAccessible.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,10 @@ bool XULToolbarButtonAccessible::IsSeparator(LocalAccessible* aAccessible) {
406406
// XULToolbarButtonAccessible: Widgets
407407

408408
bool XULToolbarButtonAccessible::IsAcceptableChild(nsIContent* aEl) const {
409-
// In general XUL button has not accessible children. Nevertheless menu
410-
// buttons can have popup accessibles (@type="menu" or columnpicker).
411-
// Also: Toolbar buttons can have labels as children.
412-
// But only if the label attribute is not present.
413-
return aEl->IsXULElement(nsGkAtoms::menupopup) ||
414-
aEl->IsXULElement(nsGkAtoms::popup) ||
409+
return XULButtonAccessible::IsAcceptableChild(aEl) ||
410+
// In addition to the children allowed by buttons, toolbarbuttons can
411+
// have labels as children, but only if the label attribute is not
412+
// present.
415413
(aEl->IsXULElement(nsGkAtoms::label) &&
416414
!mContent->AsElement()->HasAttr(nsGkAtoms::label));
417415
}

0 commit comments

Comments
 (0)