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 240240e6180bc11f40e56de4fa36fdafd9e65b81..67da9536cc19da3c2cdc6a5b4b8aa103a654a2a6 100644 |
| --- a/ui/accessibility/platform/ax_platform_node_mac.mm |
| +++ b/ui/accessibility/platform/ax_platform_node_mac.mm |
| @@ -412,6 +412,32 @@ void NotifyMacEvent(AXPlatformNodeCocoa* target, ui::AXEvent event_type) { |
| return axAttributes.autorelease(); |
| } |
| +- (NSArray*)accessibilityParameterizedAttributeNames { |
| + if (!node_) |
| + return nil; |
| + |
| + static NSArray* const kEditableTextAttributes = [@[ |
| + NSAccessibilityLineForIndexParameterizedAttribute, |
| + NSAccessibilityRangeForLineParameterizedAttribute, |
| + NSAccessibilityStringForRangeParameterizedAttribute, |
| + NSAccessibilityRangeForPositionParameterizedAttribute, |
| + NSAccessibilityRangeForIndexParameterizedAttribute, |
| + NSAccessibilityBoundsForRangeParameterizedAttribute, |
| + NSAccessibilityRTFForRangeParameterizedAttribute, |
| + NSAccessibilityStyleRangeForIndexParameterizedAttribute, |
| + NSAccessibilityAttributedStringForRangeParameterizedAttribute, |
| + ] retain]; |
| + |
| + switch (node_->GetData().role) { |
| + case ui::AX_ROLE_TEXT_FIELD: |
| + case ui::AX_ROLE_STATIC_TEXT: |
| + return kEditableTextAttributes; |
|
dmazzoni
2017/06/26 16:50:05
If we're exposing these for STATIC_TEXT, maybe a b
tapted
2017/06/27 00:56:24
Good point! Done.
|
| + default: |
| + break; |
| + } |
| + return nil; |
| +} |
| + |
| - (BOOL)accessibilityIsAttributeSettable:(NSString*)attributeName { |
| if (node_->GetData().HasState(ui::AX_STATE_DISABLED)) |
| return NO; |
| @@ -494,6 +520,14 @@ void NotifyMacEvent(AXPlatformNodeCocoa* target, ui::AXEvent event_type) { |
| return nil; |
| } |
| +- (id)accessibilityAttributeValue:(NSString*)attribute |
| + forParameter:(id)parameter { |
| + SEL selector = NSSelectorFromString([attribute stringByAppendingString:@":"]); |
| + if ([self respondsToSelector:selector]) |
| + return [self performSelector:selector withObject:parameter]; |
| + return nil; |
| +} |
| + |
| // NSAccessibility attributes. Order them according to |
| // NSAccessibilityConstants.h, or see https://crbug.com/678898. |
| @@ -633,6 +667,69 @@ void NotifyMacEvent(AXPlatformNodeCocoa* target, ui::AXEvent event_type) { |
| return @0; |
| } |
| +// Parameterized text-specific attributes. |
| + |
| +- (id)AXLineForIndex:(id)parameter { |
| + DCHECK([parameter isKindOfClass:[NSNumber class]]); |
| + // Multiline is not supported on views. |
| + return @0; |
|
tapted
2017/06/26 09:18:51
This matches what's currently done for AXInsertion
|
| +} |
| + |
| +- (id)AXRangeForLine:(id)parameter { |
| + DCHECK([parameter isKindOfClass:[NSNumber class]]); |
| + DCHECK_EQ(0, [parameter intValue]); |
| + return [NSValue valueWithRange:{0, [[self getAXValueAsString] length]}]; |
| +} |
| + |
| +- (id)AXStringForRange:(id)parameter { |
| + DCHECK([parameter isKindOfClass:[NSValue class]]); |
| + return [[self getAXValueAsString] substringWithRange:[parameter rangeValue]]; |
| +} |
| + |
| +- (id)AXRangeForPosition:(id)parameter { |
| + DCHECK([parameter isKindOfClass:[NSValue class]]); |
| + // TODO(tapted): Hit-test [parameter pointValue] and return an NSRange. |
| + NOTIMPLEMENTED(); |
| + return nil; |
| +} |
| + |
| +- (id)AXRangeForIndex:(id)parameter { |
| + DCHECK([parameter isKindOfClass:[NSNumber class]]); |
| + NOTIMPLEMENTED(); |
| + return nil; |
| +} |
| + |
| +- (id)AXBoundsForRange:(id)parameter { |
| + DCHECK([parameter isKindOfClass:[NSValue class]]); |
| + // TODO(tapted): Provide an accessor on AXPlatformNodeDelegate to obtain this |
| + // from ui::TextInputClient::GetCompositionCharacterBounds(). |
| + NOTIMPLEMENTED(); |
|
tapted
2017/06/26 09:18:51
This is the only one I've been able to hit with ba
|
| + return nil; |
| +} |
| + |
| +- (id)AXRTFForRange:(id)parameter { |
| + DCHECK([parameter isKindOfClass:[NSValue class]]); |
| + NOTIMPLEMENTED(); |
| + return nil; |
| +} |
| + |
| +- (id)AXStyleRangeForIndex:(id)parameter { |
| + DCHECK([parameter isKindOfClass:[NSNumber class]]); |
| + NOTIMPLEMENTED(); |
| + return nil; |
| +} |
| + |
| +- (id)AXAttributedStringForRange:(id)parameter { |
| + DCHECK([parameter isKindOfClass:[NSValue class]]); |
| + base::scoped_nsobject<NSAttributedString> attributedString( |
| + [[NSAttributedString alloc] |
| + initWithString:[self AXStringForRange:parameter]]); |
| + // TODO(tapted): views::WordLookupClient has a way to obtain the actual |
| + // decorations, and BridgedContentView has a conversion function that creates |
| + // an NSAttributedString. Refactor things so they can be used here. |
| + return attributedString.autorelease(); |
| +} |
| + |
| @end |
| namespace ui { |