| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "content/browser/accessibility/browser_accessibility.h" | 8 #include "content/browser/accessibility/browser_accessibility.h" |
| 9 #include "content/common/accessibility_messages.h" | 9 #include "content/common/accessibility_messages.h" |
| 10 #include "ui/accessibility/ax_tree_serializer.h" | 10 #include "ui/accessibility/ax_tree_serializer.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 if (!tree_->Unserialize(initial_tree)) { | 107 if (!tree_->Unserialize(initial_tree)) { |
| 108 if (delegate_) { | 108 if (delegate_) { |
| 109 LOG(ERROR) << tree_->error(); | 109 LOG(ERROR) << tree_->error(); |
| 110 delegate_->AccessibilityFatalError(); | 110 delegate_->AccessibilityFatalError(); |
| 111 } else { | 111 } else { |
| 112 LOG(FATAL) << tree_->error(); | 112 LOG(FATAL) << tree_->error(); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 if (!focus_) | 116 if (!focus_) |
| 117 SetFocus(tree_->GetRoot(), false); | 117 SetFocus(tree_->root(), false); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // static | 120 // static |
| 121 ui::AXTreeUpdate BrowserAccessibilityManager::GetEmptyDocument() { | 121 ui::AXTreeUpdate BrowserAccessibilityManager::GetEmptyDocument() { |
| 122 ui::AXNodeData empty_document; | 122 ui::AXNodeData empty_document; |
| 123 empty_document.id = 0; | 123 empty_document.id = 0; |
| 124 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; | 124 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; |
| 125 ui::AXTreeUpdate update; | 125 ui::AXTreeUpdate update; |
| 126 update.nodes.push_back(empty_document); | 126 update.nodes.push_back(empty_document); |
| 127 return update; | 127 return update; |
| 128 } | 128 } |
| 129 | 129 |
| 130 BrowserAccessibility* BrowserAccessibilityManager::GetRoot() { | 130 BrowserAccessibility* BrowserAccessibilityManager::GetRoot() { |
| 131 return GetFromAXNode(tree_->GetRoot()); | 131 return GetFromAXNode(tree_->root()); |
| 132 } | 132 } |
| 133 | 133 |
| 134 BrowserAccessibility* BrowserAccessibilityManager::GetFromAXNode( | 134 BrowserAccessibility* BrowserAccessibilityManager::GetFromAXNode( |
| 135 ui::AXNode* node) { | 135 ui::AXNode* node) { |
| 136 return GetFromID(node->id()); | 136 return GetFromID(node->id()); |
| 137 } | 137 } |
| 138 | 138 |
| 139 BrowserAccessibility* BrowserAccessibilityManager::GetFromID(int32 id) { | 139 BrowserAccessibility* BrowserAccessibilityManager::GetFromID(int32 id) { |
| 140 base::hash_map<int32, BrowserAccessibility*>::iterator iter = | 140 base::hash_map<int32, BrowserAccessibility*>::iterator iter = |
| 141 id_wrapper_map_.find(id); | 141 id_wrapper_map_.find(id); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 LOG(ERROR) << tree_->error(); | 191 LOG(ERROR) << tree_->error(); |
| 192 delegate_->AccessibilityFatalError(); | 192 delegate_->AccessibilityFatalError(); |
| 193 } else { | 193 } else { |
| 194 CHECK(false) << tree_->error(); | 194 CHECK(false) << tree_->error(); |
| 195 } | 195 } |
| 196 return; | 196 return; |
| 197 } | 197 } |
| 198 | 198 |
| 199 // Set focus to the root if it's not anywhere else. | 199 // Set focus to the root if it's not anywhere else. |
| 200 if (!focus_) { | 200 if (!focus_) { |
| 201 SetFocus(tree_->GetRoot(), false); | 201 SetFocus(tree_->root(), false); |
| 202 should_send_initial_focus = true; | 202 should_send_initial_focus = true; |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 if (should_send_initial_focus && | 206 if (should_send_initial_focus && |
| 207 (!delegate_ || delegate_->AccessibilityViewHasFocus())) { | 207 (!delegate_ || delegate_->AccessibilityViewHasFocus())) { |
| 208 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, GetFromAXNode(focus_)); | 208 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, GetFromAXNode(focus_)); |
| 209 } | 209 } |
| 210 | 210 |
| 211 // Now iterate over the events again and fire the events. | 211 // Now iterate over the events again and fire the events. |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 while (node->PlatformChildCount() > 0) | 413 while (node->PlatformChildCount() > 0) |
| 414 node = node->PlatformGetChild(node->PlatformChildCount() - 1); | 414 node = node->PlatformGetChild(node->PlatformChildCount() - 1); |
| 415 return node; | 415 return node; |
| 416 } | 416 } |
| 417 | 417 |
| 418 return node->GetParent(); | 418 return node->GetParent(); |
| 419 } | 419 } |
| 420 | 420 |
| 421 void BrowserAccessibilityManager::OnNodeWillBeDeleted(ui::AXNode* node) { | 421 void BrowserAccessibilityManager::OnNodeWillBeDeleted(ui::AXNode* node) { |
| 422 if (node == focus_ && tree_) { | 422 if (node == focus_ && tree_) { |
| 423 if (node != tree_->GetRoot()) | 423 if (node != tree_->root()) |
| 424 SetFocus(tree_->GetRoot(), false); | 424 SetFocus(tree_->root(), false); |
| 425 else | 425 else |
| 426 focus_ = NULL; | 426 focus_ = NULL; |
| 427 } | 427 } |
| 428 if (id_wrapper_map_.find(node->id()) == id_wrapper_map_.end()) | 428 if (id_wrapper_map_.find(node->id()) == id_wrapper_map_.end()) |
| 429 return; | 429 return; |
| 430 GetFromAXNode(node)->Destroy(); | 430 GetFromAXNode(node)->Destroy(); |
| 431 id_wrapper_map_.erase(node->id()); | 431 id_wrapper_map_.erase(node->id()); |
| 432 } | 432 } |
| 433 | 433 |
| 434 void BrowserAccessibilityManager::OnSubtreeWillBeDeleted(ui::AXNode* node) { | 434 void BrowserAccessibilityManager::OnSubtreeWillBeDeleted(ui::AXNode* node) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 464 manager = host_node_in_parent_frame->manager(); | 464 manager = host_node_in_parent_frame->manager(); |
| 465 } | 465 } |
| 466 return manager->delegate(); | 466 return manager->delegate(); |
| 467 } | 467 } |
| 468 | 468 |
| 469 ui::AXTreeUpdate BrowserAccessibilityManager::SnapshotAXTreeForTesting() { | 469 ui::AXTreeUpdate BrowserAccessibilityManager::SnapshotAXTreeForTesting() { |
| 470 scoped_ptr<ui::AXTreeSource<const ui::AXNode*> > tree_source( | 470 scoped_ptr<ui::AXTreeSource<const ui::AXNode*> > tree_source( |
| 471 tree_->CreateTreeSource()); | 471 tree_->CreateTreeSource()); |
| 472 ui::AXTreeSerializer<const ui::AXNode*> serializer(tree_source.get()); | 472 ui::AXTreeSerializer<const ui::AXNode*> serializer(tree_source.get()); |
| 473 ui::AXTreeUpdate update; | 473 ui::AXTreeUpdate update; |
| 474 serializer.SerializeChanges(tree_->GetRoot(), &update); | 474 serializer.SerializeChanges(tree_->root(), &update); |
| 475 return update; | 475 return update; |
| 476 } | 476 } |
| 477 | 477 |
| 478 } // namespace content | 478 } // namespace content |
| OLD | NEW |