Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Unified Diff: content/browser/accessibility/browser_accessibility_cocoa.mm

Issue 184103036: Follow ARIA spec guidelines for role=button with aria-pressed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Trailing space for real Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/test/data/accessibility/aria-pressed.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/accessibility/browser_accessibility_cocoa.mm
diff --git a/content/browser/accessibility/browser_accessibility_cocoa.mm b/content/browser/accessibility/browser_accessibility_cocoa.mm
index cfc924bb2df5befe14af22d426f37c5d1638fec1..66b7826286b40da35b41bd17463a42284a48cdd5 100644
--- a/content/browser/accessibility/browser_accessibility_cocoa.mm
+++ b/content/browser/accessibility/browser_accessibility_cocoa.mm
@@ -148,7 +148,7 @@ RoleMap BuildRoleMap() {
{ ui::AX_ROLE_TEXT_AREA, NSAccessibilityTextAreaRole },
{ ui::AX_ROLE_TEXT_FIELD, NSAccessibilityTextFieldRole },
{ ui::AX_ROLE_TIMER, NSAccessibilityGroupRole },
- { ui::AX_ROLE_TOGGLE_BUTTON, NSAccessibilityButtonRole },
+ { ui::AX_ROLE_TOGGLE_BUTTON, NSAccessibilityCheckBoxRole },
{ ui::AX_ROLE_TOOLBAR, NSAccessibilityToolbarRole },
{ ui::AX_ROLE_TOOLTIP, NSAccessibilityGroupRole },
{ ui::AX_ROLE_TREE, NSAccessibilityOutlineRole },
@@ -206,6 +206,7 @@ RoleMap BuildSubroleMap() {
{ ui::AX_ROLE_STATUS, @"AXApplicationStatus" },
{ ui::AX_ROLE_TAB_PANEL, @"AXTabPanel" },
{ ui::AX_ROLE_TIMER, @"AXApplicationTimer" },
+ { ui::AX_ROLE_TOGGLE_BUTTON, @"AXToggleButton" },
David Tseng 2014/03/06 18:15:17 I would match whatever WebKit uses here for a subr
aboxhall 2014/03/06 18:23:31 This is broken in Safari currently. Should I use t
David Tseng 2014/03/06 18:36:31 It depends; does VoiceOver read the literal subrol
{ ui::AX_ROLE_TOOLTIP, @"AXUserInterfaceTooltip" },
{ ui::AX_ROLE_TREE_ITEM, NSAccessibilityOutlineRowSubrole },
};
@@ -663,6 +664,17 @@ NSDictionary* attributeToMethodNameMap = nil;
ui::AX_ATTR_CANVAS_HAS_FALLBACK)) {
return NSAccessibilityGroupRole;
}
+ if (role == ui::AX_ROLE_BUTTON || role == ui::AX_ROLE_TOGGLE_BUTTON) {
+ bool isAriaPressedDefined;
+ bool isMixed;
+ browserAccessibility_->GetAriaTristate("aria-pressed",
+ &isAriaPressedDefined,
+ &isMixed);
+ if (isAriaPressedDefined)
David Tseng 2014/03/06 18:15:17 || isMixed as well.
aboxhall 2014/03/06 18:23:31 isAriaPressedDefined is set to true if the value o
David Tseng 2014/03/06 18:36:31 Yup; that makes sense.
+ return NSAccessibilityCheckBoxRole;
+ else
+ return NSAccessibilityButtonRole;
+ }
return NativeRoleFromAXRole(role);
}
@@ -710,6 +722,9 @@ NSDictionary* attributeToMethodNameMap = nil;
// This control is similar to what VoiceOver calls a "stepper".
return base::SysUTF16ToNSString(content_client->GetLocalizedString(
IDS_AX_ROLE_STEPPER));
+ case ui::AX_ROLE_TOGGLE_BUTTON:
+ return base::SysUTF16ToNSString(content_client->GetLocalizedString(
+ IDS_AX_ROLE_TOGGLE_BUTTON));
default:
break;
}
@@ -861,6 +876,18 @@ NSDictionary* attributeToMethodNameMap = nil;
} else if ([role isEqualToString:NSAccessibilityButtonRole]) {
// AXValue does not make sense for pure buttons.
return @"";
+ } else if ([self internalRole] == ui::AX_ROLE_TOGGLE_BUTTON) {
+ int value = 0;
+ bool isAriaPressedDefined;
+ bool isMixed;
+ value = browserAccessibility_->GetAriaTristate(
+ "aria-pressed", &isAriaPressedDefined, &isMixed) ? 1 : 0;
+
+ if (isMixed)
+ value = 2;
+
+ return [NSNumber numberWithInt:value];
+
} else if ([role isEqualToString:NSAccessibilityCheckBoxRole] ||
[role isEqualToString:NSAccessibilityRadioButtonRole]) {
int value = 0;
« no previous file with comments | « no previous file | content/test/data/accessibility/aria-pressed.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698