| 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 "chrome/browser/ui/aura/accessibility/ax_tree_source_aura.h" | 5 #include "chrome/browser/ui/aura/accessibility/ax_tree_source_aura.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 using views::AXAuraObjWrapper; | 24 using views::AXAuraObjWrapper; |
| 25 | 25 |
| 26 AXTreeSourceAura::AXTreeSourceAura() { | 26 AXTreeSourceAura::AXTreeSourceAura() { |
| 27 root_.reset(new AXRootObjWrapper(AXAuraObjCache::GetInstance()->GetNextID())); | 27 root_.reset(new AXRootObjWrapper(AXAuraObjCache::GetInstance()->GetNextID())); |
| 28 } | 28 } |
| 29 | 29 |
| 30 AXTreeSourceAura::~AXTreeSourceAura() { | 30 AXTreeSourceAura::~AXTreeSourceAura() { |
| 31 root_.reset(); | 31 root_.reset(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void AXTreeSourceAura::DoDefault(int32_t id) { | 34 bool AXTreeSourceAura::HandleAccessibleAction(const ui::AXActionData& action) { |
| 35 int id = action.target_node_id; |
| 36 |
| 37 // In Views, we only support setting the selection within a single node, |
| 38 // not across multiple nodes like on the web. |
| 39 if (action.action == ui::AX_ACTION_SET_SELECTION) { |
| 40 if (action.anchor_node_id != action.focus_node_id) { |
| 41 NOTREACHED(); |
| 42 return false; |
| 43 } |
| 44 id = action.anchor_node_id; |
| 45 } |
| 46 |
| 35 AXAuraObjWrapper* obj = AXAuraObjCache::GetInstance()->Get(id); | 47 AXAuraObjWrapper* obj = AXAuraObjCache::GetInstance()->Get(id); |
| 36 if (obj) | 48 if (obj) |
| 37 obj->DoDefault(); | 49 return obj->HandleAccessibleAction(action); |
| 38 } | |
| 39 | 50 |
| 40 void AXTreeSourceAura::Focus(int32_t id) { | |
| 41 AXAuraObjWrapper* obj = AXAuraObjCache::GetInstance()->Get(id); | |
| 42 if (obj) | |
| 43 obj->Focus(); | |
| 44 } | |
| 45 | |
| 46 void AXTreeSourceAura::MakeVisible(int32_t id) { | |
| 47 AXAuraObjWrapper* obj = AXAuraObjCache::GetInstance()->Get(id); | |
| 48 if (obj) | |
| 49 obj->MakeVisible(); | |
| 50 } | |
| 51 | |
| 52 void AXTreeSourceAura::SetSelection(int32_t id, int32_t start, int32_t end) { | |
| 53 AXAuraObjWrapper* obj = AXAuraObjCache::GetInstance()->Get(id); | |
| 54 if (obj) | |
| 55 obj->SetSelection(start, end); | |
| 56 } | |
| 57 | |
| 58 void AXTreeSourceAura::ShowContextMenu(int32_t id) { | |
| 59 AXAuraObjWrapper* obj = AXAuraObjCache::GetInstance()->Get(id); | |
| 60 if (obj) | |
| 61 obj->ShowContextMenu(); | |
| 62 } | |
| 63 | |
| 64 bool AXTreeSourceAura::HandleAccessibleAction(const ui::AXActionData& action) { | |
| 65 AXAuraObjWrapper* obj = | |
| 66 AXAuraObjCache::GetInstance()->Get(action.target_node_id); | |
| 67 if (obj) | |
| 68 return obj->HandleAccessibleAction(action); | |
| 69 return false; | 51 return false; |
| 70 } | 52 } |
| 71 | 53 |
| 72 bool AXTreeSourceAura::GetTreeData(ui::AXTreeData* tree_data) const { | 54 bool AXTreeSourceAura::GetTreeData(ui::AXTreeData* tree_data) const { |
| 73 tree_data->tree_id = 0; | 55 tree_data->tree_id = 0; |
| 74 tree_data->loaded = true; | 56 tree_data->loaded = true; |
| 75 tree_data->loading_progress = 1.0; | 57 tree_data->loading_progress = 1.0; |
| 76 AXAuraObjWrapper* focus = AXAuraObjCache::GetInstance()->GetFocus(); | 58 AXAuraObjWrapper* focus = AXAuraObjCache::GetInstance()->GetFocus(); |
| 77 if (focus) | 59 if (focus) |
| 78 tree_data->focus_id = focus->GetID(); | 60 tree_data->focus_id = focus->GetID(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 128 |
| 147 std::vector<AXAuraObjWrapper*> children; | 129 std::vector<AXAuraObjWrapper*> children; |
| 148 root->GetChildren(&children); | 130 root->GetChildren(&children); |
| 149 | 131 |
| 150 prefix += prefix[0]; | 132 prefix += prefix[0]; |
| 151 for (size_t i = 0; i < children.size(); ++i) | 133 for (size_t i = 0; i < children.size(); ++i) |
| 152 output += ToString(children[i], prefix); | 134 output += ToString(children[i], prefix); |
| 153 | 135 |
| 154 return output; | 136 return output; |
| 155 } | 137 } |
| OLD | NEW |