OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/one_shot_accessibility_tree_search.h" | 5 #include "content/browser/accessibility/one_shot_accessibility_tree_search.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
8 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
9 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
10 #include "content/browser/accessibility/browser_accessibility.h" | 12 #include "content/browser/accessibility/browser_accessibility.h" |
11 #include "content/browser/accessibility/browser_accessibility_manager.h" | 13 #include "content/browser/accessibility/browser_accessibility_manager.h" |
12 | 14 |
13 namespace content { | 15 namespace content { |
14 | 16 |
15 // Given a node, populate a vector with all of the strings from that node's | 17 // Given a node, populate a vector with all of the strings from that node's |
16 // attributes that might be relevant for a text search. | 18 // attributes that might be relevant for a text search. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 SearchByWalkingTree(); | 110 SearchByWalkingTree(); |
109 } | 111 } |
110 did_search_ = true; | 112 did_search_ = true; |
111 } | 113 } |
112 | 114 |
113 void OneShotAccessibilityTreeSearch::SearchByIteratingOverChildren() { | 115 void OneShotAccessibilityTreeSearch::SearchByIteratingOverChildren() { |
114 // Iterate over the children of scope_node_. | 116 // Iterate over the children of scope_node_. |
115 // If start_node_ is specified, iterate over the first child past that | 117 // If start_node_ is specified, iterate over the first child past that |
116 // node. | 118 // node. |
117 | 119 |
118 uint32 count = scope_node_->PlatformChildCount(); | 120 uint32_t count = scope_node_->PlatformChildCount(); |
119 if (count == 0) | 121 if (count == 0) |
120 return; | 122 return; |
121 | 123 |
122 // We only care about immediate children of scope_node_, so walk up | 124 // We only care about immediate children of scope_node_, so walk up |
123 // start_node_ until we get to an immediate child. If it isn't a child, | 125 // start_node_ until we get to an immediate child. If it isn't a child, |
124 // we ignore start_node_. | 126 // we ignore start_node_. |
125 while (start_node_ && start_node_->GetParent() != scope_node_) | 127 while (start_node_ && start_node_->GetParent() != scope_node_) |
126 start_node_ = start_node_->GetParent(); | 128 start_node_ = start_node_->GetParent(); |
127 | 129 |
128 uint32 index = (direction_ == FORWARDS ? 0 : count - 1); | 130 uint32_t index = (direction_ == FORWARDS ? 0 : count - 1); |
129 if (start_node_) { | 131 if (start_node_) { |
130 index = start_node_->GetIndexInParent(); | 132 index = start_node_->GetIndexInParent(); |
131 if (direction_ == FORWARDS) | 133 if (direction_ == FORWARDS) |
132 index++; | 134 index++; |
133 else | 135 else |
134 index--; | 136 index--; |
135 } | 137 } |
136 | 138 |
137 while (index < count && | 139 while (index < count && |
138 (result_limit_ == UNLIMITED_RESULTS || | 140 (result_limit_ == UNLIMITED_RESULTS || |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 204 } |
203 } | 205 } |
204 if (!found_text_match) | 206 if (!found_text_match) |
205 return false; | 207 return false; |
206 } | 208 } |
207 | 209 |
208 return true; | 210 return true; |
209 } | 211 } |
210 | 212 |
211 } // namespace content | 213 } // namespace content |
OLD | NEW |