Chromium Code Reviews| 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 { |