Bug 1439778 - Move XBL accessibility role="xul:panel" into XULMap.h r=surkov
authorTimothy Guan-tin Chien <timdream@gmail.com>
Thu, 01 Mar 2018 13:21:00 -0800
changeset 461367 724ea239987f2dfe34bdadaaeae7e06d2aa8e877
parent 461366 af8624334733a2d71ba39fa873ed0c903e6e4449
child 461368 1ea18b70b170502da444405f233f925c58e1266d
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1439778
milestone60.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 1439778 - Move XBL accessibility role="xul:panel" into XULMap.h r=surkov MozReview-Commit-ID: LqdGEZqRTWA
accessible/base/XULMap.h
accessible/base/nsAccessibilityService.cpp
accessible/xul/XULColorPickerAccessible.cpp
dom/base/nsGkAtomList.h
toolkit/content/widgets/popup.xml
--- a/accessible/base/XULMap.h
+++ b/accessible/base/XULMap.h
@@ -82,16 +82,38 @@ XULMAP(
 XULMAP(
   menupopup,
   [](nsIContent* aContent, Accessible* aContext) {
     return CreateMenupopupAccessible(aContent, aContext);
   }
 )
 
 XULMAP(
+  panel,
+  [](nsIContent* aContent, Accessible* aContext) -> Accessible* {
+    static const Element::AttrValuesArray sIgnoreTypeVals[] =
+      { &nsGkAtoms::autocomplete_richlistbox, &nsGkAtoms::autocomplete, nullptr };
+
+    if (!aContent->IsElement() ||
+        aContent->AsElement()->FindAttrValueIn(kNameSpaceID_None, nsGkAtoms::type,
+                                               sIgnoreTypeVals, eIgnoreCase) >= 0) {
+      return nullptr;
+    }
+
+    if (aContent->AsElement()->AttrValueIs(kNameSpaceID_None,
+                                           nsGkAtoms::noautofocus,
+                                           nsGkAtoms::_true, eCaseMatters)) {
+      return new XULAlertAccessible(aContent, aContext->Document());
+    }
+
+    return new EnumRoleAccessible<roles::PANE>(aContent, aContext->Document());
+  }
+)
+
+XULMAP(
   popup,
   [](nsIContent* aContent, Accessible* aContext) {
     return CreateMenupopupAccessible(aContent, aContext);
   }
 )
 
 XULMAP(
   textbox,
--- a/accessible/base/nsAccessibilityService.cpp
+++ b/accessible/base/nsAccessibilityService.cpp
@@ -317,18 +317,18 @@ static int32_t sPlatformDisabledState = 
 
 static const HTMLMarkupMapInfo sHTMLMarkupMapList[] = {
   #include "MarkupMap.h"
 };
 
 #undef MARKUPMAP
 
 #ifdef MOZ_XUL
-#define XULMAP(atom, new_func) \
-  { &nsGkAtoms::atom, new_func },
+#define XULMAP(atom, ...) \
+  { &nsGkAtoms::atom, __VA_ARGS__ },
 
 #define XULMAP_TYPE(atom, new_type) \
 XULMAP( \
   atom, \
   [](nsIContent* aContent, Accessible* aContext) -> Accessible* { \
     return new new_type(aContent, aContext->Document()); \
   } \
 )
@@ -1482,25 +1482,16 @@ nsAccessibilityService::CreateAccessible
     accessible = new XULColorPickerAccessible(aContent, aDoc);
 
   } else if (role.EqualsLiteral("xul:colorpickertile")) {
     accessible = new XULColorPickerTileAccessible(aContent, aDoc);
 
   } else if (role.EqualsLiteral("xul:link")) {
     accessible = new XULLinkAccessible(aContent, aDoc);
 
-  } else if (role.EqualsLiteral("xul:panel")) {
-    if (aContent->IsElement() &&
-        aContent->AsElement()->AttrValueIs(kNameSpaceID_None,
-                                           nsGkAtoms::noautofocus,
-                                           nsGkAtoms::_true, eCaseMatters))
-      accessible = new XULAlertAccessible(aContent, aDoc);
-    else
-      accessible = new EnumRoleAccessible<roles::PANE>(aContent, aDoc);
-
   } else if (role.EqualsLiteral("xul:text")) {
     accessible = new XULLabelAccessible(aContent, aDoc);
 
   }
 #endif // MOZ_XUL
 
   return accessible.forget();
 }
--- a/accessible/xul/XULColorPickerAccessible.cpp
+++ b/accessible/xul/XULColorPickerAccessible.cpp
@@ -2,17 +2,16 @@
 /* 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/. */
 
 #include "XULColorPickerAccessible.h"
 
 #include "Accessible-inl.h"
 #include "nsAccUtils.h"
-#include "nsCoreUtils.h"
 #include "DocAccessible.h"
 #include "Role.h"
 #include "States.h"
 
 #include "nsIDOMElement.h"
 #include "nsMenuPopupFrame.h"
 
 using namespace mozilla::a11y;
@@ -130,15 +129,12 @@ XULColorPickerAccessible::AreItemsOperab
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULColorPickerAccessible: Accessible
 
 bool
 XULColorPickerAccessible::IsAcceptableChild(nsIContent* aEl) const
 {
-  nsAutoString role;
-  nsCoreUtils::XBLBindingRole(aEl, role);
-  return role.EqualsLiteral("xul:panel") &&
-    aEl->IsElement() &&
+  return aEl->IsXULElement(nsGkAtoms::panel) &&
     aEl->AsElement()->AttrValueIs(kNameSpaceID_None, nsGkAtoms::noautofocus,
                                   nsGkAtoms::_true, eCaseMatters);
 }
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -150,16 +150,17 @@ GK_ATOM(assign, "assign")
 GK_ATOM(async, "async")
 GK_ATOM(attribute, "attribute")
 GK_ATOM(attributes, "attributes")
 GK_ATOM(attributeSet, "attribute-set")
 GK_ATOM(aural, "aural")
 GK_ATOM(_auto, "auto")
 GK_ATOM(autocheck, "autocheck")
 GK_ATOM(autocomplete, "autocomplete")
+GK_ATOM(autocomplete_richlistbox, "autocomplete-richlistbox")
 GK_ATOM(autofocus, "autofocus")
 GK_ATOM(autoplay, "autoplay")
 GK_ATOM(autorepeatbutton, "autorepeatbutton")
 GK_ATOM(axis, "axis")
 GK_ATOM(b, "b")
 GK_ATOM(background, "background")
 GK_ATOM(base, "base")
 GK_ATOM(basefont, "basefont")
--- a/toolkit/content/widgets/popup.xml
+++ b/toolkit/content/widgets/popup.xml
@@ -284,17 +284,17 @@
           }
           for (var i = 0; i < array.length; i++)
             array[i].width = width;
         ]]>
       </handler>
     </handlers>
   </binding>
 
-  <binding id="panel" role="xul:panel"
+  <binding id="panel"
            extends="chrome://global/content/bindings/popup.xml#popup-base">
     <implementation>
       <field name="_prevFocus">0</field>
       <field name="_dragBindingAlive">true</field>
       <constructor>
       <![CDATA[
         if (this.getAttribute("backdrag") == "true" && !this._draggableStarted) {
           this._draggableStarted = true;