Bug 1437873 - Move XBL accessibility role="xul:toolbarbutton" and role="xul:button" into XULMap.h draft
authorTimothy Guan-tin Chien <timdream@gmail.com>
Wed, 28 Feb 2018 11:35:57 -0800
changeset 761152 6d5055536f83c695c6c8a6510c9c7134dc4c3655
parent 761141 041712220b023a6b88a1e323b330d260841dbd66
child 761162 165beac2ba453750d94af010635ab1d9509d5aa6
child 761301 c4dd41109aeefc1a869dd8cfaeb3913a5f875581
push id100888
push usertimdream@gmail.com
push dateWed, 28 Feb 2018 19:42:24 +0000
bugs1437873
milestone60.0a1
Bug 1437873 - Move XBL accessibility role="xul:toolbarbutton" and role="xul:button" into XULMap.h This patch intentionally re-map the following controls from button to toolbarbutton - browser/components/downloads/content/download.xml#download-subview-toolbarbutton - toolkit/content/widgets/toolbarbutton.xml#menu-button MozReview-Commit-ID: E806LA6NAvC
accessible/base/XULMap.h
accessible/base/nsAccessibilityService.cpp
accessible/xul/XULFormControlAccessible.cpp
toolkit/content/widgets/button.xml
toolkit/content/widgets/toolbarbutton.xml
--- a/accessible/base/XULMap.h
+++ b/accessible/base/XULMap.h
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 XULMAP_TYPE(browser, OuterDocAccessible)
+XULMAP_TYPE(button, XULButtonAccessible)
 XULMAP_TYPE(checkbox, XULCheckboxAccessible)
 XULMAP_TYPE(dropMarker, XULDropmarkerAccessible)
 XULMAP_TYPE(editor, OuterDocAccessible)
 XULMAP_TYPE(findbar, XULToolbarAccessible)
 XULMAP_TYPE(groupbox, XULGroupboxAccessible)
 XULMAP_TYPE(iframe, OuterDocAccessible)
 XULMAP_TYPE(listbox, XULListboxAccessibleWrap)
 XULMAP_TYPE(listhead, XULColumAccessible)
@@ -32,16 +33,17 @@ XULMAP_TYPE(tabpanels, XULTabpanelsAcces
 XULMAP_TYPE(tabs, XULTabsAccessible)
 XULMAP_TYPE(toolbarseparator, XULToolbarSeparatorAccessible)
 XULMAP_TYPE(toolbarspacer, XULToolbarSeparatorAccessible)
 XULMAP_TYPE(toolbarspring, XULToolbarSeparatorAccessible)
 XULMAP_TYPE(treecol, XULColumnItemAccessible)
 XULMAP_TYPE(treecolpicker, XULButtonAccessible)
 XULMAP_TYPE(treecols, XULTreeColumAccessible)
 XULMAP_TYPE(toolbar, XULToolbarAccessible)
+XULMAP_TYPE(toolbarbutton, XULToolbarButtonAccessible)
 XULMAP_TYPE(tooltip, XULTooltipAccessible)
 
 XULMAP(
   image,
   [](nsIContent* aContent, Accessible* aContext) -> Accessible* {
     if (aContent->IsElement() &&
         aContent->AsElement()->HasAttr(kNameSpaceID_None, nsGkAtoms::onclick)) {
       return new XULToolbarButtonAccessible(aContent, aContext->Document());
--- a/accessible/base/nsAccessibilityService.cpp
+++ b/accessible/base/nsAccessibilityService.cpp
@@ -1473,20 +1473,17 @@ nsAccessibilityService::CreateAccessible
   nsAutoString role;
   nsCoreUtils::XBLBindingRole(aContent, role);
   if (role.IsEmpty() || role.EqualsLiteral("none"))
     return nullptr;
 
   RefPtr<Accessible> accessible;
 #ifdef MOZ_XUL
   // XUL controls
-  if (role.EqualsLiteral("xul:button")) {
-    accessible = new XULButtonAccessible(aContent, aDoc);
-
-  } else if (role.EqualsLiteral("xul:colorpicker")) {
+  if (role.EqualsLiteral("xul:colorpicker")) {
     accessible = new XULColorPickerAccessible(aContent, aDoc);
 
   } else if (role.EqualsLiteral("xul:colorpickertile")) {
     accessible = new XULColorPickerTileAccessible(aContent, aDoc);
 
   } else if (role.EqualsLiteral("xul:combobox")) {
     accessible = new XULComboboxAccessible(aContent, aDoc);
 
@@ -1506,19 +1503,16 @@ nsAccessibilityService::CreateAccessible
       accessible = new EnumRoleAccessible<roles::PANE>(aContent, aDoc);
 
   } else if (role.EqualsLiteral("xul:text")) {
     accessible = new XULLabelAccessible(aContent, aDoc);
 
   } else if (role.EqualsLiteral("xul:textbox")) {
     accessible = new EnumRoleAccessible<roles::SECTION>(aContent, aDoc);
 
-  } else if (role.EqualsLiteral("xul:toolbarbutton")) {
-    accessible = new XULToolbarButtonAccessible(aContent, aDoc);
-
   }
 #endif // MOZ_XUL
 
   return accessible.forget();
 }
 
 already_AddRefed<Accessible>
 nsAccessibilityService::CreateAccessibleByFrameType(nsIFrame* aFrame,
--- a/accessible/xul/XULFormControlAccessible.cpp
+++ b/accessible/xul/XULFormControlAccessible.cpp
@@ -164,31 +164,26 @@ XULButtonAccessible::ContainerWidget() c
 
 bool
 XULButtonAccessible::IsAcceptableChild(nsIContent* aEl) const
 {
   // In general XUL button has not accessible children. Nevertheless menu
   // buttons can have button (@type="menu-button") and popup accessibles
   // (@type="menu-button", @type="menu" or columnpicker.
 
-  // XXX: no children until the button is menu button. Probably it's not
-  // totally correct but in general AT wants to have leaf buttons.
-  nsAutoString role;
-  nsCoreUtils::XBLBindingRole(aEl, role);
-
   // Get an accessible for menupopup or popup elements.
   if (aEl->IsXULElement(nsGkAtoms::menupopup) ||
       aEl->IsXULElement(nsGkAtoms::popup)) {
     return true;
   }
 
-  // Button type="menu-button" contains a real button. Get an accessible
+  // Button and toolbarbutton are real buttons. Get an accessible
   // for it. Ignore dropmarker button which is placed as a last child.
-  if ((!role.EqualsLiteral("xul:button") &&
-       !role.EqualsLiteral("xul:toolbarbutton")) ||
+  if ((!aEl->IsXULElement(nsGkAtoms::button) &&
+       !aEl->IsXULElement(nsGkAtoms::toolbarbutton)) ||
       aEl->IsXULElement(nsGkAtoms::dropMarker)) {
     return false;
   }
 
   return mContent->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
                                             nsGkAtoms::menuButton, eCaseMatters);
 }
 
--- a/toolkit/content/widgets/button.xml
+++ b/toolkit/content/widgets/button.xml
@@ -4,17 +4,17 @@
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 
 <bindings id="buttonBindings"
    xmlns="http://www.mozilla.org/xbl"
    xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    xmlns:xbl="http://www.mozilla.org/xbl">
 
-  <binding id="button-base" extends="chrome://global/content/bindings/general.xml#basetext" role="xul:button">
+  <binding id="button-base" extends="chrome://global/content/bindings/general.xml#basetext">
     <implementation implements="nsIDOMXULButtonElement">
       <property name="type"
                 onget="return this.getAttribute('type');"
                 onset="this.setAttribute('type', val); return val;"/>
 
       <property name="dlgType"
                 onget="return this.getAttribute('dlgtype');"
                 onset="this.setAttribute('dlgtype', val); return val;"/>
--- a/toolkit/content/widgets/toolbarbutton.xml
+++ b/toolkit/content/widgets/toolbarbutton.xml
@@ -4,17 +4,17 @@
    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
 
 
 <bindings id="toolbarbuttonBindings"
    xmlns="http://www.mozilla.org/xbl"
    xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    xmlns:xbl="http://www.mozilla.org/xbl">
 
-  <binding id="toolbarbutton" display="xul:button" role="xul:toolbarbutton"
+  <binding id="toolbarbutton" display="xul:button"
            extends="chrome://global/content/bindings/button.xml#button-base">
     <resources>
       <stylesheet src="chrome://global/skin/toolbarbutton.css"/>
     </resources>
 
     <content>
       <children includes="observes|template|menupopup|panel|tooltip"/>
       <xul:image class="toolbarbutton-icon" xbl:inherits="validate,src=image,label,consumeanchor"/>