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" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 target, [AXPlatformNodeCocoa nativeNotificationFromAXEvent:event_type]); | 223 target, [AXPlatformNodeCocoa nativeNotificationFromAXEvent:event_type]); |
224 } | 224 } |
225 | 225 |
226 } // namespace | 226 } // namespace |
227 | 227 |
228 @interface AXPlatformNodeCocoa () | 228 @interface AXPlatformNodeCocoa () |
229 // Helper function for string attributes that don't require extra processing. | 229 // Helper function for string attributes that don't require extra processing. |
230 - (NSString*)getStringAttribute:(ui::AXStringAttribute)attribute; | 230 - (NSString*)getStringAttribute:(ui::AXStringAttribute)attribute; |
231 @end | 231 @end |
232 | 232 |
233 @implementation AXPlatformNodeCocoa | 233 @implementation AXPlatformNodeCocoa { |
| 234 ui::AXPlatformNodeBase* node_; // Weak. Retains us. |
| 235 } |
| 236 |
| 237 @synthesize node = node_; |
234 | 238 |
235 // A mapping of AX roles to native roles. | 239 // A mapping of AX roles to native roles. |
236 + (NSString*)nativeRoleFromAXRole:(ui::AXRole)role { | 240 + (NSString*)nativeRoleFromAXRole:(ui::AXRole)role { |
237 CR_DEFINE_STATIC_LOCAL(RoleMap, role_map, (BuildRoleMap())); | 241 CR_DEFINE_STATIC_LOCAL(RoleMap, role_map, (BuildRoleMap())); |
238 RoleMap::iterator it = role_map.find(role); | 242 RoleMap::iterator it = role_map.find(role); |
239 return it != role_map.end() ? it->second : NSAccessibilityUnknownRole; | 243 return it != role_map.end() ? it->second : NSAccessibilityUnknownRole; |
240 } | 244 } |
241 | 245 |
242 // A mapping of AX roles to native subroles. | 246 // A mapping of AX roles to native subroles. |
243 + (NSString*)nativeSubroleFromAXRole:(ui::AXRole)role { | 247 + (NSString*)nativeSubroleFromAXRole:(ui::AXRole)role { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 287 |
284 // NSAccessibility informal protocol implementation. | 288 // NSAccessibility informal protocol implementation. |
285 | 289 |
286 - (BOOL)accessibilityIsIgnored { | 290 - (BOOL)accessibilityIsIgnored { |
287 return [[self AXRole] isEqualToString:NSAccessibilityUnknownRole] || | 291 return [[self AXRole] isEqualToString:NSAccessibilityUnknownRole] || |
288 node_->GetData().HasStateFlag(ui::AX_STATE_INVISIBLE); | 292 node_->GetData().HasStateFlag(ui::AX_STATE_INVISIBLE); |
289 } | 293 } |
290 | 294 |
291 - (id)accessibilityHitTest:(NSPoint)point { | 295 - (id)accessibilityHitTest:(NSPoint)point { |
292 for (AXPlatformNodeCocoa* child in [self AXChildren]) { | 296 for (AXPlatformNodeCocoa* child in [self AXChildren]) { |
293 if (NSPointInRect(point, child.boundsInScreen)) | 297 if (![child accessibilityIsIgnored] && |
| 298 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( |
| 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 |