Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: content/browser/accessibility/browser_accessibility_android.cc

Issue 224803005: Refactor BrowserAccessibility to prepare for AXNode (re-land) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix gtk Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_android.h" 5 #include "content/browser/accessibility/browser_accessibility_android.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/browser/accessibility/browser_accessibility_manager_android.h" 8 #include "content/browser/accessibility/browser_accessibility_manager_android.h"
9 #include "content/common/accessibility_messages.h" 9 #include "content/common/accessibility_messages.h"
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 BrowserAccessibilityAndroid::BrowserAccessibilityAndroid() { 50 BrowserAccessibilityAndroid::BrowserAccessibilityAndroid() {
51 first_time_ = true; 51 first_time_ = true;
52 } 52 }
53 53
54 bool BrowserAccessibilityAndroid::IsNative() const { 54 bool BrowserAccessibilityAndroid::IsNative() const {
55 return true; 55 return true;
56 } 56 }
57 57
58 bool BrowserAccessibilityAndroid::PlatformIsLeaf() const { 58 bool BrowserAccessibilityAndroid::PlatformIsLeaf() const {
59 if (child_count() == 0) 59 if (InternalChildCount() == 0)
60 return true; 60 return true;
61 61
62 // Iframes are always allowed to contain children. 62 // Iframes are always allowed to contain children.
63 if (IsIframe() || 63 if (IsIframe() ||
64 role() == ui::AX_ROLE_ROOT_WEB_AREA || 64 GetRole() == ui::AX_ROLE_ROOT_WEB_AREA ||
65 role() == ui::AX_ROLE_WEB_AREA) { 65 GetRole() == ui::AX_ROLE_WEB_AREA) {
66 return false; 66 return false;
67 } 67 }
68 68
69 // If it has a focusable child, we definitely can't leave out children. 69 // If it has a focusable child, we definitely can't leave out children.
70 if (HasFocusableChild()) 70 if (HasFocusableChild())
71 return false; 71 return false;
72 72
73 // Headings with text can drop their children. 73 // Headings with text can drop their children.
74 base::string16 name = GetText(); 74 base::string16 name = GetText();
75 if (role() == ui::AX_ROLE_HEADING && !name.empty()) 75 if (GetRole() == ui::AX_ROLE_HEADING && !name.empty())
76 return true; 76 return true;
77 77
78 // Focusable nodes with text can drop their children. 78 // Focusable nodes with text can drop their children.
79 if (HasState(ui::AX_STATE_FOCUSABLE) && !name.empty()) 79 if (HasState(ui::AX_STATE_FOCUSABLE) && !name.empty())
80 return true; 80 return true;
81 81
82 // Nodes with only static text as children can drop their children. 82 // Nodes with only static text as children can drop their children.
83 if (HasOnlyStaticTextChildren()) 83 if (HasOnlyStaticTextChildren())
84 return true; 84 return true;
85 85
86 return BrowserAccessibility::PlatformIsLeaf(); 86 return BrowserAccessibility::PlatformIsLeaf();
87 } 87 }
88 88
89 bool BrowserAccessibilityAndroid::IsCheckable() const { 89 bool BrowserAccessibilityAndroid::IsCheckable() const {
90 bool checkable = false; 90 bool checkable = false;
91 bool is_aria_pressed_defined; 91 bool is_aria_pressed_defined;
92 bool is_mixed; 92 bool is_mixed;
93 GetAriaTristate("aria-pressed", &is_aria_pressed_defined, &is_mixed); 93 GetAriaTristate("aria-pressed", &is_aria_pressed_defined, &is_mixed);
94 if (role() == ui::AX_ROLE_CHECK_BOX || 94 if (GetRole() == ui::AX_ROLE_CHECK_BOX ||
95 role() == ui::AX_ROLE_RADIO_BUTTON || 95 GetRole() == ui::AX_ROLE_RADIO_BUTTON ||
96 is_aria_pressed_defined) { 96 is_aria_pressed_defined) {
97 checkable = true; 97 checkable = true;
98 } 98 }
99 if (HasState(ui::AX_STATE_CHECKED)) 99 if (HasState(ui::AX_STATE_CHECKED))
100 checkable = true; 100 checkable = true;
101 return checkable; 101 return checkable;
102 } 102 }
103 103
104 bool BrowserAccessibilityAndroid::IsChecked() const { 104 bool BrowserAccessibilityAndroid::IsChecked() const {
105 return HasState(ui::AX_STATE_CHECKED); 105 return HasState(ui::AX_STATE_CHECKED);
106 } 106 }
107 107
108 bool BrowserAccessibilityAndroid::IsClickable() const { 108 bool BrowserAccessibilityAndroid::IsClickable() const {
109 return (PlatformIsLeaf() && !GetText().empty()); 109 return (PlatformIsLeaf() && !GetText().empty());
110 } 110 }
111 111
112 bool BrowserAccessibilityAndroid::IsCollection() const { 112 bool BrowserAccessibilityAndroid::IsCollection() const {
113 return (role() == ui::AX_ROLE_GRID || 113 return (GetRole() == ui::AX_ROLE_GRID ||
114 role() == ui::AX_ROLE_LIST || 114 GetRole() == ui::AX_ROLE_LIST ||
115 role() == ui::AX_ROLE_LIST_BOX || 115 GetRole() == ui::AX_ROLE_LIST_BOX ||
116 role() == ui::AX_ROLE_TABLE || 116 GetRole() == ui::AX_ROLE_TABLE ||
117 role() == ui::AX_ROLE_TREE); 117 GetRole() == ui::AX_ROLE_TREE);
118 } 118 }
119 119
120 bool BrowserAccessibilityAndroid::IsCollectionItem() const { 120 bool BrowserAccessibilityAndroid::IsCollectionItem() const {
121 return (role() == ui::AX_ROLE_CELL || 121 return (GetRole() == ui::AX_ROLE_CELL ||
122 role() == ui::AX_ROLE_COLUMN_HEADER || 122 GetRole() == ui::AX_ROLE_COLUMN_HEADER ||
123 role() == ui::AX_ROLE_DESCRIPTION_LIST_TERM || 123 GetRole() == ui::AX_ROLE_DESCRIPTION_LIST_TERM ||
124 role() == ui::AX_ROLE_LIST_BOX_OPTION || 124 GetRole() == ui::AX_ROLE_LIST_BOX_OPTION ||
125 role() == ui::AX_ROLE_LIST_ITEM || 125 GetRole() == ui::AX_ROLE_LIST_ITEM ||
126 role() == ui::AX_ROLE_ROW_HEADER || 126 GetRole() == ui::AX_ROLE_ROW_HEADER ||
127 role() == ui::AX_ROLE_TREE_ITEM); 127 GetRole() == ui::AX_ROLE_TREE_ITEM);
128 } 128 }
129 129
130 bool BrowserAccessibilityAndroid::IsContentInvalid() const { 130 bool BrowserAccessibilityAndroid::IsContentInvalid() const {
131 std::string invalid; 131 std::string invalid;
132 return GetHtmlAttribute("aria-invalid", &invalid); 132 return GetHtmlAttribute("aria-invalid", &invalid);
133 } 133 }
134 134
135 bool BrowserAccessibilityAndroid::IsDismissable() const { 135 bool BrowserAccessibilityAndroid::IsDismissable() const {
136 return false; // No concept of "dismissable" on the web currently. 136 return false; // No concept of "dismissable" on the web currently.
137 } 137 }
138 138
139 bool BrowserAccessibilityAndroid::IsEnabled() const { 139 bool BrowserAccessibilityAndroid::IsEnabled() const {
140 return HasState(ui::AX_STATE_ENABLED); 140 return HasState(ui::AX_STATE_ENABLED);
141 } 141 }
142 142
143 bool BrowserAccessibilityAndroid::IsFocusable() const { 143 bool BrowserAccessibilityAndroid::IsFocusable() const {
144 bool focusable = HasState(ui::AX_STATE_FOCUSABLE); 144 bool focusable = HasState(ui::AX_STATE_FOCUSABLE);
145 if (IsIframe() || 145 if (IsIframe() ||
146 role() == ui::AX_ROLE_WEB_AREA) { 146 GetRole() == ui::AX_ROLE_WEB_AREA) {
147 focusable = false; 147 focusable = false;
148 } 148 }
149 return focusable; 149 return focusable;
150 } 150 }
151 151
152 bool BrowserAccessibilityAndroid::IsFocused() const { 152 bool BrowserAccessibilityAndroid::IsFocused() const {
153 return manager()->GetFocus(manager()->GetRoot()) == this; 153 return manager()->GetFocus(manager()->GetRoot()) == this;
154 } 154 }
155 155
156 bool BrowserAccessibilityAndroid::IsHeading() const { 156 bool BrowserAccessibilityAndroid::IsHeading() const {
157 return (role() == ui::AX_ROLE_COLUMN_HEADER || 157 return (GetRole() == ui::AX_ROLE_COLUMN_HEADER ||
158 role() == ui::AX_ROLE_HEADING || 158 GetRole() == ui::AX_ROLE_HEADING ||
159 role() == ui::AX_ROLE_ROW_HEADER); 159 GetRole() == ui::AX_ROLE_ROW_HEADER);
160 } 160 }
161 161
162 bool BrowserAccessibilityAndroid::IsHierarchical() const { 162 bool BrowserAccessibilityAndroid::IsHierarchical() const {
163 return (role() == ui::AX_ROLE_LIST || 163 return (GetRole() == ui::AX_ROLE_LIST ||
164 role() == ui::AX_ROLE_TREE); 164 GetRole() == ui::AX_ROLE_TREE);
165 } 165 }
166 166
167 bool BrowserAccessibilityAndroid::IsLink() const { 167 bool BrowserAccessibilityAndroid::IsLink() const {
168 return role() == ui::AX_ROLE_LINK || role() == ui::AX_ROLE_IMAGE_MAP_LINK; 168 return GetRole() == ui::AX_ROLE_LINK ||
169 GetRole() == ui::AX_ROLE_IMAGE_MAP_LINK;
169 } 170 }
170 171
171 bool BrowserAccessibilityAndroid::IsMultiLine() const { 172 bool BrowserAccessibilityAndroid::IsMultiLine() const {
172 return role() == ui::AX_ROLE_TEXT_AREA; 173 return GetRole() == ui::AX_ROLE_TEXT_AREA;
173 } 174 }
174 175
175 bool BrowserAccessibilityAndroid::IsPassword() const { 176 bool BrowserAccessibilityAndroid::IsPassword() const {
176 return HasState(ui::AX_STATE_PROTECTED); 177 return HasState(ui::AX_STATE_PROTECTED);
177 } 178 }
178 179
179 bool BrowserAccessibilityAndroid::IsRangeType() const { 180 bool BrowserAccessibilityAndroid::IsRangeType() const {
180 return (role() == ui::AX_ROLE_PROGRESS_INDICATOR || 181 return (GetRole() == ui::AX_ROLE_PROGRESS_INDICATOR ||
181 role() == ui::AX_ROLE_SCROLL_BAR || 182 GetRole() == ui::AX_ROLE_SCROLL_BAR ||
182 role() == ui::AX_ROLE_SLIDER); 183 GetRole() == ui::AX_ROLE_SLIDER);
183 } 184 }
184 185
185 bool BrowserAccessibilityAndroid::IsScrollable() const { 186 bool BrowserAccessibilityAndroid::IsScrollable() const {
186 int dummy; 187 int dummy;
187 return GetIntAttribute(ui::AX_ATTR_SCROLL_X_MAX, &dummy); 188 return GetIntAttribute(ui::AX_ATTR_SCROLL_X_MAX, &dummy);
188 } 189 }
189 190
190 bool BrowserAccessibilityAndroid::IsSelected() const { 191 bool BrowserAccessibilityAndroid::IsSelected() const {
191 return HasState(ui::AX_STATE_SELECTED); 192 return HasState(ui::AX_STATE_SELECTED);
192 } 193 }
193 194
194 bool BrowserAccessibilityAndroid::IsVisibleToUser() const { 195 bool BrowserAccessibilityAndroid::IsVisibleToUser() const {
195 return !HasState(ui::AX_STATE_INVISIBLE); 196 return !HasState(ui::AX_STATE_INVISIBLE);
196 } 197 }
197 198
198 bool BrowserAccessibilityAndroid::CanOpenPopup() const { 199 bool BrowserAccessibilityAndroid::CanOpenPopup() const {
199 return HasState(ui::AX_STATE_HASPOPUP); 200 return HasState(ui::AX_STATE_HASPOPUP);
200 } 201 }
201 202
202 const char* BrowserAccessibilityAndroid::GetClassName() const { 203 const char* BrowserAccessibilityAndroid::GetClassName() const {
203 const char* class_name = NULL; 204 const char* class_name = NULL;
204 205
205 switch(role()) { 206 switch(GetRole()) {
206 case ui::AX_ROLE_EDITABLE_TEXT: 207 case ui::AX_ROLE_EDITABLE_TEXT:
207 case ui::AX_ROLE_SPIN_BUTTON: 208 case ui::AX_ROLE_SPIN_BUTTON:
208 case ui::AX_ROLE_TEXT_AREA: 209 case ui::AX_ROLE_TEXT_AREA:
209 case ui::AX_ROLE_TEXT_FIELD: 210 case ui::AX_ROLE_TEXT_FIELD:
210 class_name = "android.widget.EditText"; 211 class_name = "android.widget.EditText";
211 break; 212 break;
212 case ui::AX_ROLE_SLIDER: 213 case ui::AX_ROLE_SLIDER:
213 class_name = "android.widget.SeekBar"; 214 class_name = "android.widget.SeekBar";
214 break; 215 break;
215 case ui::AX_ROLE_COMBO_BOX: 216 case ui::AX_ROLE_COMBO_BOX:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 default: 257 default:
257 class_name = "android.view.View"; 258 class_name = "android.view.View";
258 break; 259 break;
259 } 260 }
260 261
261 return class_name; 262 return class_name;
262 } 263 }
263 264
264 base::string16 BrowserAccessibilityAndroid::GetText() const { 265 base::string16 BrowserAccessibilityAndroid::GetText() const {
265 if (IsIframe() || 266 if (IsIframe() ||
266 role() == ui::AX_ROLE_WEB_AREA) { 267 GetRole() == ui::AX_ROLE_WEB_AREA) {
267 return base::string16(); 268 return base::string16();
268 } 269 }
269 270
270 base::string16 description = GetString16Attribute( 271 base::string16 description = GetString16Attribute(
271 ui::AX_ATTR_DESCRIPTION); 272 ui::AX_ATTR_DESCRIPTION);
272 base::string16 text; 273 base::string16 text;
273 if (!name().empty()) 274 if (!name().empty())
274 text = base::UTF8ToUTF16(name()); 275 text = base::UTF8ToUTF16(name());
275 else if (!description.empty()) 276 else if (!description.empty())
276 text = description; 277 text = description;
277 else if (!value().empty()) 278 else if (!value().empty())
278 text = base::UTF8ToUTF16(value()); 279 text = base::UTF8ToUTF16(value());
279 280
280 // This is called from PlatformIsLeaf, so don't call PlatformChildCount 281 // This is called from PlatformIsLeaf, so don't call PlatformChildCount
281 // from within this! 282 // from within this!
282 if (text.empty() && HasOnlyStaticTextChildren()) { 283 if (text.empty() && HasOnlyStaticTextChildren()) {
283 for (uint32 i = 0; i < child_count(); i++) { 284 for (uint32 i = 0; i < InternalChildCount(); i++) {
284 BrowserAccessibility* child = children()[i]; 285 BrowserAccessibility* child = InternalGetChild(i);
285 text += static_cast<BrowserAccessibilityAndroid*>(child)->GetText(); 286 text += static_cast<BrowserAccessibilityAndroid*>(child)->GetText();
286 } 287 }
287 } 288 }
288 289
289 switch(role()) { 290 switch(GetRole()) {
290 case ui::AX_ROLE_HEADING: 291 case ui::AX_ROLE_HEADING:
291 // Only append "heading" if this node already has text. 292 // Only append "heading" if this node already has text.
292 if (!text.empty()) 293 if (!text.empty())
293 text += base::ASCIIToUTF16(" Heading"); 294 text += base::ASCIIToUTF16(" Heading");
294 break; 295 break;
295 } 296 }
296 297
297 return text; 298 return text;
298 } 299 }
299 300
300 int BrowserAccessibilityAndroid::GetItemIndex() const { 301 int BrowserAccessibilityAndroid::GetItemIndex() const {
301 int index = 0; 302 int index = 0;
302 switch(role()) { 303 switch(GetRole()) {
303 case ui::AX_ROLE_LIST_ITEM: 304 case ui::AX_ROLE_LIST_ITEM:
304 case ui::AX_ROLE_LIST_BOX_OPTION: 305 case ui::AX_ROLE_LIST_BOX_OPTION:
305 case ui::AX_ROLE_TREE_ITEM: 306 case ui::AX_ROLE_TREE_ITEM:
306 index = index_in_parent(); 307 index = GetIndexInParent();
307 break; 308 break;
308 case ui::AX_ROLE_SLIDER: 309 case ui::AX_ROLE_SLIDER:
309 case ui::AX_ROLE_PROGRESS_INDICATOR: { 310 case ui::AX_ROLE_PROGRESS_INDICATOR: {
310 float value_for_range; 311 float value_for_range;
311 if (GetFloatAttribute( 312 if (GetFloatAttribute(
312 ui::AX_ATTR_VALUE_FOR_RANGE, &value_for_range)) { 313 ui::AX_ATTR_VALUE_FOR_RANGE, &value_for_range)) {
313 index = static_cast<int>(value_for_range); 314 index = static_cast<int>(value_for_range);
314 } 315 }
315 break; 316 break;
316 } 317 }
317 } 318 }
318 return index; 319 return index;
319 } 320 }
320 321
321 int BrowserAccessibilityAndroid::GetItemCount() const { 322 int BrowserAccessibilityAndroid::GetItemCount() const {
322 int count = 0; 323 int count = 0;
323 switch(role()) { 324 switch(GetRole()) {
324 case ui::AX_ROLE_LIST: 325 case ui::AX_ROLE_LIST:
325 case ui::AX_ROLE_LIST_BOX: 326 case ui::AX_ROLE_LIST_BOX:
326 count = PlatformChildCount(); 327 count = PlatformChildCount();
327 break; 328 break;
328 case ui::AX_ROLE_SLIDER: 329 case ui::AX_ROLE_SLIDER:
329 case ui::AX_ROLE_PROGRESS_INDICATOR: { 330 case ui::AX_ROLE_PROGRESS_INDICATOR: {
330 float max_value_for_range; 331 float max_value_for_range;
331 if (GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE, 332 if (GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE,
332 &max_value_for_range)) { 333 &max_value_for_range)) {
333 count = static_cast<int>(max_value_for_range); 334 count = static_cast<int>(max_value_for_range);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 else if (live == "assertive") 473 else if (live == "assertive")
473 return ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_ASSERTIVE; 474 return ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_ASSERTIVE;
474 return ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_NONE; 475 return ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_NONE;
475 } 476 }
476 477
477 int BrowserAccessibilityAndroid::AndroidRangeType() const { 478 int BrowserAccessibilityAndroid::AndroidRangeType() const {
478 return ANDROID_VIEW_ACCESSIBILITY_RANGE_TYPE_FLOAT; 479 return ANDROID_VIEW_ACCESSIBILITY_RANGE_TYPE_FLOAT;
479 } 480 }
480 481
481 int BrowserAccessibilityAndroid::RowCount() const { 482 int BrowserAccessibilityAndroid::RowCount() const {
482 if (role() == ui::AX_ROLE_GRID || 483 if (GetRole() == ui::AX_ROLE_GRID ||
483 role() == ui::AX_ROLE_TABLE) { 484 GetRole() == ui::AX_ROLE_TABLE) {
484 return CountChildrenWithRole(ui::AX_ROLE_ROW); 485 return CountChildrenWithRole(ui::AX_ROLE_ROW);
485 } 486 }
486 487
487 if (role() == ui::AX_ROLE_LIST || 488 if (GetRole() == ui::AX_ROLE_LIST ||
488 role() == ui::AX_ROLE_LIST_BOX || 489 GetRole() == ui::AX_ROLE_LIST_BOX ||
489 role() == ui::AX_ROLE_TREE) { 490 GetRole() == ui::AX_ROLE_TREE) {
490 return PlatformChildCount(); 491 return PlatformChildCount();
491 } 492 }
492 493
493 return 0; 494 return 0;
494 } 495 }
495 496
496 int BrowserAccessibilityAndroid::ColumnCount() const { 497 int BrowserAccessibilityAndroid::ColumnCount() const {
497 if (role() == ui::AX_ROLE_GRID || 498 if (GetRole() == ui::AX_ROLE_GRID ||
498 role() == ui::AX_ROLE_TABLE) { 499 GetRole() == ui::AX_ROLE_TABLE) {
499 return CountChildrenWithRole(ui::AX_ROLE_COLUMN); 500 return CountChildrenWithRole(ui::AX_ROLE_COLUMN);
500 } 501 }
501 return 0; 502 return 0;
502 } 503 }
503 504
504 int BrowserAccessibilityAndroid::RowIndex() const { 505 int BrowserAccessibilityAndroid::RowIndex() const {
505 if (role() == ui::AX_ROLE_LIST_ITEM || 506 if (GetRole() == ui::AX_ROLE_LIST_ITEM ||
506 role() == ui::AX_ROLE_LIST_BOX_OPTION || 507 GetRole() == ui::AX_ROLE_LIST_BOX_OPTION ||
507 role() == ui::AX_ROLE_TREE_ITEM) { 508 GetRole() == ui::AX_ROLE_TREE_ITEM) {
508 return index_in_parent(); 509 return GetIndexInParent();
509 } 510 }
510 511
511 return GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX); 512 return GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX);
512 } 513 }
513 514
514 int BrowserAccessibilityAndroid::RowSpan() const { 515 int BrowserAccessibilityAndroid::RowSpan() const {
515 return GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_SPAN); 516 return GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_SPAN);
516 } 517 }
517 518
518 int BrowserAccessibilityAndroid::ColumnIndex() const { 519 int BrowserAccessibilityAndroid::ColumnIndex() const {
(...skipping 12 matching lines...) Expand all
531 return GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE); 532 return GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE);
532 } 533 }
533 534
534 float BrowserAccessibilityAndroid::RangeCurrentValue() const { 535 float BrowserAccessibilityAndroid::RangeCurrentValue() const {
535 return GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE); 536 return GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE);
536 } 537 }
537 538
538 bool BrowserAccessibilityAndroid::HasFocusableChild() const { 539 bool BrowserAccessibilityAndroid::HasFocusableChild() const {
539 // This is called from PlatformIsLeaf, so don't call PlatformChildCount 540 // This is called from PlatformIsLeaf, so don't call PlatformChildCount
540 // from within this! 541 // from within this!
541 for (uint32 i = 0; i < child_count(); i++) { 542 for (uint32 i = 0; i < InternalChildCount(); i++) {
542 BrowserAccessibility* child = children()[i]; 543 BrowserAccessibility* child = InternalGetChild(i);
543 if (child->HasState(ui::AX_STATE_FOCUSABLE)) 544 if (child->HasState(ui::AX_STATE_FOCUSABLE))
544 return true; 545 return true;
545 if (static_cast<BrowserAccessibilityAndroid*>(child)->HasFocusableChild()) 546 if (static_cast<BrowserAccessibilityAndroid*>(child)->HasFocusableChild())
546 return true; 547 return true;
547 } 548 }
548 return false; 549 return false;
549 } 550 }
550 551
551 bool BrowserAccessibilityAndroid::HasOnlyStaticTextChildren() const { 552 bool BrowserAccessibilityAndroid::HasOnlyStaticTextChildren() const {
552 // This is called from PlatformIsLeaf, so don't call PlatformChildCount 553 // This is called from PlatformIsLeaf, so don't call PlatformChildCount
553 // from within this! 554 // from within this!
554 for (uint32 i = 0; i < child_count(); i++) { 555 for (uint32 i = 0; i < InternalChildCount(); i++) {
555 BrowserAccessibility* child = children()[i]; 556 BrowserAccessibility* child = InternalGetChild(i);
556 if (child->role() != ui::AX_ROLE_STATIC_TEXT) 557 if (child->GetRole() != ui::AX_ROLE_STATIC_TEXT)
557 return false; 558 return false;
558 } 559 }
559 return true; 560 return true;
560 } 561 }
561 562
562 bool BrowserAccessibilityAndroid::IsIframe() const { 563 bool BrowserAccessibilityAndroid::IsIframe() const {
563 base::string16 html_tag = GetString16Attribute( 564 base::string16 html_tag = GetString16Attribute(
564 ui::AX_ATTR_HTML_TAG); 565 ui::AX_ATTR_HTML_TAG);
565 return html_tag == base::ASCIIToUTF16("iframe"); 566 return html_tag == base::ASCIIToUTF16("iframe");
566 } 567 }
567 568
568 void BrowserAccessibilityAndroid::PostInitialize() { 569 void BrowserAccessibilityAndroid::PostInitialize() {
569 BrowserAccessibility::PostInitialize(); 570 BrowserAccessibility::PostInitialize();
570 571
571 if (IsEditableText()) { 572 if (IsEditableText()) {
572 if (base::UTF8ToUTF16(value()) != new_value_) { 573 if (base::UTF8ToUTF16(value()) != new_value_) {
573 old_value_ = new_value_; 574 old_value_ = new_value_;
574 new_value_ = base::UTF8ToUTF16(value()); 575 new_value_ = base::UTF8ToUTF16(value());
575 } 576 }
576 } 577 }
577 578
578 if (role() == ui::AX_ROLE_ALERT && first_time_) 579 if (GetRole() == ui::AX_ROLE_ALERT && first_time_)
579 manager()->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, this); 580 manager()->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, this);
580 581
581 base::string16 live; 582 base::string16 live;
582 if (GetString16Attribute( 583 if (GetString16Attribute(
583 ui::AX_ATTR_CONTAINER_LIVE_STATUS, &live)) { 584 ui::AX_ATTR_CONTAINER_LIVE_STATUS, &live)) {
584 NotifyLiveRegionUpdate(live); 585 NotifyLiveRegionUpdate(live);
585 } 586 }
586 587
587 first_time_ = false; 588 first_time_ = false;
588 } 589 }
(...skipping 10 matching lines...) Expand all
599 manager()->NotifyAccessibilityEvent(ui::AX_EVENT_SHOW, 600 manager()->NotifyAccessibilityEvent(ui::AX_EVENT_SHOW,
600 this); 601 this);
601 } 602 }
602 cached_text_ = text; 603 cached_text_ = text;
603 } 604 }
604 } 605 }
605 606
606 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { 607 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const {
607 int count = 0; 608 int count = 0;
608 for (uint32 i = 0; i < PlatformChildCount(); i++) { 609 for (uint32 i = 0; i < PlatformChildCount(); i++) {
609 if (PlatformGetChild(i)->role() == role) 610 if (PlatformGetChild(i)->GetRole() == role)
610 count++; 611 count++;
611 } 612 }
612 return count; 613 return count;
613 } 614 }
614 615
615 } // namespace content 616 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/accessibility/browser_accessibility.cc ('k') | content/browser/accessibility/browser_accessibility_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698