Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ui/accessibility/platform/ax_platform_node_mac.h" | 5 #import "ui/accessibility/platform/ax_platform_node_mac.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 12 #include "ui/accessibility/ax_action_data.h" | 12 #include "ui/accessibility/ax_action_data.h" |
| 13 #include "ui/accessibility/ax_node_data.h" | 13 #include "ui/accessibility/ax_node_data.h" |
| 14 #include "ui/accessibility/ax_utils.h" | |
| 14 #include "ui/accessibility/platform/ax_platform_node_delegate.h" | 15 #include "ui/accessibility/platform/ax_platform_node_delegate.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 16 #import "ui/gfx/mac/coordinate_conversion.h" | 17 #import "ui/gfx/mac/coordinate_conversion.h" |
| 17 #include "ui/strings/grit/ui_strings.h" | 18 #include "ui/strings/grit/ui_strings.h" |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 struct RoleMapEntry { | 22 struct RoleMapEntry { |
| 22 ui::AXRole value; | 23 ui::AXRole value; |
| 23 NSString* nativeValue; | 24 NSString* nativeValue; |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 | 298 |
| 298 - (BOOL)accessibilityNotifiesWhenDestroyed { | 299 - (BOOL)accessibilityNotifiesWhenDestroyed { |
| 299 return YES; | 300 return YES; |
| 300 } | 301 } |
| 301 | 302 |
| 302 - (id)accessibilityFocusedUIElement { | 303 - (id)accessibilityFocusedUIElement { |
| 303 return node_->GetDelegate()->GetFocus(); | 304 return node_->GetDelegate()->GetFocus(); |
| 304 } | 305 } |
| 305 | 306 |
| 306 - (NSArray*)accessibilityActionNames { | 307 - (NSArray*)accessibilityActionNames { |
| 307 return nil; | 308 base::scoped_nsobject<NSMutableArray> axActions( |
| 309 [[NSMutableArray alloc] init]); | |
| 310 | |
| 311 // VoiceOver expects the "press" action to be first. | |
| 312 if (ui::IsRoleClickable(node_->GetData().role)) | |
| 313 [axActions addObject:NSAccessibilityPressAction]; | |
|
tapted
2017/02/09 02:45:18
Do we expect much more to appear in future? E.g. w
Patti Lor
2017/02/09 23:11:23
I think so, yes - "ConfirmAction" simulates pressi
tapted
2017/02/09 23:25:05
Ack.
| |
| 314 | |
| 315 return axActions.autorelease(); | |
| 316 } | |
| 317 | |
| 318 - (void)accessibilityPerformAction:(NSString*)action { | |
| 319 DCHECK([[self accessibilityActionNames] containsObject:action]); | |
| 320 ui::AXActionData data; | |
| 321 if ([action isEqualToString:NSAccessibilityPressAction]) { | |
|
tapted
2017/02/09 02:45:18
nit: curlies not required
Patti Lor
2017/02/09 23:11:23
Done.
| |
| 322 data.action = ui::AX_ACTION_DO_DEFAULT; | |
| 323 } | |
| 324 | |
| 325 if (data.action != ui::AX_ACTION_NONE) | |
| 326 node_->GetDelegate()->AccessibilityPerformAction(data); | |
| 308 } | 327 } |
| 309 | 328 |
| 310 - (NSArray*)accessibilityAttributeNames { | 329 - (NSArray*)accessibilityAttributeNames { |
| 311 // These attributes are required on all accessibility objects. | 330 // These attributes are required on all accessibility objects. |
| 312 NSArray* const kAllRoleAttributes = @[ | 331 NSArray* const kAllRoleAttributes = @[ |
| 313 NSAccessibilityChildrenAttribute, | 332 NSAccessibilityChildrenAttribute, |
| 314 NSAccessibilityParentAttribute, | 333 NSAccessibilityParentAttribute, |
| 315 NSAccessibilityPositionAttribute, | 334 NSAccessibilityPositionAttribute, |
| 316 NSAccessibilityRoleAttribute, | 335 NSAccessibilityRoleAttribute, |
| 317 NSAccessibilitySizeAttribute, | 336 NSAccessibilitySizeAttribute, |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 631 } | 650 } |
| 632 NotifyMacEvent(native_node_, event_type); | 651 NotifyMacEvent(native_node_, event_type); |
| 633 } | 652 } |
| 634 | 653 |
| 635 int AXPlatformNodeMac::GetIndexInParent() { | 654 int AXPlatformNodeMac::GetIndexInParent() { |
| 636 // TODO(dmazzoni): implement this. http://crbug.com/396137 | 655 // TODO(dmazzoni): implement this. http://crbug.com/396137 |
| 637 return -1; | 656 return -1; |
| 638 } | 657 } |
| 639 | 658 |
| 640 } // namespace ui | 659 } // namespace ui |
| OLD | NEW |