OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/accessibility/browser_accessibility_manager.h" | 5 #include "content/browser/accessibility/browser_accessibility_manager.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 |
7 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "build/build_config.h" |
8 #include "content/browser/accessibility/browser_accessibility.h" | 11 #include "content/browser/accessibility/browser_accessibility.h" |
9 #include "content/common/accessibility_messages.h" | 12 #include "content/common/accessibility_messages.h" |
10 #include "ui/accessibility/ax_tree_serializer.h" | 13 #include "ui/accessibility/ax_tree_serializer.h" |
11 | 14 |
12 namespace content { | 15 namespace content { |
13 | 16 |
14 namespace { | 17 namespace { |
15 | 18 |
16 // Search the tree recursively from |node| and return any node that has | 19 // Search the tree recursively from |node| and return any node that has |
17 // a child tree ID of |ax_tree_id|. | 20 // a child tree ID of |ax_tree_id|. |
(...skipping 29 matching lines...) Expand all Loading... |
47 const ui::AXNodeData& node4 /* = ui::AXNodeData() */, | 50 const ui::AXNodeData& node4 /* = ui::AXNodeData() */, |
48 const ui::AXNodeData& node5 /* = ui::AXNodeData() */, | 51 const ui::AXNodeData& node5 /* = ui::AXNodeData() */, |
49 const ui::AXNodeData& node6 /* = ui::AXNodeData() */, | 52 const ui::AXNodeData& node6 /* = ui::AXNodeData() */, |
50 const ui::AXNodeData& node7 /* = ui::AXNodeData() */, | 53 const ui::AXNodeData& node7 /* = ui::AXNodeData() */, |
51 const ui::AXNodeData& node8 /* = ui::AXNodeData() */, | 54 const ui::AXNodeData& node8 /* = ui::AXNodeData() */, |
52 const ui::AXNodeData& node9 /* = ui::AXNodeData() */, | 55 const ui::AXNodeData& node9 /* = ui::AXNodeData() */, |
53 const ui::AXNodeData& node10 /* = ui::AXNodeData() */, | 56 const ui::AXNodeData& node10 /* = ui::AXNodeData() */, |
54 const ui::AXNodeData& node11 /* = ui::AXNodeData() */, | 57 const ui::AXNodeData& node11 /* = ui::AXNodeData() */, |
55 const ui::AXNodeData& node12 /* = ui::AXNodeData() */) { | 58 const ui::AXNodeData& node12 /* = ui::AXNodeData() */) { |
56 CR_DEFINE_STATIC_LOCAL(ui::AXNodeData, empty_data, ()); | 59 CR_DEFINE_STATIC_LOCAL(ui::AXNodeData, empty_data, ()); |
57 int32 no_id = empty_data.id; | 60 int32_t no_id = empty_data.id; |
58 | 61 |
59 ui::AXTreeUpdate update; | 62 ui::AXTreeUpdate update; |
60 update.nodes.push_back(node1); | 63 update.nodes.push_back(node1); |
61 if (node2.id != no_id) | 64 if (node2.id != no_id) |
62 update.nodes.push_back(node2); | 65 update.nodes.push_back(node2); |
63 if (node3.id != no_id) | 66 if (node3.id != no_id) |
64 update.nodes.push_back(node3); | 67 update.nodes.push_back(node3); |
65 if (node4.id != no_id) | 68 if (node4.id != no_id) |
66 update.nodes.push_back(node4); | 69 update.nodes.push_back(node4); |
67 if (node5.id != no_id) | 70 if (node5.id != no_id) |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 return root ? GetFromAXNode(root) : nullptr; | 193 return root ? GetFromAXNode(root) : nullptr; |
191 } | 194 } |
192 | 195 |
193 BrowserAccessibility* BrowserAccessibilityManager::GetFromAXNode( | 196 BrowserAccessibility* BrowserAccessibilityManager::GetFromAXNode( |
194 const ui::AXNode* node) const { | 197 const ui::AXNode* node) const { |
195 if (!node) | 198 if (!node) |
196 return nullptr; | 199 return nullptr; |
197 return GetFromID(node->id()); | 200 return GetFromID(node->id()); |
198 } | 201 } |
199 | 202 |
200 BrowserAccessibility* BrowserAccessibilityManager::GetFromID(int32 id) const { | 203 BrowserAccessibility* BrowserAccessibilityManager::GetFromID(int32_t id) const { |
201 const auto iter = id_wrapper_map_.find(id); | 204 const auto iter = id_wrapper_map_.find(id); |
202 if (iter != id_wrapper_map_.end()) | 205 if (iter != id_wrapper_map_.end()) |
203 return iter->second; | 206 return iter->second; |
204 | 207 |
205 return nullptr; | 208 return nullptr; |
206 } | 209 } |
207 | 210 |
208 BrowserAccessibility* | 211 BrowserAccessibility* |
209 BrowserAccessibilityManager::GetParentNodeFromParentTree() { | 212 BrowserAccessibilityManager::GetParentNodeFromParentTree() { |
210 if (!GetRoot()) | 213 if (!GetRoot()) |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 283 |
281 bool BrowserAccessibilityManager::UseRootScrollOffsetsWhenComputingBounds() { | 284 bool BrowserAccessibilityManager::UseRootScrollOffsetsWhenComputingBounds() { |
282 return true; | 285 return true; |
283 } | 286 } |
284 | 287 |
285 void BrowserAccessibilityManager::OnAccessibilityEvents( | 288 void BrowserAccessibilityManager::OnAccessibilityEvents( |
286 const std::vector<AXEventNotificationDetails>& details) { | 289 const std::vector<AXEventNotificationDetails>& details) { |
287 bool should_send_initial_focus = false; | 290 bool should_send_initial_focus = false; |
288 | 291 |
289 // Process all changes to the accessibility tree first. | 292 // Process all changes to the accessibility tree first. |
290 for (uint32 index = 0; index < details.size(); ++index) { | 293 for (uint32_t index = 0; index < details.size(); ++index) { |
291 const AXEventNotificationDetails& detail = details[index]; | 294 const AXEventNotificationDetails& detail = details[index]; |
292 if (!tree_->Unserialize(detail.update)) { | 295 if (!tree_->Unserialize(detail.update)) { |
293 if (delegate_) { | 296 if (delegate_) { |
294 LOG(ERROR) << tree_->error(); | 297 LOG(ERROR) << tree_->error(); |
295 delegate_->AccessibilityFatalError(); | 298 delegate_->AccessibilityFatalError(); |
296 } else { | 299 } else { |
297 CHECK(false) << tree_->error(); | 300 CHECK(false) << tree_->error(); |
298 } | 301 } |
299 return; | 302 return; |
300 } | 303 } |
301 | 304 |
302 // Set focus to the root if it's not anywhere else. | 305 // Set focus to the root if it's not anywhere else. |
303 if (!focus_) { | 306 if (!focus_) { |
304 SetFocus(tree_->root(), false); | 307 SetFocus(tree_->root(), false); |
305 should_send_initial_focus = true; | 308 should_send_initial_focus = true; |
306 } | 309 } |
307 } | 310 } |
308 | 311 |
309 if (should_send_initial_focus && NativeViewHasFocus()) | 312 if (should_send_initial_focus && NativeViewHasFocus()) |
310 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, GetFromAXNode(focus_)); | 313 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, GetFromAXNode(focus_)); |
311 | 314 |
312 // Now iterate over the events again and fire the events. | 315 // Now iterate over the events again and fire the events. |
313 for (uint32 index = 0; index < details.size(); index++) { | 316 for (uint32_t index = 0; index < details.size(); index++) { |
314 const AXEventNotificationDetails& detail = details[index]; | 317 const AXEventNotificationDetails& detail = details[index]; |
315 | 318 |
316 // Find the node corresponding to the id that's the target of the | 319 // Find the node corresponding to the id that's the target of the |
317 // event (which may not be the root of the update tree). | 320 // event (which may not be the root of the update tree). |
318 ui::AXNode* node = tree_->GetFromId(detail.id); | 321 ui::AXNode* node = tree_->GetFromId(detail.id); |
319 if (!node) | 322 if (!node) |
320 continue; | 323 continue; |
321 | 324 |
322 ui::AXEvent event_type = detail.event_type; | 325 ui::AXEvent event_type = detail.event_type; |
323 if (event_type == ui::AX_EVENT_FOCUS || | 326 if (event_type == ui::AX_EVENT_FOCUS || |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 tree_->CreateTreeSource()); | 635 tree_->CreateTreeSource()); |
633 ui::AXTreeSerializer<const ui::AXNode*, | 636 ui::AXTreeSerializer<const ui::AXNode*, |
634 ui::AXNodeData, | 637 ui::AXNodeData, |
635 ui::AXTreeData> serializer(tree_source.get()); | 638 ui::AXTreeData> serializer(tree_source.get()); |
636 ui::AXTreeUpdate update; | 639 ui::AXTreeUpdate update; |
637 serializer.SerializeChanges(tree_->root(), &update); | 640 serializer.SerializeChanges(tree_->root(), &update); |
638 return update; | 641 return update; |
639 } | 642 } |
640 | 643 |
641 } // namespace content | 644 } // namespace content |
OLD | NEW |