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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // If we can't find the node to replace, we're out of sync with the | 233 // If we can't find the node to replace, we're out of sync with the |
234 // renderer (this would be a bug). | 234 // renderer (this would be a bug). |
235 DCHECK(current); | 235 DCHECK(current); |
236 if (!current) | 236 if (!current) |
237 return; | 237 return; |
238 | 238 |
239 // If this update is just for a single node (|include_children| is false), | 239 // If this update is just for a single node (|include_children| is false), |
240 // modify |current| directly and return - no tree changes are needed. | 240 // modify |current| directly and return - no tree changes are needed. |
241 if (!include_children) { | 241 if (!include_children) { |
242 DCHECK_EQ(0U, src.children.size()); | 242 DCHECK_EQ(0U, src.children.size()); |
243 current->Initialize( | 243 current->PreInitialize( |
244 this, | 244 this, |
245 current->parent(), | 245 current->parent(), |
246 current->child_id(), | 246 current->child_id(), |
247 current->index_in_parent(), | 247 current->index_in_parent(), |
248 src); | 248 src); |
249 current->SendNodeUpdateEvents(); | 249 current->PostInitialize(); |
250 return; | 250 return; |
251 } | 251 } |
252 | 252 |
253 BrowserAccessibility* current_parent = current->parent(); | 253 BrowserAccessibility* current_parent = current->parent(); |
254 int current_index_in_parent = current->index_in_parent(); | 254 int current_index_in_parent = current->index_in_parent(); |
255 | 255 |
256 // Detach all of the nodes in the old tree and get a single flat vector | 256 // Detach all of the nodes in the old tree and get a single flat vector |
257 // of all node pointers. | 257 // of all node pointers. |
258 std::vector<BrowserAccessibility*> old_tree_nodes; | 258 std::vector<BrowserAccessibility*> old_tree_nodes; |
259 current->DetachTree(&old_tree_nodes); | 259 current->DetachTree(&old_tree_nodes); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 instance->UpdateParent(parent, index_in_parent); | 314 instance->UpdateParent(parent, index_in_parent); |
315 instance->InternalAddReference(); | 315 instance->InternalAddReference(); |
316 send_show_events = false; | 316 send_show_events = false; |
317 } else { | 317 } else { |
318 // Otherwise, create a new instance. | 318 // Otherwise, create a new instance. |
319 instance = factory_->Create(); | 319 instance = factory_->Create(); |
320 child_id = GetNextChildID(); | 320 child_id = GetNextChildID(); |
321 children_can_send_show_events = false; | 321 children_can_send_show_events = false; |
322 } | 322 } |
323 | 323 |
324 instance->Initialize(this, parent, child_id, index_in_parent, src); | 324 instance->PreInitialize(this, parent, child_id, index_in_parent, src); |
| 325 for (int i = 0; i < static_cast<int>(src.children.size()); ++i) { |
| 326 BrowserAccessibility* child = CreateAccessibilityTree( |
| 327 instance, src.children[i], i, children_can_send_show_events); |
| 328 instance->AddChild(child); |
| 329 } |
| 330 |
325 child_id_map_[child_id] = instance; | 331 child_id_map_[child_id] = instance; |
326 renderer_id_to_child_id_map_[src.id] = child_id; | 332 renderer_id_to_child_id_map_[src.id] = child_id; |
327 | 333 |
328 if (src.role == WebAccessibility::ROLE_ROOT_WEB_AREA) | 334 if (src.role == WebAccessibility::ROLE_ROOT_WEB_AREA) |
329 root_ = instance; | 335 root_ = instance; |
330 | 336 |
331 if ((src.state >> WebAccessibility::STATE_FOCUSED) & 1) | 337 if ((src.state >> WebAccessibility::STATE_FOCUSED) & 1) |
332 SetFocus(instance, false); | 338 SetFocus(instance, false); |
333 for (int i = 0; i < static_cast<int>(src.children.size()); ++i) { | |
334 BrowserAccessibility* child = CreateAccessibilityTree( | |
335 instance, src.children[i], i, children_can_send_show_events); | |
336 instance->AddChild(child); | |
337 } | |
338 | 339 |
339 // Note: the purpose of send_show_events and children_can_send_show_events | 340 // Note: the purpose of send_show_events and children_can_send_show_events |
340 // is so that we send a single OBJECT_SHOW event for the root of a subtree | 341 // is so that we send a single OBJECT_SHOW event for the root of a subtree |
341 // that just appeared for the first time, but not on any descendant of | 342 // that just appeared for the first time, but not on any descendant of |
342 // that subtree. | 343 // that subtree. |
343 if (send_show_events) | 344 if (send_show_events) |
344 NotifyAccessibilityEvent(ViewHostMsg_AccEvent::OBJECT_SHOW, instance); | 345 NotifyAccessibilityEvent(ViewHostMsg_AccEvent::OBJECT_SHOW, instance); |
345 | 346 |
346 instance->SendNodeUpdateEvents(); | 347 instance->PostInitialize(); |
347 | 348 |
348 return instance; | 349 return instance; |
349 } | 350 } |
OLD | NEW |