| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/containers/hash_tables.h" | 5 #include "base/containers/hash_tables.h" |
| 6 #include "ui/accessibility/ax_action_data.h" | 6 #include "ui/accessibility/ax_action_data.h" |
| 7 #include "ui/accessibility/platform/test_ax_node_wrapper.h" | 7 #include "ui/accessibility/platform/test_ax_node_wrapper.h" |
| 8 #include "ui/gfx/geometry/rect_conversions.h" | 8 #include "ui/gfx/geometry/rect_conversions.h" |
| 9 | 9 |
| 10 namespace ui { | 10 namespace ui { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 gfx::NativeViewAccessible TestAXNodeWrapper::HitTestSync(int x, int y) { | 134 gfx::NativeViewAccessible TestAXNodeWrapper::HitTestSync(int x, int y) { |
| 135 TestAXNodeWrapper* wrapper = HitTestSyncInternal(x, y); | 135 TestAXNodeWrapper* wrapper = HitTestSyncInternal(x, y); |
| 136 return wrapper ? wrapper->ax_platform_node()->GetNativeViewAccessible() | 136 return wrapper ? wrapper->ax_platform_node()->GetNativeViewAccessible() |
| 137 : nullptr; | 137 : nullptr; |
| 138 } | 138 } |
| 139 | 139 |
| 140 gfx::NativeViewAccessible TestAXNodeWrapper::GetFocus() { | 140 gfx::NativeViewAccessible TestAXNodeWrapper::GetFocus() { |
| 141 return nullptr; | 141 return nullptr; |
| 142 } | 142 } |
| 143 | 143 |
| 144 // Walk the AXTree and ensure that all wrappers are created |
| 145 void TestAXNodeWrapper::BuildAllWrappers(AXTree* tree, AXNode* node) { |
| 146 for (int i = 0; i < node->child_count(); i++) { |
| 147 auto* child = node->children()[i]; |
| 148 TestAXNodeWrapper::GetOrCreate(tree, child); |
| 149 |
| 150 BuildAllWrappers(tree, child); |
| 151 } |
| 152 } |
| 153 |
| 144 AXPlatformNode* TestAXNodeWrapper::GetFromNodeID(int32_t id) { | 154 AXPlatformNode* TestAXNodeWrapper::GetFromNodeID(int32_t id) { |
| 155 // Force creating all of the wrappers for this tree. |
| 156 BuildAllWrappers(tree_, node_); |
| 157 |
| 158 for (auto it = g_node_to_wrapper_map.begin(); |
| 159 it != g_node_to_wrapper_map.end(); ++it) { |
| 160 AXNode* node = it->first; |
| 161 if (node->id() == id) { |
| 162 TestAXNodeWrapper* wrapper = it->second; |
| 163 return wrapper->ax_platform_node(); |
| 164 } |
| 165 } |
| 145 return nullptr; | 166 return nullptr; |
| 146 } | 167 } |
| 147 | 168 |
| 148 gfx::AcceleratedWidget | 169 gfx::AcceleratedWidget |
| 149 TestAXNodeWrapper::GetTargetForNativeAccessibilityEvent() { | 170 TestAXNodeWrapper::GetTargetForNativeAccessibilityEvent() { |
| 150 return gfx::kNullAcceleratedWidget; | 171 return gfx::kNullAcceleratedWidget; |
| 151 } | 172 } |
| 152 | 173 |
| 153 bool TestAXNodeWrapper::AccessibilityPerformAction( | 174 bool TestAXNodeWrapper::AccessibilityPerformAction( |
| 154 const ui::AXActionData& data) { | 175 const ui::AXActionData& data) { |
| 155 return true; | 176 return true; |
| 156 } | 177 } |
| 157 | 178 |
| 158 bool TestAXNodeWrapper::ShouldIgnoreHoveredStateForTesting() { | 179 bool TestAXNodeWrapper::ShouldIgnoreHoveredStateForTesting() { |
| 159 return true; | 180 return true; |
| 160 } | 181 } |
| 161 | 182 |
| 162 TestAXNodeWrapper::TestAXNodeWrapper(AXTree* tree, AXNode* node) | 183 TestAXNodeWrapper::TestAXNodeWrapper(AXTree* tree, AXNode* node) |
| 163 : tree_(tree), | 184 : tree_(tree), |
| 164 node_(node), | 185 node_(node), |
| 165 platform_node_(AXPlatformNode::Create(this)) { | 186 platform_node_(AXPlatformNode::Create(this)) { |
| 166 } | 187 } |
| 167 | 188 |
| 168 } // namespace ui | 189 } // namespace ui |
| OLD | NEW |