Bug 1439778 - Move XBL accessibility role="xul:panel" into XULMap.h draft
authorTimothy Guan-tin Chien <timdream@gmail.com>
Thu, 01 Mar 2018 13:21:00 -0800
changeset 762568 b7549687ba08f357763369d267c658c7b80a0ef9
parent 762567 9caf14e0b300424d05fe5dd5afa7b9d1c65a5416
child 762578 8011abefc9a634d7472508a956e708667203fb25
push id101204
push userbmo:timdream@gmail.com
push dateFri, 02 Mar 2018 17:37:47 +0000
bugs1439778
milestone60.0a1
Bug 1439778 - Move XBL accessibility role="xul:panel" into XULMap.h 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;