| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/view_messages.h" | 9 #include "content/common/view_messages.h" |
| 10 | 10 |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 // If we can't find the node to replace, we're out of sync with the | 249 // If we can't find the node to replace, we're out of sync with the |
| 250 // renderer (this would be a bug). | 250 // renderer (this would be a bug). |
| 251 DCHECK(current); | 251 DCHECK(current); |
| 252 if (!current) | 252 if (!current) |
| 253 return; | 253 return; |
| 254 | 254 |
| 255 // If this update is just for a single node (|include_children| is false), | 255 // If this update is just for a single node (|include_children| is false), |
| 256 // modify |current| directly and return - no tree changes are needed. | 256 // modify |current| directly and return - no tree changes are needed. |
| 257 if (!include_children) { | 257 if (!include_children) { |
| 258 DCHECK_EQ(0U, src.children.size()); | 258 DCHECK_EQ(0U, src.children.size()); |
| 259 current->Initialize( | 259 current->PreInitialize( |
| 260 this, | 260 this, |
| 261 current->parent(), | 261 current->parent(), |
| 262 current->child_id(), | 262 current->child_id(), |
| 263 current->index_in_parent(), | 263 current->index_in_parent(), |
| 264 src); | 264 src); |
| 265 current->SendNodeUpdateEvents(); | 265 current->PostInitialize(); |
| 266 return; | 266 return; |
| 267 } | 267 } |
| 268 | 268 |
| 269 BrowserAccessibility* current_parent = current->parent(); | 269 BrowserAccessibility* current_parent = current->parent(); |
| 270 int current_index_in_parent = current->index_in_parent(); | 270 int current_index_in_parent = current->index_in_parent(); |
| 271 | 271 |
| 272 // Detach all of the nodes in the old tree and get a single flat vector | 272 // Detach all of the nodes in the old tree and get a single flat vector |
| 273 // of all node pointers. | 273 // of all node pointers. |
| 274 std::vector<BrowserAccessibility*> old_tree_nodes; | 274 std::vector<BrowserAccessibility*> old_tree_nodes; |
| 275 current->DetachTree(&old_tree_nodes); | 275 current->DetachTree(&old_tree_nodes); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 instance->UpdateParent(parent, index_in_parent); | 330 instance->UpdateParent(parent, index_in_parent); |
| 331 instance->InternalAddReference(); | 331 instance->InternalAddReference(); |
| 332 send_show_events = false; | 332 send_show_events = false; |
| 333 } else { | 333 } else { |
| 334 // Otherwise, create a new instance. | 334 // Otherwise, create a new instance. |
| 335 instance = factory_->Create(); | 335 instance = factory_->Create(); |
| 336 child_id = GetNextChildID(); | 336 child_id = GetNextChildID(); |
| 337 children_can_send_show_events = false; | 337 children_can_send_show_events = false; |
| 338 } | 338 } |
| 339 | 339 |
| 340 instance->Initialize(this, parent, child_id, index_in_parent, src); | 340 instance->PreInitialize(this, parent, child_id, index_in_parent, src); |
| 341 for (int i = 0; i < static_cast<int>(src.children.size()); ++i) { |
| 342 BrowserAccessibility* child = CreateAccessibilityTree( |
| 343 instance, src.children[i], i, children_can_send_show_events); |
| 344 instance->AddChild(child); |
| 345 } |
| 346 |
| 341 child_id_map_[child_id] = instance; | 347 child_id_map_[child_id] = instance; |
| 342 renderer_id_to_child_id_map_[src.id] = child_id; | 348 renderer_id_to_child_id_map_[src.id] = child_id; |
| 343 | 349 |
| 344 if (src.role == WebAccessibility::ROLE_ROOT_WEB_AREA) | 350 if (src.role == WebAccessibility::ROLE_ROOT_WEB_AREA) |
| 345 root_ = instance; | 351 root_ = instance; |
| 346 | 352 |
| 347 if ((src.state >> WebAccessibility::STATE_FOCUSED) & 1) | 353 if ((src.state >> WebAccessibility::STATE_FOCUSED) & 1) |
| 348 SetFocus(instance, false); | 354 SetFocus(instance, false); |
| 349 for (int i = 0; i < static_cast<int>(src.children.size()); ++i) { | |
| 350 BrowserAccessibility* child = CreateAccessibilityTree( | |
| 351 instance, src.children[i], i, children_can_send_show_events); | |
| 352 instance->AddChild(child); | |
| 353 } | |
| 354 | 355 |
| 355 // Note: the purpose of send_show_events and children_can_send_show_events | 356 // Note: the purpose of send_show_events and children_can_send_show_events |
| 356 // is so that we send a single OBJECT_SHOW event for the root of a subtree | 357 // is so that we send a single OBJECT_SHOW event for the root of a subtree |
| 357 // that just appeared for the first time, but not on any descendant of | 358 // that just appeared for the first time, but not on any descendant of |
| 358 // that subtree. | 359 // that subtree. |
| 359 if (send_show_events) | 360 if (send_show_events) |
| 360 NotifyAccessibilityEvent(ViewHostMsg_AccEvent::OBJECT_SHOW, instance); | 361 NotifyAccessibilityEvent(ViewHostMsg_AccEvent::OBJECT_SHOW, instance); |
| 361 | 362 |
| 362 instance->SendNodeUpdateEvents(); | 363 instance->PostInitialize(); |
| 363 | 364 |
| 364 return instance; | 365 return instance; |
| 365 } | 366 } |
| OLD | NEW |