Commit 5902d1aa authored by Martin Robinson's avatar Martin Robinson Committed by Chromium LUCI CQ

Use the native combobox a11y role more often on MacOS

Instead of mapping the ARIA combobox role to other roles on MacOS,
always use it unless it is applied to a multiline edit field. This
matches the specified behavior and other browsers.

These were originally mapped to other roles because of VoiceOver
failures that have been fixed with other changes.

Bug: 1125165
Change-Id: I26b8ccb006c15d6329da1c29193640f529fab781
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2611093Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Martin Robinson <mrobinson@igalia.com>
Cr-Commit-Position: refs/heads/master@{#844021}
parent 4fa38947
......@@ -1980,7 +1980,7 @@ id content::AXTextMarkerRangeFrom(id anchor_textmarker, id focus_textmarker) {
cocoa_role = NSAccessibilityGroupRole;
} else if ((_owner->IsPlainTextField() &&
_owner->HasState(ax::mojom::State::kMultiline)) ||
_owner->IsRichTextField()) {
(_owner->IsRichTextField() && !ui::IsComboBox(role))) {
cocoa_role = NSAccessibilityTextAreaRole;
} else if (role == ax::mojom::Role::kImage &&
_owner->HasExplicitlyEmptyName()) {
......
AXWebArea AXFocused=1
++AXGroup
++++AXStaticText AXValue='Choose a fruit, with text content'
++AXPopUpButton AXLinkedUIElements=[:6] AXTitle='Choose a fruit, with text content' AXValue='Apple'
++AXComboBox AXLinkedUIElements=[:6] AXTitle='Choose a fruit, with text content' AXValue='Apple'
++++AXStaticText AXValue='Apple'
++AXList
++++AXStaticText AXValue='Apple'
......
AXWebArea
++AXPopUpButton AXHasPopup=1 AXPopupValue='menu'
++AXPopUpButton
++AXPopUpButton AXHasPopup=1 AXPopupValue='menu'
++AXPopUpButton AXHasPopup=1 AXPopupValue='listbox'
++AXPopUpButton AXHasPopup=1 AXPopupValue='grid'
++AXPopUpButton AXHasPopup=1 AXPopupValue='dialog'
++AXPopUpButton AXHasPopup=1 AXPopupValue='listbox'
++AXPopUpButton AXHasPopup=1 AXPopupValue='listbox'
++AXPopUpButton AXHasPopup=1 AXPopupValue='listbox'
++AXComboBox AXHasPopup=1 AXPopupValue='menu'
++AXComboBox
++AXComboBox AXHasPopup=1 AXPopupValue='menu'
++AXComboBox AXHasPopup=1 AXPopupValue='listbox'
++AXComboBox AXHasPopup=1 AXPopupValue='grid'
++AXComboBox AXHasPopup=1 AXPopupValue='dialog'
++AXComboBox AXHasPopup=1 AXPopupValue='listbox'
++AXComboBox AXHasPopup=1 AXPopupValue='listbox'
++AXComboBox AXHasPopup=1 AXPopupValue='listbox'
AXWebArea
++AXGroup
++AXGroup AXOrientation='AXHorizontalOrientation'
++AXGroup AXOrientation='AXVerticalOrientation'
++AXComboBox
++AXComboBox AXOrientation='AXHorizontalOrientation'
++AXComboBox AXOrientation='AXVerticalOrientation'
++AXList AXOrientation='AXVerticalOrientation'
++AXList AXOrientation='AXHorizontalOrientation'
++AXList AXOrientation='AXVerticalOrientation'
......
AXWebArea
++AXGroup
++++AXStaticText AXValue='State'
++AXGroup AXTitle='State'
++AXComboBox AXTitle='State'
++++AXTextField AXLinkedUIElements=[:6]
++AXList
++++AXStaticText AXValue='Alabama'
++++AXStaticText AXFocused=1 AXValue='Alaska'
++AXGroup AXTitle='State'
++AXComboBox AXTitle='State'
++++AXTextField AXLinkedUIElements=[:11]
++AXList
++++AXStaticText AXValue='Alabama'
......
......@@ -723,6 +723,17 @@ bool IsText(ax::mojom::Role role) {
}
}
bool IsComboBox(const ax::mojom::Role role) {
switch (role) {
case ax::mojom::Role::kComboBoxMenuButton:
case ax::mojom::Role::kComboBoxGrouping:
case ax::mojom::Role::kTextFieldWithComboBox:
return true;
default:
return false;
}
}
bool ShouldHaveReadonlyStateByDefault(const ax::mojom::Role role) {
switch (role) {
case ax::mojom::Role::kArticle:
......
......@@ -179,6 +179,9 @@ AX_BASE_EXPORT bool IsTableRow(ax::mojom::Role role);
// break, or inline text box.
AX_BASE_EXPORT bool IsText(ax::mojom::Role role);
// Returns true if the provided role is any of the combobox-related roles.
AX_BASE_EXPORT bool IsComboBox(ax::mojom::Role role);
// Returns true if the node should be read only by default
AX_BASE_EXPORT bool ShouldHaveReadonlyStateByDefault(
const ax::mojom::Role role);
......
......@@ -57,8 +57,8 @@ RoleMap BuildRoleMap() {
{ax::mojom::Role::kColorWell, NSAccessibilityColorWellRole},
{ax::mojom::Role::kColumn, NSAccessibilityColumnRole},
{ax::mojom::Role::kColumnHeader, @"AXCell"},
{ax::mojom::Role::kComboBoxGrouping, NSAccessibilityGroupRole},
{ax::mojom::Role::kComboBoxMenuButton, NSAccessibilityPopUpButtonRole},
{ax::mojom::Role::kComboBoxGrouping, NSAccessibilityComboBoxRole},
{ax::mojom::Role::kComboBoxMenuButton, NSAccessibilityComboBoxRole},
{ax::mojom::Role::kComment, NSAccessibilityGroupRole},
{ax::mojom::Role::kComplementary, NSAccessibilityGroupRole},
{ax::mojom::Role::kContentDeletion, NSAccessibilityGroupRole},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment