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

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: Try removing default impl for FromNativeViewAccessible again. 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
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_mac.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
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
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 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 648
644 namespace ui { 649 namespace ui {
645 650
646 // static 651 // static
647 AXPlatformNode* AXPlatformNode::Create(AXPlatformNodeDelegate* delegate) { 652 AXPlatformNode* AXPlatformNode::Create(AXPlatformNodeDelegate* delegate) {
648 AXPlatformNodeBase* node = new AXPlatformNodeMac(); 653 AXPlatformNodeBase* node = new AXPlatformNodeMac();
649 node->Init(delegate); 654 node->Init(delegate);
650 return node; 655 return node;
651 } 656 }
652 657
658 // static
659 AXPlatformNode* AXPlatformNode::FromNativeViewAccessible(
660 gfx::NativeViewAccessible accessible) {
661 if ([accessible isKindOfClass:[AXPlatformNodeCocoa class]])
662 return [accessible node];
663 return nullptr;
664 }
665
653 AXPlatformNodeMac::AXPlatformNodeMac() { 666 AXPlatformNodeMac::AXPlatformNodeMac() {
654 } 667 }
655 668
656 AXPlatformNodeMac::~AXPlatformNodeMac() { 669 AXPlatformNodeMac::~AXPlatformNodeMac() {
657 } 670 }
658 671
659 void AXPlatformNodeMac::Destroy() { 672 void AXPlatformNodeMac::Destroy() {
660 if (native_node_) 673 if (native_node_)
661 [native_node_ detach]; 674 [native_node_ detach];
662 AXPlatformNodeBase::Destroy(); 675 AXPlatformNodeBase::Destroy();
(...skipping 22 matching lines...) Expand all
685 } 698 }
686 NotifyMacEvent(native_node_, event_type); 699 NotifyMacEvent(native_node_, event_type);
687 } 700 }
688 701
689 int AXPlatformNodeMac::GetIndexInParent() { 702 int AXPlatformNodeMac::GetIndexInParent() {
690 // TODO(dmazzoni): implement this. http://crbug.com/396137 703 // TODO(dmazzoni): implement this. http://crbug.com/396137
691 return -1; 704 return -1;
692 } 705 }
693 706
694 } // namespace ui 707 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698