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> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 OneShotAccessibilityTreeSearch::~OneShotAccessibilityTreeSearch() { | 44 OneShotAccessibilityTreeSearch::~OneShotAccessibilityTreeSearch() { |
45 } | 45 } |
46 | 46 |
47 void OneShotAccessibilityTreeSearch::SetStartNode( | 47 void OneShotAccessibilityTreeSearch::SetStartNode( |
48 BrowserAccessibility* start_node) { | 48 BrowserAccessibility* start_node) { |
49 DCHECK(!did_search_); | 49 DCHECK(!did_search_); |
50 CHECK(start_node); | 50 CHECK(start_node); |
51 | 51 |
52 if (!scope_node_->GetParent() || | 52 if (!scope_node_->PlatformGetParent() || |
53 start_node->IsDescendantOf(scope_node_->GetParent())) { | 53 start_node->IsDescendantOf(scope_node_->PlatformGetParent())) { |
54 start_node_ = start_node; | 54 start_node_ = start_node; |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
58 void OneShotAccessibilityTreeSearch::SetDirection(Direction direction) { | 58 void OneShotAccessibilityTreeSearch::SetDirection(Direction direction) { |
59 DCHECK(!did_search_); | 59 DCHECK(!did_search_); |
60 direction_ = direction; | 60 direction_ = direction; |
61 } | 61 } |
62 | 62 |
63 void OneShotAccessibilityTreeSearch::SetResultLimit(int result_limit) { | 63 void OneShotAccessibilityTreeSearch::SetResultLimit(int result_limit) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // 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 |
118 // node. | 118 // node. |
119 | 119 |
120 uint32_t count = scope_node_->PlatformChildCount(); | 120 uint32_t count = scope_node_->PlatformChildCount(); |
121 if (count == 0) | 121 if (count == 0) |
122 return; | 122 return; |
123 | 123 |
124 // 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 |
125 // 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, |
126 // we ignore start_node_. | 126 // we ignore start_node_. |
127 while (start_node_ && start_node_->GetParent() != scope_node_) | 127 while (start_node_ && start_node_->PlatformGetParent() != scope_node_) |
128 start_node_ = start_node_->GetParent(); | 128 start_node_ = start_node_->PlatformGetParent(); |
129 | 129 |
130 uint32_t index = (direction_ == FORWARDS ? 0 : count - 1); | 130 uint32_t index = (direction_ == FORWARDS ? 0 : count - 1); |
131 if (start_node_) { | 131 if (start_node_) { |
132 index = start_node_->GetIndexInParent(); | 132 index = start_node_->GetIndexInParent(); |
133 if (direction_ == FORWARDS) | 133 if (direction_ == FORWARDS) |
134 index++; | 134 index++; |
135 else | 135 else |
136 index--; | 136 index--; |
137 } | 137 } |
138 | 138 |
(...skipping 14 matching lines...) Expand all Loading... |
153 void OneShotAccessibilityTreeSearch::SearchByWalkingTree() { | 153 void OneShotAccessibilityTreeSearch::SearchByWalkingTree() { |
154 BrowserAccessibility* node = nullptr; | 154 BrowserAccessibility* node = nullptr; |
155 node = start_node_; | 155 node = start_node_; |
156 if (node != scope_node_ || result_limit_ == 1) { | 156 if (node != scope_node_ || result_limit_ == 1) { |
157 if (direction_ == FORWARDS) | 157 if (direction_ == FORWARDS) |
158 node = tree_->NextInTreeOrder(start_node_); | 158 node = tree_->NextInTreeOrder(start_node_); |
159 else | 159 else |
160 node = tree_->PreviousInTreeOrder(start_node_); | 160 node = tree_->PreviousInTreeOrder(start_node_); |
161 } | 161 } |
162 | 162 |
163 BrowserAccessibility* stop_node = scope_node_->GetParent(); | 163 BrowserAccessibility* stop_node = scope_node_->PlatformGetParent(); |
164 while (node && | 164 while (node && |
165 node != stop_node && | 165 node != stop_node && |
166 (result_limit_ == UNLIMITED_RESULTS || | 166 (result_limit_ == UNLIMITED_RESULTS || |
167 static_cast<int>(matches_.size()) < result_limit_)) { | 167 static_cast<int>(matches_.size()) < result_limit_)) { |
168 if (Matches(node)) | 168 if (Matches(node)) |
169 matches_.push_back(node); | 169 matches_.push_back(node); |
170 | 170 |
171 if (direction_ == FORWARDS) | 171 if (direction_ == FORWARDS) |
172 node = tree_->NextInTreeOrder(node); | 172 node = tree_->NextInTreeOrder(node); |
173 else | 173 else |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 return (node->GetRole() == ui::AX_ROLE_HEADING && | 329 return (node->GetRole() == ui::AX_ROLE_HEADING && |
330 start->GetRole() == ui::AX_ROLE_HEADING && | 330 start->GetRole() == ui::AX_ROLE_HEADING && |
331 (node->GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL) == | 331 (node->GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL) == |
332 start->GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL))); | 332 start->GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL))); |
333 } | 333 } |
334 | 334 |
335 bool AccessibilityFramePredicate( | 335 bool AccessibilityFramePredicate( |
336 BrowserAccessibility* start, BrowserAccessibility* node) { | 336 BrowserAccessibility* start, BrowserAccessibility* node) { |
337 if (node->IsWebAreaForPresentationalIframe()) | 337 if (node->IsWebAreaForPresentationalIframe()) |
338 return false; | 338 return false; |
339 if (!node->GetParent()) | 339 if (!node->PlatformGetParent()) |
340 return false; | 340 return false; |
341 return (node->GetRole() == ui::AX_ROLE_WEB_AREA || | 341 return (node->GetRole() == ui::AX_ROLE_WEB_AREA || |
342 node->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA); | 342 node->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA); |
343 } | 343 } |
344 | 344 |
345 bool AccessibilityLandmarkPredicate( | 345 bool AccessibilityLandmarkPredicate( |
346 BrowserAccessibility* start, BrowserAccessibility* node) { | 346 BrowserAccessibility* start, BrowserAccessibility* node) { |
347 switch (node->GetRole()) { | 347 switch (node->GetRole()) { |
348 case ui::AX_ROLE_APPLICATION: | 348 case ui::AX_ROLE_APPLICATION: |
349 case ui::AX_ROLE_ARTICLE: | 349 case ui::AX_ROLE_ARTICLE: |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 } | 449 } |
450 | 450 |
451 bool AccessibilityVisitedLinkPredicate( | 451 bool AccessibilityVisitedLinkPredicate( |
452 BrowserAccessibility* start, BrowserAccessibility* node) { | 452 BrowserAccessibility* start, BrowserAccessibility* node) { |
453 return ((node->GetRole() == ui::AX_ROLE_LINK || | 453 return ((node->GetRole() == ui::AX_ROLE_LINK || |
454 node->GetRole() == ui::AX_ROLE_IMAGE_MAP_LINK) && | 454 node->GetRole() == ui::AX_ROLE_IMAGE_MAP_LINK) && |
455 node->HasState(ui::AX_STATE_VISITED)); | 455 node->HasState(ui::AX_STATE_VISITED)); |
456 } | 456 } |
457 | 457 |
458 } // namespace content | 458 } // namespace content |
OLD | NEW |