| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 return; | 178 return; |
| 179 } | 179 } |
| 180 | 180 |
| 181 // Set focus to the root if it's not anywhere else. | 181 // Set focus to the root if it's not anywhere else. |
| 182 if (!focus_) { | 182 if (!focus_) { |
| 183 SetFocus(tree_->GetRoot(), false); | 183 SetFocus(tree_->GetRoot(), false); |
| 184 should_send_initial_focus = true; | 184 should_send_initial_focus = true; |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 | 187 |
| 188 OnTreeUpdateFinished(); | |
| 189 | |
| 190 if (should_send_initial_focus && | 188 if (should_send_initial_focus && |
| 191 (!delegate_ || delegate_->AccessibilityViewHasFocus())) { | 189 (!delegate_ || delegate_->AccessibilityViewHasFocus())) { |
| 192 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, GetFromAXNode(focus_)); | 190 NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, GetFromAXNode(focus_)); |
| 193 } | 191 } |
| 194 | 192 |
| 195 // Now iterate over the events again and fire the events. | 193 // Now iterate over the events again and fire the events. |
| 196 for (uint32 index = 0; index < params.size(); index++) { | 194 for (uint32 index = 0; index < params.size(); index++) { |
| 197 const AccessibilityHostMsg_EventParams& param = params[index]; | 195 const AccessibilityHostMsg_EventParams& param = params[index]; |
| 198 | 196 |
| 199 // Find the node corresponding to the id that's the target of the | 197 // Find the node corresponding to the id that's the target of the |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 SetFocus(tree_->GetRoot(), false); | 406 SetFocus(tree_->GetRoot(), false); |
| 409 else | 407 else |
| 410 focus_ = NULL; | 408 focus_ = NULL; |
| 411 } | 409 } |
| 412 if (id_wrapper_map_.find(node->id()) == id_wrapper_map_.end()) | 410 if (id_wrapper_map_.find(node->id()) == id_wrapper_map_.end()) |
| 413 return; | 411 return; |
| 414 GetFromAXNode(node)->Destroy(); | 412 GetFromAXNode(node)->Destroy(); |
| 415 id_wrapper_map_.erase(node->id()); | 413 id_wrapper_map_.erase(node->id()); |
| 416 } | 414 } |
| 417 | 415 |
| 416 void BrowserAccessibilityManager::OnSubtreeWillBeDeleted(ui::AXNode* node) { |
| 417 } |
| 418 |
| 418 void BrowserAccessibilityManager::OnNodeCreated(ui::AXNode* node) { | 419 void BrowserAccessibilityManager::OnNodeCreated(ui::AXNode* node) { |
| 419 BrowserAccessibility* wrapper = factory_->Create(); | 420 BrowserAccessibility* wrapper = factory_->Create(); |
| 420 wrapper->Init(this, node); | 421 wrapper->Init(this, node); |
| 421 id_wrapper_map_[node->id()] = wrapper; | 422 id_wrapper_map_[node->id()] = wrapper; |
| 422 wrapper->OnDataChanged(); | 423 wrapper->OnDataChanged(); |
| 423 } | 424 } |
| 424 | 425 |
| 425 void BrowserAccessibilityManager::OnNodeChanged(ui::AXNode* node) { | 426 void BrowserAccessibilityManager::OnNodeChanged(ui::AXNode* node) { |
| 426 GetFromAXNode(node)->OnDataChanged(); | 427 GetFromAXNode(node)->OnDataChanged(); |
| 427 } | 428 } |
| 428 | 429 |
| 429 void BrowserAccessibilityManager::OnNodeCreationFinished(ui::AXNode* node) { | 430 void BrowserAccessibilityManager::OnAtomicUpdateFinished( |
| 430 GetFromAXNode(node)->OnUpdateFinished(); | 431 bool root_changed, const std::vector<ui::AXTreeDelegate::Change>& changes) { |
| 431 } | 432 for (size_t i = 0; i < changes.size(); ++i) |
| 432 | 433 GetFromAXNode(changes[i].node)->OnUpdateFinished(); |
| 433 void BrowserAccessibilityManager::OnNodeChangeFinished(ui::AXNode* node) { | |
| 434 GetFromAXNode(node)->OnUpdateFinished(); | |
| 435 } | 434 } |
| 436 | 435 |
| 437 BrowserAccessibilityDelegate* | 436 BrowserAccessibilityDelegate* |
| 438 BrowserAccessibilityManager::GetDelegateFromRootManager() { | 437 BrowserAccessibilityManager::GetDelegateFromRootManager() { |
| 439 BrowserAccessibilityManager* manager = this; | 438 BrowserAccessibilityManager* manager = this; |
| 440 while (manager->delegate()) { | 439 while (manager->delegate()) { |
| 441 BrowserAccessibility* host_node_in_parent_frame = | 440 BrowserAccessibility* host_node_in_parent_frame = |
| 442 manager->delegate()->AccessibilityGetParentFrame(); | 441 manager->delegate()->AccessibilityGetParentFrame(); |
| 443 if (!host_node_in_parent_frame) | 442 if (!host_node_in_parent_frame) |
| 444 break; | 443 break; |
| 445 manager = host_node_in_parent_frame->manager(); | 444 manager = host_node_in_parent_frame->manager(); |
| 446 } | 445 } |
| 447 return manager->delegate(); | 446 return manager->delegate(); |
| 448 } | 447 } |
| 449 | 448 |
| 450 ui::AXTreeUpdate BrowserAccessibilityManager::SnapshotAXTreeForTesting() { | 449 ui::AXTreeUpdate BrowserAccessibilityManager::SnapshotAXTreeForTesting() { |
| 451 scoped_ptr<ui::AXTreeSource<const ui::AXNode*> > tree_source( | 450 scoped_ptr<ui::AXTreeSource<const ui::AXNode*> > tree_source( |
| 452 tree_->CreateTreeSource()); | 451 tree_->CreateTreeSource()); |
| 453 ui::AXTreeSerializer<const ui::AXNode*> serializer(tree_source.get()); | 452 ui::AXTreeSerializer<const ui::AXNode*> serializer(tree_source.get()); |
| 454 ui::AXTreeUpdate update; | 453 ui::AXTreeUpdate update; |
| 455 serializer.SerializeChanges(tree_->GetRoot(), &update); | 454 serializer.SerializeChanges(tree_->GetRoot(), &update); |
| 456 return update; | 455 return update; |
| 457 } | 456 } |
| 458 | 457 |
| 459 } // namespace content | 458 } // namespace content |
| OLD | NEW |