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 9edb01336f2b23b0513e8bf4e20d314dc76925e0..e362bea5e7fb377fe11b9f0920e536b0f9c16b43 100644 |
| --- a/ui/accessibility/platform/ax_platform_node_mac.mm |
| +++ b/ui/accessibility/platform/ax_platform_node_mac.mm |
| @@ -355,23 +355,30 @@ void NotifyMacEvent(AXPlatformNodeCocoa* target, ui::AXEvent event_type) { |
| // Attributes required for user-editable controls. |
| NSArray* const kValueAttributes = @[ NSAccessibilityValueAttribute ]; |
| - // Attributes required for textfields. |
| - NSArray* const kTextfieldAttributes = @[ |
| + // Attributes required for unprotected textfields. |
| + NSArray* const kUnprotectedTextfieldAttributes = @[ |
| NSAccessibilityInsertionPointLineNumberAttribute, |
| NSAccessibilityNumberOfCharactersAttribute, |
| - NSAccessibilityPlaceholderValueAttribute, |
| NSAccessibilitySelectedTextAttribute, |
| NSAccessibilitySelectedTextRangeAttribute, |
| NSAccessibilityVisibleCharacterRangeAttribute, |
| ]; |
| + // Required for all textfields, including protected ones. |
| + NSString* const kTextfieldAttributes = |
| + NSAccessibilityPlaceholderValueAttribute; |
| + |
| base::scoped_nsobject<NSMutableArray> axAttributes( |
| [[NSMutableArray alloc] init]); |
| [axAttributes addObjectsFromArray:kAllRoleAttributes]; |
| switch (node_->GetData().role) { |
| case ui::AX_ROLE_TEXT_FIELD: |
| - [axAttributes addObjectsFromArray:kTextfieldAttributes]; |
| + [axAttributes addObject:kTextfieldAttributes]; |
| + if (!ui::AXNodeData::IsFlagSet(node_->GetData().state, |
| + ui::AX_STATE_PROTECTED)) { |
| + [axAttributes addObjectsFromArray:kUnprotectedTextfieldAttributes]; |
| + } |
| // Fallthrough. |
| case ui::AX_ROLE_CHECK_BOX: |
| case ui::AX_ROLE_COMBO_BOX: |
| @@ -405,11 +412,15 @@ void NotifyMacEvent(AXPlatformNodeCocoa* target, ui::AXEvent event_type) { |
| return NO; |
| } |
| - // Since tabs use the Radio Button role on Mac, the standard way to set them |
| - // is via the value attribute rather than the selected attribute. |
| - if ([attributeName isEqualToString:NSAccessibilityValueAttribute] && |
| - node_->GetData().role == ui::AX_ROLE_TAB) { |
| - return !node_->GetData().HasStateFlag(ui::AX_STATE_SELECTED); |
| + if ([attributeName isEqualToString:NSAccessibilityValueAttribute]) { |
| + // Since tabs use the Radio Button role on Mac, the standard way to set them |
| + // is via the value attribute rather than the selected attribute. |
| + if (node_->GetData().role == ui::AX_ROLE_TAB) |
| + return !node_->GetData().HasStateFlag(ui::AX_STATE_SELECTED); |
| + // NSSecureTextField doesn't allow values to be edited (despite showing up |
| + // as editable), match its behavior. |
| + else if (node_->GetData().HasStateFlag(ui::AX_STATE_PROTECTED)) |
|
tapted
2017/02/23 06:20:34
nit: no else after return, also should this check
Patti Lor
2017/02/24 04:36:14
The else is a no-op, so I just left it out. Is it
|
| + return NO; |
| } |
| if ([attributeName isEqualToString:NSAccessibilityValueAttribute] || |
| @@ -583,12 +594,18 @@ void NotifyMacEvent(AXPlatformNodeCocoa* target, ui::AXEvent event_type) { |
| // Text-specific attributes. |
| - (NSString*)AXSelectedText { |
| + if (ui::AXNodeData::IsFlagSet(node_->GetData().state, ui::AX_STATE_PROTECTED)) |
| + return nil; |
| + |
| NSRange selectedTextRange; |
| [[self AXSelectedTextRange] getValue:&selectedTextRange]; |
| return [[self AXValue] substringWithRange:selectedTextRange]; |
| } |
| - (NSValue*)AXSelectedTextRange { |
| + if (ui::AXNodeData::IsFlagSet(node_->GetData().state, ui::AX_STATE_PROTECTED)) |
| + return nil; |
| + |
| int textDir, start, end; |
| node_->GetIntAttribute(ui::AX_ATTR_TEXT_DIRECTION, &textDir); |
| node_->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, &start); |
| @@ -603,14 +620,20 @@ void NotifyMacEvent(AXPlatformNodeCocoa* target, ui::AXEvent event_type) { |
| } |
| - (NSNumber*)AXNumberOfCharacters { |
| + if (ui::AXNodeData::IsFlagSet(node_->GetData().state, ui::AX_STATE_PROTECTED)) |
| + return nil; |
| return @([[self AXValue] length]); |
| } |
| - (NSValue*)AXVisibleCharacterRange { |
| + if (ui::AXNodeData::IsFlagSet(node_->GetData().state, ui::AX_STATE_PROTECTED)) |
| + return nil; |
| return [NSValue valueWithRange:{0, [[self AXNumberOfCharacters] intValue]}]; |
| } |
| - (NSNumber*)AXInsertionPointLineNumber { |
| + if (ui::AXNodeData::IsFlagSet(node_->GetData().state, ui::AX_STATE_PROTECTED)) |
| + return nil; |
| // Multiline is not supported on views. |
| return @0; |
| } |