Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(878)

Side by Side Diff: ui/accessibility/platform/ax_platform_node_mac.mm

Issue 2715543003: Views a11y: Implement AXPlatformNode::FromNativeViewAccessible on all platforms. (Closed)
Patch Set: Make GetForView protected. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 (NSPointInRect(point, [child boundsInScreen]))
294 return [child accessibilityHitTest:point]; 298 return [child accessibilityHitTest:point];
295 } 299 }
296 return NSAccessibilityUnignoredAncestor(self); 300 return NSAccessibilityUnignoredAncestor(self);
297 } 301 }
298 302
299 - (BOOL)accessibilityNotifiesWhenDestroyed { 303 - (BOOL)accessibilityNotifiesWhenDestroyed {
300 return YES; 304 return YES;
301 } 305 }
302 306
303 - (id)accessibilityFocusedUIElement { 307 - (id)accessibilityFocusedUIElement {
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 623
620 namespace ui { 624 namespace ui {
621 625
622 // static 626 // static
623 AXPlatformNode* AXPlatformNode::Create(AXPlatformNodeDelegate* delegate) { 627 AXPlatformNode* AXPlatformNode::Create(AXPlatformNodeDelegate* delegate) {
624 AXPlatformNodeBase* node = new AXPlatformNodeMac(); 628 AXPlatformNodeBase* node = new AXPlatformNodeMac();
625 node->Init(delegate); 629 node->Init(delegate);
626 return node; 630 return node;
627 } 631 }
628 632
633 // static
634 AX_EXPORT AXPlatformNode* AXPlatformNode::FromNativeViewAccessible(
635 gfx::NativeViewAccessible accessible) {
636 if ([accessible isKindOfClass:[AXPlatformNodeCocoa class]])
637 return [accessible node];
638 return nullptr;
639 }
640
629 AXPlatformNodeMac::AXPlatformNodeMac() { 641 AXPlatformNodeMac::AXPlatformNodeMac() {
630 } 642 }
631 643
632 AXPlatformNodeMac::~AXPlatformNodeMac() { 644 AXPlatformNodeMac::~AXPlatformNodeMac() {
633 } 645 }
634 646
635 void AXPlatformNodeMac::Destroy() { 647 void AXPlatformNodeMac::Destroy() {
636 if (native_node_) 648 if (native_node_)
637 [native_node_ detach]; 649 [native_node_ detach];
638 AXPlatformNodeBase::Destroy(); 650 AXPlatformNodeBase::Destroy();
(...skipping 22 matching lines...) Expand all
661 } 673 }
662 NotifyMacEvent(native_node_, event_type); 674 NotifyMacEvent(native_node_, event_type);
663 } 675 }
664 676
665 int AXPlatformNodeMac::GetIndexInParent() { 677 int AXPlatformNodeMac::GetIndexInParent() {
666 // TODO(dmazzoni): implement this. http://crbug.com/396137 678 // TODO(dmazzoni): implement this. http://crbug.com/396137
667 return -1; 679 return -1;
668 } 680 }
669 681
670 } // namespace ui 682 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698