| 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 #include "ui/accessibility/platform/ax_platform_node.h" | 5 #include "ui/accessibility/platform/ax_platform_node.h" |
| 6 | 6 |
| 7 #include "base/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "ui/accessibility/ax_node_data.h" | 10 #include "ui/accessibility/ax_node_data.h" |
| 11 #include "ui/accessibility/platform/ax_platform_node_delegate.h" | 11 #include "ui/accessibility/platform/ax_platform_node_delegate.h" |
| 12 | 12 |
| 13 namespace ui { | 13 namespace ui { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 using UniqueIdMap = base::hash_map<int32_t, AXPlatformNode*>; | 17 using UniqueIdMap = base::hash_map<int32_t, AXPlatformNode*>; |
| 18 // Map from each AXPlatformNode's unique id to its instance. | 18 // Map from each AXPlatformNode's unique id to its instance. |
| 19 base::LazyInstance<UniqueIdMap> g_unique_id_map = | 19 base::LazyInstance<UniqueIdMap> g_unique_id_map = |
| 20 LAZY_INSTANCE_INITIALIZER; | 20 LAZY_INSTANCE_INITIALIZER; |
| 21 | 21 |
| 22 } | 22 } |
| 23 | 23 |
| 24 #if !defined(PLATFORM_HAS_AX_PLATFORM_NODE_IMPL) | 24 #if !defined(PLATFORM_HAS_AX_PLATFORM_NODE_IMPL) |
| 25 // static | 25 // static |
| 26 AXPlatformNode* AXPlatformNode::Create(AXPlatformNodeDelegate* delegate) { | 26 AXPlatformNode* AXPlatformNode::Create(AXPlatformNodeDelegate* delegate) { |
| 27 return nullptr; | 27 return nullptr; |
| 28 } | 28 } |
| 29 #endif // !defined(PLATFORM_HAS_AX_PLATFORM_NODE_IMPL) | |
| 30 | 29 |
| 31 #if !defined(OS_WIN) | |
| 32 // This is the default implementation for platforms where native views | 30 // This is the default implementation for platforms where native views |
| 33 // accessibility is unsupported or unfinished. | 31 // accessibility is unsupported or unfinished. |
| 34 // | 32 // |
| 35 // static | 33 // static |
| 36 AXPlatformNode* AXPlatformNode::FromNativeViewAccessible( | 34 AXPlatformNode* AXPlatformNode::FromNativeViewAccessible( |
| 37 gfx::NativeViewAccessible accessible) { | 35 gfx::NativeViewAccessible accessible) { |
| 38 return nullptr; | 36 return nullptr; |
| 39 } | 37 } |
| 40 #endif | 38 #endif // !defined(PLATFORM_HAS_AX_PLATFORM_NODE_IMPL) |
| 41 | 39 |
| 42 // static | 40 // static |
| 43 int32_t AXPlatformNode::GetNextUniqueId() { | 41 int32_t AXPlatformNode::GetNextUniqueId() { |
| 44 static int32_t next_unique_id = 1; | 42 static int32_t next_unique_id = 1; |
| 45 int32_t unique_id = next_unique_id; | 43 int32_t unique_id = next_unique_id; |
| 46 if (next_unique_id == INT32_MAX) | 44 if (next_unique_id == INT32_MAX) |
| 47 next_unique_id = 1; | 45 next_unique_id = 1; |
| 48 else | 46 else |
| 49 next_unique_id++; | 47 next_unique_id++; |
| 50 | 48 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 68 AXPlatformNode* AXPlatformNode::GetFromUniqueId(int32_t unique_id) { | 66 AXPlatformNode* AXPlatformNode::GetFromUniqueId(int32_t unique_id) { |
| 69 UniqueIdMap* unique_ids = g_unique_id_map.Pointer(); | 67 UniqueIdMap* unique_ids = g_unique_id_map.Pointer(); |
| 70 auto iter = unique_ids->find(unique_id); | 68 auto iter = unique_ids->find(unique_id); |
| 71 if (iter != unique_ids->end()) | 69 if (iter != unique_ids->end()) |
| 72 return iter->second; | 70 return iter->second; |
| 73 | 71 |
| 74 return nullptr; | 72 return nullptr; |
| 75 } | 73 } |
| 76 | 74 |
| 77 } // namespace ui | 75 } // namespace ui |
| OLD | NEW |