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.h" | 5 #include "content/browser/accessibility/browser_accessibility.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 case ui::AX_ROLE_SLIDER: | 53 case ui::AX_ROLE_SLIDER: |
54 case ui::AX_ROLE_STATIC_TEXT: | 54 case ui::AX_ROLE_STATIC_TEXT: |
55 case ui::AX_ROLE_TEXT_FIELD: | 55 case ui::AX_ROLE_TEXT_FIELD: |
56 return true; | 56 return true; |
57 default: | 57 default: |
58 return false; | 58 return false; |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 uint32 BrowserAccessibility::PlatformChildCount() const { | 62 uint32 BrowserAccessibility::PlatformChildCount() const { |
63 if (GetBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST)) { | |
64 // Check if the child frame currently exists. | |
65 if (manager_->delegate()->AccessibilityGetChildFrame(GetId())) | |
66 return 1; | |
67 | |
68 return 0; | |
69 } | |
70 | |
71 return PlatformIsLeaf() ? 0 : InternalChildCount(); | 63 return PlatformIsLeaf() ? 0 : InternalChildCount(); |
72 } | 64 } |
73 | 65 |
74 bool BrowserAccessibility::IsNative() const { | 66 bool BrowserAccessibility::IsNative() const { |
75 return false; | 67 return false; |
76 } | 68 } |
77 | 69 |
78 bool BrowserAccessibility::IsDescendantOf( | 70 bool BrowserAccessibility::IsDescendantOf( |
79 BrowserAccessibility* ancestor) { | 71 BrowserAccessibility* ancestor) { |
80 if (this == ancestor) { | 72 if (this == ancestor) { |
81 return true; | 73 return true; |
82 } else if (GetParent()) { | 74 } else if (GetParent()) { |
83 return GetParent()->IsDescendantOf(ancestor); | 75 return GetParent()->IsDescendantOf(ancestor); |
84 } | 76 } |
85 | 77 |
86 return false; | 78 return false; |
87 } | 79 } |
88 | 80 |
89 BrowserAccessibility* BrowserAccessibility::PlatformGetChild( | 81 BrowserAccessibility* BrowserAccessibility::PlatformGetChild( |
90 uint32 child_index) const { | 82 uint32 child_index) const { |
91 DCHECK(child_index < PlatformChildCount()); | 83 DCHECK(child_index < InternalChildCount()); |
92 BrowserAccessibility* result = nullptr; | 84 BrowserAccessibility* result = InternalGetChild(child_index); |
93 | 85 |
94 if (GetBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST)) { | 86 if (result->HasBoolAttribute(ui::AX_ATTR_IS_AX_TREE_HOST)) { |
95 BrowserAccessibilityManager* child_manager = | 87 BrowserAccessibilityManager* child_manager = |
96 manager_->delegate()->AccessibilityGetChildFrame(GetId()); | 88 manager_->delegate()->AccessibilityGetChildFrame(result->GetId()); |
97 if (child_manager) | 89 if (child_manager) |
98 result = child_manager->GetRoot(); | 90 result = child_manager->GetRoot(); |
99 } else { | |
100 result = InternalGetChild(child_index); | |
101 } | 91 } |
102 | 92 |
103 return result; | 93 return result; |
104 } | 94 } |
105 | 95 |
106 bool BrowserAccessibility::PlatformIsChildOfLeaf() const { | 96 bool BrowserAccessibility::PlatformIsChildOfLeaf() const { |
107 BrowserAccessibility* ancestor = GetParent(); | 97 BrowserAccessibility* ancestor = GetParent(); |
108 while (ancestor) { | 98 while (ancestor) { |
109 if (ancestor->PlatformIsLeaf()) | 99 if (ancestor->PlatformIsLeaf()) |
110 return true; | 100 return true; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 return manager_->GetFromAXNode(parent); | 143 return manager_->GetFromAXNode(parent); |
154 | 144 |
155 if (!manager_->delegate()) | 145 if (!manager_->delegate()) |
156 return NULL; | 146 return NULL; |
157 | 147 |
158 BrowserAccessibility* host_node = | 148 BrowserAccessibility* host_node = |
159 manager_->delegate()->AccessibilityGetParentFrame(); | 149 manager_->delegate()->AccessibilityGetParentFrame(); |
160 if (!host_node) | 150 if (!host_node) |
161 return NULL; | 151 return NULL; |
162 | 152 |
163 return host_node; | 153 return host_node->GetParent(); |
164 } | 154 } |
165 | 155 |
166 int32 BrowserAccessibility::GetIndexInParent() const { | 156 int32 BrowserAccessibility::GetIndexInParent() const { |
167 return node_ ? node_->index_in_parent() : -1; | 157 return node_ ? node_->index_in_parent() : -1; |
168 } | 158 } |
169 | 159 |
170 int32 BrowserAccessibility::GetId() const { | 160 int32 BrowserAccessibility::GetId() const { |
171 return node_ ? node_->id() : -1; | 161 return node_ ? node_->id() : -1; |
172 } | 162 } |
173 | 163 |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 } | 756 } |
767 need_to_offset_web_area = true; | 757 need_to_offset_web_area = true; |
768 } | 758 } |
769 parent = parent->GetParentForBoundsCalculation(); | 759 parent = parent->GetParentForBoundsCalculation(); |
770 } | 760 } |
771 | 761 |
772 return bounds; | 762 return bounds; |
773 } | 763 } |
774 | 764 |
775 } // namespace content | 765 } // namespace content |
OLD | NEW |