Chromium Code Reviews| 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 bool root_changed, | 290 bool root_changed, |
| 291 const std::vector<ui::AXTreeDelegate::Change>& changes) { | 291 const std::vector<ui::AXTreeDelegate::Change>& changes) { |
| 292 BrowserAccessibilityManager::OnAtomicUpdateFinished(root_changed, changes); | 292 BrowserAccessibilityManager::OnAtomicUpdateFinished(root_changed, changes); |
| 293 | 293 |
| 294 if (root_changed) { | 294 if (root_changed) { |
| 295 // In order to make screen readers aware of the new accessibility root, | 295 // In order to make screen readers aware of the new accessibility root, |
| 296 // we need to fire a focus event on it. | 296 // we need to fire a focus event on it. |
| 297 OnWindowFocused(); | 297 OnWindowFocused(); |
| 298 } | 298 } |
| 299 | 299 |
| 300 // BrowserAccessibilityManager::OnAtomicUpdateFinished calls | 300 // Do a sequence of Windows-specific updates on each node. Each one is |
| 301 // OnUpdateFinished() on each node in |changes|. However, the | 301 // done in a single pass that must complete before the next step starts. |
| 302 // IAccessibleText text for a node is a concatenatenation of all of its child | 302 // The first step moves win_attributes_ to old_win_attributes_ and then |
| 303 // text nodes, so we can't compute a node's IAccessibleText in | 303 // recomputes all of win_attributes_ other than IAccessibleText. |
| 304 // OnUpdateFinished because its children may not have been updated yet. | |
| 305 // | |
| 306 // So we make a second pass here to update IAccessibleText. | |
| 307 for (size_t i = 0; i < changes.size(); ++i) { | 304 for (size_t i = 0; i < changes.size(); ++i) { |
| 308 BrowserAccessibility* obj = GetFromAXNode(changes[i].node); | 305 BrowserAccessibility* obj = GetFromAXNode(changes[i].node); |
| 309 if (obj && obj->IsNative()) | 306 if (obj && obj->IsNative() && !obj->PlatformIsChildOfLeaf()) |
| 310 obj->ToBrowserAccessibilityWin()->UpdateIAccessibleText(); | 307 obj->ToBrowserAccessibilityWin()->UpdateStep1ComputeWinAttributes(); |
| 308 } | |
| 309 | |
| 310 // The next step updates the hypertext of each node, which is a | |
| 311 // concatenatenation of all of its child text nodes, so it can't run until | |
|
David Tseng
2015/01/30 23:57:25
nit: contatenation
dmazzoni
2015/01/31 07:45:21
Done.
| |
| 312 // the text of all of the nodes was computed in the previous step. | |
| 313 for (size_t i = 0; i < changes.size(); ++i) { | |
| 314 BrowserAccessibility* obj = GetFromAXNode(changes[i].node); | |
| 315 if (obj && obj->IsNative() && !obj->PlatformIsChildOfLeaf()) | |
| 316 obj->ToBrowserAccessibilityWin()->UpdateStep2ComputeHypertext(); | |
| 317 } | |
| 318 | |
| 319 // The third step fires events on nodes based on what's changed - like | |
| 320 // if the name, value, or description changed, or if the hypertext had | |
| 321 // text inserted or removed. It's able to figure out exactly what changed | |
| 322 // because we still have old_win_attributes_ populated. | |
| 323 // This step has to run after the previous two steps complete because the | |
| 324 // client may walk the tree when it receives any of these events. | |
| 325 for (size_t i = 0; i < changes.size(); ++i) { | |
| 326 BrowserAccessibility* obj = GetFromAXNode(changes[i].node); | |
| 327 if (obj && obj->IsNative() && !obj->PlatformIsChildOfLeaf()) { | |
| 328 obj->ToBrowserAccessibilityWin()->UpdateStep3FireEvents( | |
| 329 changes[i].type == AXTreeDelegate::SUBTREE_CREATED); | |
| 330 } | |
| 331 } | |
| 332 | |
| 333 // The final step is to delete old_win_attributes_ since they're not | |
| 334 // needed anymore. | |
| 335 for (size_t i = 0; i < changes.size(); ++i) { | |
| 336 BrowserAccessibility* obj = GetFromAXNode(changes[i].node); | |
| 337 if (obj && obj->IsNative() && !obj->PlatformIsChildOfLeaf()) | |
| 338 obj->ToBrowserAccessibilityWin()->UpdateStep4DeleteOldWinAttributes(); | |
|
David Tseng
2015/01/30 23:57:25
Could you combine this last step with the above on
dmazzoni
2015/01/31 07:45:21
Sure. It doesn't really need its own step.
| |
| 311 } | 339 } |
| 312 } | 340 } |
| 313 | 341 |
| 314 void BrowserAccessibilityManagerWin::TrackScrollingObject( | 342 void BrowserAccessibilityManagerWin::TrackScrollingObject( |
| 315 BrowserAccessibilityWin* node) { | 343 BrowserAccessibilityWin* node) { |
| 316 if (tracked_scroll_object_) | 344 if (tracked_scroll_object_) |
| 317 tracked_scroll_object_->Release(); | 345 tracked_scroll_object_->Release(); |
| 318 tracked_scroll_object_ = node; | 346 tracked_scroll_object_ = node; |
| 319 tracked_scroll_object_->AddRef(); | 347 tracked_scroll_object_->AddRef(); |
| 320 } | 348 } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 341 child_manager->GetFromUniqueIdWin(unique_id_win); | 369 child_manager->GetFromUniqueIdWin(unique_id_win); |
| 342 if (result) | 370 if (result) |
| 343 return result; | 371 return result; |
| 344 } | 372 } |
| 345 } | 373 } |
| 346 | 374 |
| 347 return NULL; | 375 return NULL; |
| 348 } | 376 } |
| 349 | 377 |
| 350 } // namespace content | 378 } // namespace content |
| OLD | NEW |