Bug 1440392 - Move XBL accessibility role="xul:menupopup" into XULMap.h
MozReview-Commit-ID: IeR805H6qW8
--- a/accessible/base/XULMap.h
+++ b/accessible/base/XULMap.h
@@ -73,16 +73,30 @@ XULMAP(
}
}
return nullptr;
}
)
XULMAP(
+ menupopup,
+ [](nsIContent* aContent, Accessible* aContext) {
+ return CreateMenupopupAccessible(aContent, aContext);
+ }
+)
+
+XULMAP(
+ popup,
+ [](nsIContent* aContent, Accessible* aContext) {
+ return CreateMenupopupAccessible(aContent, aContext);
+ }
+)
+
+XULMAP(
thumb,
[](nsIContent* aContent, Accessible* aContext) -> Accessible* {
if (aContent->IsElement() &&
aContent->AsElement()->ClassList()->Contains(NS_LITERAL_STRING("scale-thumb"))) {
return new XULThumbAccessible(aContent, aContext->Document());
}
return nullptr;
}
--- a/accessible/base/nsAccessibilityService.cpp
+++ b/accessible/base/nsAccessibilityService.cpp
@@ -139,16 +139,38 @@ MustBeAccessible(nsIContent* aContent, D
// for it.
nsAutoString id;
if (nsCoreUtils::GetID(aContent, id) && !id.IsEmpty())
return aDocument->IsDependentID(id);
return false;
}
+/**
+ * Used by XULMap.h to map both menupopup and popup elements
+ */
+#ifdef MOZ_XUL
+Accessible*
+CreateMenupopupAccessible(nsIContent* aContent, Accessible* aContext)
+{
+#ifdef MOZ_ACCESSIBILITY_ATK
+ // ATK considers this node to be redundant when within menubars, and it makes menu
+ // navigation with assistive technologies more difficult
+ // XXX In the future we will should this for consistency across the nsIAccessible
+ // implementations on each platform for a consistent scripting environment, but
+ // then strip out redundant accessibles in the AccessibleWrap class for each platform.
+ nsIContent *parent = aContent->GetParent();
+ if (parent && parent->IsXULElement(nsGkAtoms::menu))
+ return nullptr;
+#endif
+
+ return new XULMenupopupAccessible(aContent, aContext->Document());
+}
+#endif
+
////////////////////////////////////////////////////////////////////////////////
// Accessible constructors
static Accessible*
New_HTMLLink(nsIContent* aContent, Accessible* aContext)
{
// Only some roles truly enjoy life as HTMLLinkAccessibles, for details
// see closed bug 494807.
@@ -1466,30 +1488,16 @@ nsAccessibilityService::CreateAccessible
accessible = new XULColorPickerTileAccessible(aContent, aDoc);
} else if (role.EqualsLiteral("xul:combobox")) {
accessible = new XULComboboxAccessible(aContent, aDoc);
} else if (role.EqualsLiteral("xul:link")) {
accessible = new XULLinkAccessible(aContent, aDoc);
- } else if (role.EqualsLiteral("xul:menupopup")) {
-#ifdef MOZ_ACCESSIBILITY_ATK
- // ATK considers this node to be redundant when within menubars, and it makes menu
- // navigation with assistive technologies more difficult
- // XXX In the future we will should this for consistency across the nsIAccessible
- // implementations on each platform for a consistent scripting environment, but
- // then strip out redundant accessibles in the AccessibleWrap class for each platform.
- nsIContent *parent = aContent->GetParent();
- if (parent && parent->IsXULElement(nsGkAtoms::menu))
- return nullptr;
-#endif
-
- accessible = new XULMenupopupAccessible(aContent, aDoc);
-
} else if(role.EqualsLiteral("xul:pane")) {
accessible = new EnumRoleAccessible<roles::PANE>(aContent, aDoc);
} else if (role.EqualsLiteral("xul:panel")) {
if (aContent->IsElement() &&
aContent->AsElement()->AttrValueIs(kNameSpaceID_None,
nsGkAtoms::noautofocus,
nsGkAtoms::_true, eCaseMatters))
--- a/accessible/xul/XULFormControlAccessible.cpp
+++ b/accessible/xul/XULFormControlAccessible.cpp
@@ -169,18 +169,19 @@ XULButtonAccessible::IsAcceptableChild(n
// 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 panel elements.
- if (role.EqualsLiteral("xul:menupopup")) {
+ // 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
// for it. Ignore dropmarker button which is placed as a last child.
if ((!role.EqualsLiteral("xul:button") &&
!role.EqualsLiteral("xul:toolbarbutton")) ||
aEl->IsXULElement(nsGkAtoms::dropMarker)) {
--- a/toolkit/content/widgets/popup.xml
+++ b/toolkit/content/widgets/popup.xml
@@ -246,17 +246,17 @@
this.popupBoxObject.setConstraintRect(aRect);
]]>
</body>
</method>
</implementation>
</binding>
- <binding id="popup" role="xul:menupopup"
+ <binding id="popup"
extends="chrome://global/content/bindings/popup.xml#popup-base">
<content>
<xul:arrowscrollbox class="popup-internal-box" flex="1" orient="vertical"
smoothscroll="false">
<children/>
</xul:arrowscrollbox>
</content>