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_win.h" | 5 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/win/scoped_comptr.h" | 8 #include "base/win/scoped_comptr.h" |
9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
10 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 10 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 bool root_changed, | 299 bool root_changed, |
300 const std::vector<ui::AXTreeDelegate::Change>& changes) { | 300 const std::vector<ui::AXTreeDelegate::Change>& changes) { |
301 BrowserAccessibilityManager::OnAtomicUpdateFinished(root_changed, changes); | 301 BrowserAccessibilityManager::OnAtomicUpdateFinished(root_changed, changes); |
302 | 302 |
303 if (root_changed) { | 303 if (root_changed) { |
304 // In order to make screen readers aware of the new accessibility root, | 304 // In order to make screen readers aware of the new accessibility root, |
305 // we need to fire a focus event on it. | 305 // we need to fire a focus event on it. |
306 OnWindowFocused(); | 306 OnWindowFocused(); |
307 } | 307 } |
308 | 308 |
309 // BrowserAccessibilityManager::OnAtomicUpdateFinished calls | 309 // Do a sequence of Windows-specific updates on each node. Each one is |
310 // OnUpdateFinished() on each node in |changes|. However, the | 310 // done in a single pass that must complete before the next step starts. |
311 // IAccessibleText text for a node is a concatenatenation of all of its child | 311 // The first step moves win_attributes_ to old_win_attributes_ and then |
312 // text nodes, so we can't compute a node's IAccessibleText in | 312 // recomputes all of win_attributes_ other than IAccessibleText. |
313 // OnUpdateFinished because its children may not have been updated yet. | |
314 // | |
315 // So we make a second pass here to update IAccessibleText. | |
316 for (size_t i = 0; i < changes.size(); ++i) { | 313 for (size_t i = 0; i < changes.size(); ++i) { |
317 BrowserAccessibility* obj = GetFromAXNode(changes[i].node); | 314 BrowserAccessibility* obj = GetFromAXNode(changes[i].node); |
318 if (obj && obj->IsNative()) | 315 if (obj && obj->IsNative() && !obj->PlatformIsChildOfLeaf()) |
319 obj->ToBrowserAccessibilityWin()->UpdateIAccessibleText(); | 316 obj->ToBrowserAccessibilityWin()->UpdateStep1ComputeWinAttributes(); |
| 317 } |
| 318 |
| 319 // The next step updates the hypertext of each node, which is a |
| 320 // concatenation of all of its child text nodes, so it can't run until |
| 321 // the text of all of the nodes was computed in the previous step. |
| 322 for (size_t i = 0; i < changes.size(); ++i) { |
| 323 BrowserAccessibility* obj = GetFromAXNode(changes[i].node); |
| 324 if (obj && obj->IsNative() && !obj->PlatformIsChildOfLeaf()) |
| 325 obj->ToBrowserAccessibilityWin()->UpdateStep2ComputeHypertext(); |
| 326 } |
| 327 |
| 328 // The third step fires events on nodes based on what's changed - like |
| 329 // if the name, value, or description changed, or if the hypertext had |
| 330 // text inserted or removed. It's able to figure out exactly what changed |
| 331 // because we still have old_win_attributes_ populated. |
| 332 // This step has to run after the previous two steps complete because the |
| 333 // client may walk the tree when it receives any of these events. |
| 334 // At the end, it deletes old_win_attributes_ since they're not needed |
| 335 // anymore. |
| 336 for (size_t i = 0; i < changes.size(); ++i) { |
| 337 BrowserAccessibility* obj = GetFromAXNode(changes[i].node); |
| 338 if (obj && obj->IsNative() && !obj->PlatformIsChildOfLeaf()) { |
| 339 obj->ToBrowserAccessibilityWin()->UpdateStep3FireEvents( |
| 340 changes[i].type == AXTreeDelegate::SUBTREE_CREATED); |
| 341 } |
320 } | 342 } |
321 } | 343 } |
322 | 344 |
323 void BrowserAccessibilityManagerWin::TrackScrollingObject( | 345 void BrowserAccessibilityManagerWin::TrackScrollingObject( |
324 BrowserAccessibilityWin* node) { | 346 BrowserAccessibilityWin* node) { |
325 if (tracked_scroll_object_) | 347 if (tracked_scroll_object_) |
326 tracked_scroll_object_->Release(); | 348 tracked_scroll_object_->Release(); |
327 tracked_scroll_object_ = node; | 349 tracked_scroll_object_ = node; |
328 tracked_scroll_object_->AddRef(); | 350 tracked_scroll_object_->AddRef(); |
329 } | 351 } |
(...skipping 20 matching lines...) Expand all Loading... |
350 child_manager->GetFromUniqueIdWin(unique_id_win); | 372 child_manager->GetFromUniqueIdWin(unique_id_win); |
351 if (result) | 373 if (result) |
352 return result; | 374 return result; |
353 } | 375 } |
354 } | 376 } |
355 | 377 |
356 return NULL; | 378 return NULL; |
357 } | 379 } |
358 | 380 |
359 } // namespace content | 381 } // namespace content |
OLD | NEW |