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 <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 return nullptr; | 739 return nullptr; |
740 | 740 |
741 if (object->PlatformChildCount()) | 741 if (object->PlatformChildCount()) |
742 return object->PlatformGetChild(0); | 742 return object->PlatformGetChild(0); |
743 | 743 |
744 while (object) { | 744 while (object) { |
745 BrowserAccessibility* sibling = object->GetNextSibling(); | 745 BrowserAccessibility* sibling = object->GetNextSibling(); |
746 if (sibling) | 746 if (sibling) |
747 return sibling; | 747 return sibling; |
748 | 748 |
749 object = object->GetParent(); | 749 object = object->PlatformGetParent(); |
750 } | 750 } |
751 | 751 |
752 return nullptr; | 752 return nullptr; |
753 } | 753 } |
754 | 754 |
755 // static | 755 // static |
756 // Previous object in tree using depth-first pre-order traversal. | 756 // Previous object in tree using depth-first pre-order traversal. |
757 BrowserAccessibility* BrowserAccessibilityManager::PreviousInTreeOrder( | 757 BrowserAccessibility* BrowserAccessibilityManager::PreviousInTreeOrder( |
758 const BrowserAccessibility* object) { | 758 const BrowserAccessibility* object) { |
759 if (!object) | 759 if (!object) |
760 return nullptr; | 760 return nullptr; |
761 | 761 |
762 BrowserAccessibility* sibling = object->GetPreviousSibling(); | 762 BrowserAccessibility* sibling = object->GetPreviousSibling(); |
763 if (!sibling) | 763 if (!sibling) |
764 return object->GetParent(); | 764 return object->PlatformGetParent(); |
765 | 765 |
766 if (sibling->PlatformChildCount()) | 766 if (sibling->PlatformChildCount()) |
767 return sibling->PlatformDeepestLastChild(); | 767 return sibling->PlatformDeepestLastChild(); |
768 | 768 |
769 return sibling; | 769 return sibling; |
770 } | 770 } |
771 | 771 |
772 // static | 772 // static |
773 BrowserAccessibility* BrowserAccessibilityManager::PreviousTextOnlyObject( | 773 BrowserAccessibility* BrowserAccessibilityManager::PreviousTextOnlyObject( |
774 const BrowserAccessibility* object) { | 774 const BrowserAccessibility* object) { |
(...skipping 19 matching lines...) Expand all Loading... |
794 const BrowserAccessibility& object1, | 794 const BrowserAccessibility& object1, |
795 const BrowserAccessibility& object2, | 795 const BrowserAccessibility& object2, |
796 BrowserAccessibility** common_parent, | 796 BrowserAccessibility** common_parent, |
797 int* child_index1, | 797 int* child_index1, |
798 int* child_index2) { | 798 int* child_index2) { |
799 DCHECK(common_parent && child_index1 && child_index2); | 799 DCHECK(common_parent && child_index1 && child_index2); |
800 auto* ancestor1 = const_cast<BrowserAccessibility*>(&object1); | 800 auto* ancestor1 = const_cast<BrowserAccessibility*>(&object1); |
801 auto* ancestor2 = const_cast<BrowserAccessibility*>(&object2); | 801 auto* ancestor2 = const_cast<BrowserAccessibility*>(&object2); |
802 do { | 802 do { |
803 *child_index1 = ancestor1->GetIndexInParent(); | 803 *child_index1 = ancestor1->GetIndexInParent(); |
804 ancestor1 = ancestor1->GetParent(); | 804 ancestor1 = ancestor1->PlatformGetParent(); |
805 } while ( | 805 } while ( |
806 ancestor1 && | 806 ancestor1 && |
807 // |BrowserAccessibility::IsAncestorOf| returns true if objects are equal. | 807 // |BrowserAccessibility::IsAncestorOf| returns true if objects are equal. |
808 (ancestor1 == ancestor2 || !ancestor2->IsDescendantOf(ancestor1))); | 808 (ancestor1 == ancestor2 || !ancestor2->IsDescendantOf(ancestor1))); |
809 | 809 |
810 if (!ancestor1) { | 810 if (!ancestor1) { |
811 *common_parent = nullptr; | 811 *common_parent = nullptr; |
812 *child_index1 = -1; | 812 *child_index1 = -1; |
813 *child_index2 = -1; | 813 *child_index2 = -1; |
814 return false; | 814 return false; |
815 } | 815 } |
816 | 816 |
817 do { | 817 do { |
818 *child_index2 = ancestor2->GetIndexInParent(); | 818 *child_index2 = ancestor2->GetIndexInParent(); |
819 ancestor2 = ancestor2->GetParent(); | 819 ancestor2 = ancestor2->PlatformGetParent(); |
820 } while (ancestor1 != ancestor2); | 820 } while (ancestor1 != ancestor2); |
821 | 821 |
822 *common_parent = ancestor1; | 822 *common_parent = ancestor1; |
823 return true; | 823 return true; |
824 } | 824 } |
825 | 825 |
826 // static | 826 // static |
827 ui::AXTreeOrder BrowserAccessibilityManager::CompareNodes( | 827 ui::AXTreeOrder BrowserAccessibilityManager::CompareNodes( |
828 const BrowserAccessibility& object1, | 828 const BrowserAccessibility& object1, |
829 const BrowserAccessibility& object2) { | 829 const BrowserAccessibility& object2) { |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1231 // more complicated layouts. The hope is that if the user is moving the | 1231 // more complicated layouts. The hope is that if the user is moving the |
1232 // mouse, this fallback will only be used transiently, and the asynchronous | 1232 // mouse, this fallback will only be used transiently, and the asynchronous |
1233 // result will be used for the next call. | 1233 // result will be used for the next call. |
1234 return GetRoot()->ApproximateHitTest(screen_point); | 1234 return GetRoot()->ApproximateHitTest(screen_point); |
1235 } | 1235 } |
1236 | 1236 |
1237 void BrowserAccessibilityManager::CacheHitTestResult( | 1237 void BrowserAccessibilityManager::CacheHitTestResult( |
1238 BrowserAccessibility* hit_test_result) { | 1238 BrowserAccessibility* hit_test_result) { |
1239 // Walk up to the highest ancestor that's a leaf node; we don't want to | 1239 // Walk up to the highest ancestor that's a leaf node; we don't want to |
1240 // return a node that's hidden from the tree. | 1240 // return a node that's hidden from the tree. |
1241 BrowserAccessibility* parent = hit_test_result->GetParent(); | 1241 BrowserAccessibility* parent = hit_test_result->PlatformGetParent(); |
1242 while (parent) { | 1242 while (parent) { |
1243 if (parent->PlatformChildCount() == 0) | 1243 if (parent->PlatformChildCount() == 0) |
1244 hit_test_result = parent; | 1244 hit_test_result = parent; |
1245 parent = parent->GetParent(); | 1245 parent = parent->PlatformGetParent(); |
1246 } | 1246 } |
1247 | 1247 |
1248 last_hover_ax_tree_id_ = hit_test_result->manager()->ax_tree_id(); | 1248 last_hover_ax_tree_id_ = hit_test_result->manager()->ax_tree_id(); |
1249 last_hover_node_id_ = hit_test_result->GetId(); | 1249 last_hover_node_id_ = hit_test_result->GetId(); |
1250 last_hover_bounds_ = hit_test_result->GetScreenBoundsRect(); | 1250 last_hover_bounds_ = hit_test_result->GetScreenBoundsRect(); |
1251 } | 1251 } |
1252 | 1252 |
1253 } // namespace content | 1253 } // namespace content |
OLD | NEW |