| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 child_wrapper->ax_platform_node()->GetNativeViewAccessible() : | 104 child_wrapper->ax_platform_node()->GetNativeViewAccessible() : |
| 105 nullptr; | 105 nullptr; |
| 106 } | 106 } |
| 107 | 107 |
| 108 gfx::Rect TestAXNodeWrapper::GetScreenBoundsRect() const { | 108 gfx::Rect TestAXNodeWrapper::GetScreenBoundsRect() const { |
| 109 gfx::RectF bounds = GetData().location; | 109 gfx::RectF bounds = GetData().location; |
| 110 bounds.Offset(g_offset); | 110 bounds.Offset(g_offset); |
| 111 return gfx::ToEnclosingRect(bounds); | 111 return gfx::ToEnclosingRect(bounds); |
| 112 } | 112 } |
| 113 | 113 |
| 114 TestAXNodeWrapper* TestAXNodeWrapper::HitTestSyncInternal(int x, int y) { |
| 115 // Here we find the deepest child whose bounding box contains the given point. |
| 116 // The assuptions are that there are no overlapping bounding rects and that |
| 117 // all children have smaller bounding rects than their parents. |
| 118 if (!GetScreenBoundsRect().Contains(gfx::Rect(x, y))) |
| 119 return nullptr; |
| 120 |
| 121 for (int i = 0; i < GetChildCount(); i++) { |
| 122 TestAXNodeWrapper* child = GetOrCreate(tree_, node_->children()[i]); |
| 123 if (!child) |
| 124 return nullptr; |
| 125 |
| 126 TestAXNodeWrapper* result = child->HitTestSyncInternal(x, y); |
| 127 if (result) { |
| 128 return result; |
| 129 } |
| 130 } |
| 131 return this; |
| 132 } |
| 133 |
| 114 gfx::NativeViewAccessible TestAXNodeWrapper::HitTestSync(int x, int y) { | 134 gfx::NativeViewAccessible TestAXNodeWrapper::HitTestSync(int x, int y) { |
| 115 return nullptr; | 135 TestAXNodeWrapper* wrapper = HitTestSyncInternal(x, y); |
| 136 return wrapper ? wrapper->ax_platform_node()->GetNativeViewAccessible() |
| 137 : nullptr; |
| 116 } | 138 } |
| 117 | 139 |
| 118 gfx::NativeViewAccessible TestAXNodeWrapper::GetFocus() { | 140 gfx::NativeViewAccessible TestAXNodeWrapper::GetFocus() { |
| 119 return nullptr; | 141 return nullptr; |
| 120 } | 142 } |
| 121 | 143 |
| 122 gfx::AcceleratedWidget | 144 gfx::AcceleratedWidget |
| 123 TestAXNodeWrapper::GetTargetForNativeAccessibilityEvent() { | 145 TestAXNodeWrapper::GetTargetForNativeAccessibilityEvent() { |
| 124 return gfx::kNullAcceleratedWidget; | 146 return gfx::kNullAcceleratedWidget; |
| 125 } | 147 } |
| 126 | 148 |
| 127 bool TestAXNodeWrapper::AccessibilityPerformAction( | 149 bool TestAXNodeWrapper::AccessibilityPerformAction( |
| 128 const ui::AXActionData& data) { | 150 const ui::AXActionData& data) { |
| 129 return true; | 151 return true; |
| 130 } | 152 } |
| 131 | 153 |
| 132 TestAXNodeWrapper::TestAXNodeWrapper(AXTree* tree, AXNode* node) | 154 TestAXNodeWrapper::TestAXNodeWrapper(AXTree* tree, AXNode* node) |
| 133 : tree_(tree), | 155 : tree_(tree), |
| 134 node_(node), | 156 node_(node), |
| 135 platform_node_(AXPlatformNode::Create(this)) { | 157 platform_node_(AXPlatformNode::Create(this)) { |
| 136 } | 158 } |
| 137 | 159 |
| 138 } // namespace ui | 160 } // namespace ui |
| OLD | NEW |