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

Unified Diff: ui/accessibility/platform/ax_platform_node_mac.mm

Issue 2016243002: Mac a11y: Add RoleDescription and Value attributes to accessibility information. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: TODO for comparing against Cocoa. Created 4 years, 7 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 | ui/gfx/mac/coordinate_conversion.h » ('j') | ui/gfx/mac/coordinate_conversion.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/accessibility/platform/ax_platform_node_mac.mm
diff --git a/ui/accessibility/platform/ax_platform_node_mac.mm b/ui/accessibility/platform/ax_platform_node_mac.mm
index 620841889eae237edc5ee3a5a3f4f237f6de4a33..364ebee10542afd33e942bfcf2cfbd2bfda74cb8 100644
--- a/ui/accessibility/platform/ax_platform_node_mac.mm
+++ b/ui/accessibility/platform/ax_platform_node_mac.mm
@@ -190,6 +190,11 @@ RoleMap BuildSubroleMap() {
} // namespace
+@interface AXPlatformNodeCocoa ()
+// Helper function for string attributes that don't require extra processing.
+- (NSString*)getStringAttribute:(ui::AXStringAttribute)attribute;
+@end
+
@implementation AXPlatformNodeCocoa
// A mapping of AX roles to native roles.
@@ -223,40 +228,10 @@ RoleMap BuildSubroleMap() {
return gfx::ScreenRectToNSRect(node_->GetBoundsInScreen());
}
-- (NSArray*)AXChildren {
- if (!node_)
- return nil;
- int count = node_->GetChildCount();
- NSMutableArray* children = [NSMutableArray arrayWithCapacity:count];
- for (int i = 0; i < count; ++i)
- [children addObject:node_->ChildAtIndex(i)];
- return NSAccessibilityUnignoredChildren(children);
-}
-
-- (id)AXParent {
- if (!node_)
- return nil;
- return NSAccessibilityUnignoredAncestor(node_->GetParent());
-}
-
-- (NSValue*)AXPosition {
- return [NSValue valueWithPoint:self.boundsInScreen.origin];
-}
-
-- (NSString*)AXRole {
- if (!node_)
- return nil;
- return [[self class] nativeRoleFromAXRole:node_->GetData().role];
-}
-
-- (NSValue*)AXSize {
- return [NSValue valueWithSize:self.boundsInScreen.size];
-}
-
-- (NSString*)AXTitle {
- std::string value;
- if (node_->GetStringAttribute(ui::AX_ATTR_NAME, &value))
- return base::SysUTF8ToNSString(value);
+- (NSString*)getStringAttribute:(ui::AXStringAttribute)attribute {
+ std::string attributeValue;
+ if (node_->GetStringAttribute(attribute, &attributeValue))
+ return base::SysUTF8ToNSString(attributeValue);
return nil;
}
@@ -290,6 +265,10 @@ RoleMap BuildSubroleMap() {
// Title is required for most elements. Cocoa asks for the value even if it
// is omitted here, but won't present it to accessibility APIs without this.
NSAccessibilityTitleAttribute,
+
+ // Attributes which are not required, but are general to all roles.
+ NSAccessibilityRoleDescriptionAttribute,
+ NSAccessibilityValueAttribute,
tapted 2016/06/06 04:09:51 So I poked around a bit - I think doing this for R
Patti Lor 2016/06/10 01:36:10 Have added switch to add Value attributes on a bun
];
// TODO(tapted): Add additional attributes based on role.
}
@@ -305,6 +284,50 @@ RoleMap BuildSubroleMap() {
return nil;
}
+// NSAccessibility attributes.
+
+- (NSArray*)AXChildren {
+ if (!node_)
+ return nil;
+ int count = node_->GetChildCount();
+ NSMutableArray* children = [NSMutableArray arrayWithCapacity:count];
+ for (int i = 0; i < count; ++i)
+ [children addObject:node_->ChildAtIndex(i)];
+ return NSAccessibilityUnignoredChildren(children);
+}
+
+- (id)AXParent {
+ if (!node_)
+ return nil;
+ return NSAccessibilityUnignoredAncestor(node_->GetParent());
+}
+
+- (NSValue*)AXPosition {
+ return [NSValue valueWithPoint:self.boundsInScreen.origin];
+}
+
+- (NSString*)AXRole {
+ if (!node_)
+ return nil;
+ return [[self class] nativeRoleFromAXRole:node_->GetData().role];
+}
+
+- (NSValue*)AXSize {
+ return [NSValue valueWithSize:self.boundsInScreen.size];
+}
+
+- (NSString*)AXTitle {
+ return [self getStringAttribute:ui::AX_ATTR_NAME];
+}
+
+- (NSString*)AXRoleDescription {
+ return [self getStringAttribute:ui::AX_ATTR_DESCRIPTION];
tapted 2016/06/06 04:09:51 So if this returns nil, I think we should then try
Patti Lor 2016/06/10 01:36:09 Works with nil values! Done. Have also added the s
tapted 2016/06/10 03:17:17 What string does it return for nil? The API is NS
Patti Lor 2016/06/16 07:05:21 Having a nil role returns an empty NSString, so I'
+}
+
+- (NSString*)AXValue {
+ return [self getStringAttribute:ui::AX_ATTR_VALUE];
+}
+
@end
namespace ui {
« no previous file with comments | « no previous file | ui/gfx/mac/coordinate_conversion.h » ('j') | ui/gfx/mac/coordinate_conversion.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698