| 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 SetFocus(tree_->GetRoot(), false); | 391 SetFocus(tree_->GetRoot(), false); |
| 394 else | 392 else |
| 395 focus_ = NULL; | 393 focus_ = NULL; |
| 396 } | 394 } |
| 397 if (id_wrapper_map_.find(node->id()) == id_wrapper_map_.end()) | 395 if (id_wrapper_map_.find(node->id()) == id_wrapper_map_.end()) |
| 398 return; | 396 return; |
| 399 GetFromAXNode(node)->Destroy(); | 397 GetFromAXNode(node)->Destroy(); |
| 400 id_wrapper_map_.erase(node->id()); | 398 id_wrapper_map_.erase(node->id()); |
| 401 } | 399 } |
| 402 | 400 |
| 401 void BrowserAccessibilityManager::OnSubtreeWillBeDeleted(ui::AXNode* node) { |
| 402 } |
| 403 |
| 403 void BrowserAccessibilityManager::OnNodeCreated(ui::AXNode* node) { | 404 void BrowserAccessibilityManager::OnNodeCreated(ui::AXNode* node) { |
| 404 BrowserAccessibility* wrapper = factory_->Create(); | 405 BrowserAccessibility* wrapper = factory_->Create(); |
| 405 wrapper->Init(this, node); | 406 wrapper->Init(this, node); |
| 406 id_wrapper_map_[node->id()] = wrapper; | 407 id_wrapper_map_[node->id()] = wrapper; |
| 407 wrapper->OnDataChanged(); | 408 wrapper->OnDataChanged(); |
| 408 } | 409 } |
| 409 | 410 |
| 410 void BrowserAccessibilityManager::OnNodeChanged(ui::AXNode* node) { | 411 void BrowserAccessibilityManager::OnNodeChanged(ui::AXNode* node) { |
| 411 GetFromAXNode(node)->OnDataChanged(); | 412 GetFromAXNode(node)->OnDataChanged(); |
| 412 } | 413 } |
| 413 | 414 |
| 414 void BrowserAccessibilityManager::OnNodeCreationFinished(ui::AXNode* node) { | 415 void BrowserAccessibilityManager::OnAtomicUpdateFinished( |
| 415 GetFromAXNode(node)->OnUpdateFinished(); | 416 bool root_changed, const std::vector<ui::AXTreeDelegate::Change>& changes) { |
| 416 } | 417 for (size_t i = 0; i < changes.size(); ++i) |
| 417 | 418 GetFromAXNode(changes[i].node)->OnUpdateFinished(); |
| 418 void BrowserAccessibilityManager::OnNodeChangeFinished(ui::AXNode* node) { | |
| 419 GetFromAXNode(node)->OnUpdateFinished(); | |
| 420 } | 419 } |
| 421 | 420 |
| 422 ui::AXTreeUpdate BrowserAccessibilityManager::SnapshotAXTreeForTesting() { | 421 ui::AXTreeUpdate BrowserAccessibilityManager::SnapshotAXTreeForTesting() { |
| 423 scoped_ptr<ui::AXTreeSource<const ui::AXNode*> > tree_source( | 422 scoped_ptr<ui::AXTreeSource<const ui::AXNode*> > tree_source( |
| 424 tree_->CreateTreeSource()); | 423 tree_->CreateTreeSource()); |
| 425 ui::AXTreeSerializer<const ui::AXNode*> serializer(tree_source.get()); | 424 ui::AXTreeSerializer<const ui::AXNode*> serializer(tree_source.get()); |
| 426 ui::AXTreeUpdate update; | 425 ui::AXTreeUpdate update; |
| 427 serializer.SerializeChanges(tree_->GetRoot(), &update); | 426 serializer.SerializeChanges(tree_->GetRoot(), &update); |
| 428 return update; | 427 return update; |
| 429 } | 428 } |
| 430 | 429 |
| 431 } // namespace content | 430 } // namespace content |
| OLD | NEW |