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_role_properties.h" | 14 #include "ui/accessibility/ax_role_properties.h" |
| 15 #include "ui/accessibility/platform/ax_platform_node.h" | |
| 15 #include "ui/accessibility/platform/ax_platform_node_delegate.h" | 16 #include "ui/accessibility/platform/ax_platform_node_delegate.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 17 #import "ui/gfx/mac/coordinate_conversion.h" | 18 #import "ui/gfx/mac/coordinate_conversion.h" |
| 18 #include "ui/strings/grit/ui_strings.h" | 19 #include "ui/strings/grit/ui_strings.h" |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 struct RoleMapEntry { | 23 struct RoleMapEntry { |
| 23 ui::AXRole value; | 24 ui::AXRole value; |
| 24 NSString* nativeValue; | 25 NSString* nativeValue; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 target, [AXPlatformNodeCocoa nativeNotificationFromAXEvent:event_type]); | 224 target, [AXPlatformNodeCocoa nativeNotificationFromAXEvent:event_type]); |
| 224 } | 225 } |
| 225 | 226 |
| 226 } // namespace | 227 } // namespace |
| 227 | 228 |
| 228 @interface AXPlatformNodeCocoa () | 229 @interface AXPlatformNodeCocoa () |
| 229 // Helper function for string attributes that don't require extra processing. | 230 // Helper function for string attributes that don't require extra processing. |
| 230 - (NSString*)getStringAttribute:(ui::AXStringAttribute)attribute; | 231 - (NSString*)getStringAttribute:(ui::AXStringAttribute)attribute; |
| 231 @end | 232 @end |
| 232 | 233 |
| 233 @implementation AXPlatformNodeCocoa | 234 @implementation AXPlatformNodeCocoa { |
| 235 ui::AXPlatformNodeBase* node_; // Weak. Retains us. | |
| 236 } | |
| 237 | |
| 238 @synthesize node = node_; | |
| 234 | 239 |
| 235 // A mapping of AX roles to native roles. | 240 // A mapping of AX roles to native roles. |
| 236 + (NSString*)nativeRoleFromAXRole:(ui::AXRole)role { | 241 + (NSString*)nativeRoleFromAXRole:(ui::AXRole)role { |
| 237 CR_DEFINE_STATIC_LOCAL(RoleMap, role_map, (BuildRoleMap())); | 242 CR_DEFINE_STATIC_LOCAL(RoleMap, role_map, (BuildRoleMap())); |
| 238 RoleMap::iterator it = role_map.find(role); | 243 RoleMap::iterator it = role_map.find(role); |
| 239 return it != role_map.end() ? it->second : NSAccessibilityUnknownRole; | 244 return it != role_map.end() ? it->second : NSAccessibilityUnknownRole; |
| 240 } | 245 } |
| 241 | 246 |
| 242 // A mapping of AX roles to native subroles. | 247 // A mapping of AX roles to native subroles. |
| 243 + (NSString*)nativeSubroleFromAXRole:(ui::AXRole)role { | 248 + (NSString*)nativeSubroleFromAXRole:(ui::AXRole)role { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 | 288 |
| 284 // NSAccessibility informal protocol implementation. | 289 // NSAccessibility informal protocol implementation. |
| 285 | 290 |
| 286 - (BOOL)accessibilityIsIgnored { | 291 - (BOOL)accessibilityIsIgnored { |
| 287 return [[self AXRole] isEqualToString:NSAccessibilityUnknownRole] || | 292 return [[self AXRole] isEqualToString:NSAccessibilityUnknownRole] || |
| 288 node_->GetData().HasStateFlag(ui::AX_STATE_INVISIBLE); | 293 node_->GetData().HasStateFlag(ui::AX_STATE_INVISIBLE); |
| 289 } | 294 } |
| 290 | 295 |
| 291 - (id)accessibilityHitTest:(NSPoint)point { | 296 - (id)accessibilityHitTest:(NSPoint)point { |
| 292 for (AXPlatformNodeCocoa* child in [self AXChildren]) { | 297 for (AXPlatformNodeCocoa* child in [self AXChildren]) { |
| 293 if (NSPointInRect(point, child.boundsInScreen)) | 298 if (NSPointInRect(point, [child boundsInScreen])) |
| 294 return [child accessibilityHitTest:point]; | 299 return [child accessibilityHitTest:point]; |
| 295 } | 300 } |
| 296 return NSAccessibilityUnignoredAncestor(self); | 301 return NSAccessibilityUnignoredAncestor(self); |
| 297 } | 302 } |
| 298 | 303 |
| 299 - (BOOL)accessibilityNotifiesWhenDestroyed { | 304 - (BOOL)accessibilityNotifiesWhenDestroyed { |
| 300 return YES; | 305 return YES; |
| 301 } | 306 } |
| 302 | 307 |
| 303 - (id)accessibilityFocusedUIElement { | 308 - (id)accessibilityFocusedUIElement { |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 619 | 624 |
| 620 namespace ui { | 625 namespace ui { |
| 621 | 626 |
| 622 // static | 627 // static |
| 623 AXPlatformNode* AXPlatformNode::Create(AXPlatformNodeDelegate* delegate) { | 628 AXPlatformNode* AXPlatformNode::Create(AXPlatformNodeDelegate* delegate) { |
| 624 AXPlatformNodeBase* node = new AXPlatformNodeMac(); | 629 AXPlatformNodeBase* node = new AXPlatformNodeMac(); |
| 625 node->Init(delegate); | 630 node->Init(delegate); |
| 626 return node; | 631 return node; |
| 627 } | 632 } |
| 628 | 633 |
| 634 // static | |
| 635 AX_EXPORT AXPlatformNode* AXPlatformNode::FromNativeViewAccessible( | |
|
tapted
2017/03/06 01:43:09
remove AX_EXPORT
Patti Lor
2017/03/13 03:03:25
Done.
| |
| 636 gfx::NativeViewAccessible accessible) { | |
| 637 if ([accessible isKindOfClass:[AXPlatformNodeCocoa class]]) | |
| 638 return [accessible node]; | |
| 639 return nullptr; | |
| 640 } | |
| 641 | |
| 629 AXPlatformNodeMac::AXPlatformNodeMac() { | 642 AXPlatformNodeMac::AXPlatformNodeMac() { |
| 630 } | 643 } |
| 631 | 644 |
| 632 AXPlatformNodeMac::~AXPlatformNodeMac() { | 645 AXPlatformNodeMac::~AXPlatformNodeMac() { |
| 633 } | 646 } |
| 634 | 647 |
| 635 void AXPlatformNodeMac::Destroy() { | 648 void AXPlatformNodeMac::Destroy() { |
| 636 if (native_node_) | 649 if (native_node_) |
| 637 [native_node_ detach]; | 650 [native_node_ detach]; |
| 638 AXPlatformNodeBase::Destroy(); | 651 AXPlatformNodeBase::Destroy(); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 661 } | 674 } |
| 662 NotifyMacEvent(native_node_, event_type); | 675 NotifyMacEvent(native_node_, event_type); |
| 663 } | 676 } |
| 664 | 677 |
| 665 int AXPlatformNodeMac::GetIndexInParent() { | 678 int AXPlatformNodeMac::GetIndexInParent() { |
| 666 // TODO(dmazzoni): implement this. http://crbug.com/396137 | 679 // TODO(dmazzoni): implement this. http://crbug.com/396137 |
| 667 return -1; | 680 return -1; |
| 668 } | 681 } |
| 669 | 682 |
| 670 } // namespace ui | 683 } // namespace ui |
| OLD | NEW |