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.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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 const BrowserAccessibility& node, | 355 const BrowserAccessibility& node, |
| 356 int start_offset, | 356 int start_offset, |
| 357 int end_offset) { | 357 int end_offset) { |
| 358 if (delegate_) { | 358 if (delegate_) { |
| 359 delegate_->AccessibilitySetTextSelection( | 359 delegate_->AccessibilitySetTextSelection( |
| 360 node.GetId(), start_offset, end_offset); | 360 node.GetId(), start_offset, end_offset); |
| 361 } | 361 } |
| 362 } | 362 } |
| 363 | 363 |
| 364 gfx::Rect BrowserAccessibilityManager::GetViewBounds() { | 364 gfx::Rect BrowserAccessibilityManager::GetViewBounds() { |
| 365 if (delegate_) | 365 BrowserAccessibilityDelegate* delegate = GetDelegateFromRootManager(); |
| 366 return delegate_->AccessibilityGetViewBounds(); | 366 if (delegate) |
| 367 return delegate->AccessibilityGetViewBounds(); | |
| 367 return gfx::Rect(); | 368 return gfx::Rect(); |
| 368 } | 369 } |
| 369 | 370 |
| 370 BrowserAccessibility* BrowserAccessibilityManager::NextInTreeOrder( | 371 BrowserAccessibility* BrowserAccessibilityManager::NextInTreeOrder( |
| 371 BrowserAccessibility* node) { | 372 BrowserAccessibility* node) { |
| 372 if (!node) | 373 if (!node) |
| 373 return NULL; | 374 return NULL; |
| 374 | 375 |
| 375 if (node->PlatformChildCount() > 0) | 376 if (node->PlatformChildCount() > 0) |
| 376 return node->PlatformGetChild(0); | 377 return node->PlatformGetChild(0); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 } | 427 } |
| 427 | 428 |
| 428 void BrowserAccessibilityManager::OnNodeCreationFinished(ui::AXNode* node) { | 429 void BrowserAccessibilityManager::OnNodeCreationFinished(ui::AXNode* node) { |
| 429 GetFromAXNode(node)->OnUpdateFinished(); | 430 GetFromAXNode(node)->OnUpdateFinished(); |
| 430 } | 431 } |
| 431 | 432 |
| 432 void BrowserAccessibilityManager::OnNodeChangeFinished(ui::AXNode* node) { | 433 void BrowserAccessibilityManager::OnNodeChangeFinished(ui::AXNode* node) { |
| 433 GetFromAXNode(node)->OnUpdateFinished(); | 434 GetFromAXNode(node)->OnUpdateFinished(); |
| 434 } | 435 } |
| 435 | 436 |
| 437 BrowserAccessibilityDelegate* | |
| 438 BrowserAccessibilityManager::GetDelegateFromRootManager() { | |
| 439 BrowserAccessibility* root = GetRoot(); | |
|
David Tseng
2015/01/15 22:33:27
Would maybe be cleaner to just hold a pointer to B
dmazzoni
2015/01/15 23:09:22
Done.
| |
| 440 while (root->GetParent()) | |
| 441 root = root->GetParent()->manager()->GetRoot(); | |
| 442 return root->manager()->delegate(); | |
| 443 } | |
| 444 | |
| 436 ui::AXTreeUpdate BrowserAccessibilityManager::SnapshotAXTreeForTesting() { | 445 ui::AXTreeUpdate BrowserAccessibilityManager::SnapshotAXTreeForTesting() { |
| 437 scoped_ptr<ui::AXTreeSource<const ui::AXNode*> > tree_source( | 446 scoped_ptr<ui::AXTreeSource<const ui::AXNode*> > tree_source( |
| 438 tree_->CreateTreeSource()); | 447 tree_->CreateTreeSource()); |
| 439 ui::AXTreeSerializer<const ui::AXNode*> serializer(tree_source.get()); | 448 ui::AXTreeSerializer<const ui::AXNode*> serializer(tree_source.get()); |
| 440 ui::AXTreeUpdate update; | 449 ui::AXTreeUpdate update; |
| 441 serializer.SerializeChanges(tree_->GetRoot(), &update); | 450 serializer.SerializeChanges(tree_->GetRoot(), &update); |
| 442 return update; | 451 return update; |
| 443 } | 452 } |
| 444 | 453 |
| 445 } // namespace content | 454 } // namespace content |
| OLD | NEW |