Rename Animate as Begin(Main)Frame
[chromium-blink-merge.git] / content / browser / accessibility / browser_accessibility_android.cc
blob8a8514a0d80a84db258d2a05348513a1e9ac59fc
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
3 // found in the LICENSE file.
5 #include "content/browser/accessibility/browser_accessibility_android.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "content/browser/accessibility/browser_accessibility_manager_android.h"
9 #include "content/common/accessibility_messages.h"
11 namespace {
13 // These are enums from android.text.InputType in Java:
14 enum {
15 ANDROID_TEXT_INPUTTYPE_TYPE_NULL = 0,
16 ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME = 0x4,
17 ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME_DATE = 0x14,
18 ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME_TIME = 0x24,
19 ANDROID_TEXT_INPUTTYPE_TYPE_NUMBER = 0x2,
20 ANDROID_TEXT_INPUTTYPE_TYPE_PHONE = 0x3,
21 ANDROID_TEXT_INPUTTYPE_TYPE_TEXT = 0x1,
22 ANDROID_TEXT_INPUTTYPE_TYPE_TEXT_URI = 0x11,
23 ANDROID_TEXT_INPUTTYPE_TYPE_TEXT_WEB_EDIT_TEXT = 0xa1,
24 ANDROID_TEXT_INPUTTYPE_TYPE_TEXT_WEB_EMAIL = 0xd1,
25 ANDROID_TEXT_INPUTTYPE_TYPE_TEXT_WEB_PASSWORD = 0xe1
28 // These are enums from android.view.View in Java:
29 enum {
30 ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_NONE = 0,
31 ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_POLITE = 1,
32 ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_ASSERTIVE = 2
35 // These are enums from
36 // android.view.accessibility.AccessibilityNodeInfo.RangeInfo in Java:
37 enum {
38 ANDROID_VIEW_ACCESSIBILITY_RANGE_TYPE_FLOAT = 1
41 } // namespace
43 namespace content {
45 // static
46 BrowserAccessibility* BrowserAccessibility::Create() {
47 return new BrowserAccessibilityAndroid();
50 BrowserAccessibilityAndroid::BrowserAccessibilityAndroid() {
51 first_time_ = true;
54 bool BrowserAccessibilityAndroid::IsNative() const {
55 return true;
58 bool BrowserAccessibilityAndroid::PlatformIsLeaf() const {
59 if (InternalChildCount() == 0)
60 return true;
62 // Iframes are always allowed to contain children.
63 if (IsIframe() ||
64 GetRole() == ui::AX_ROLE_ROOT_WEB_AREA ||
65 GetRole() == ui::AX_ROLE_WEB_AREA) {
66 return false;
69 // If it has a focusable child, we definitely can't leave out children.
70 if (HasFocusableChild())
71 return false;
73 // Headings with text can drop their children.
74 base::string16 name = GetText();
75 if (GetRole() == ui::AX_ROLE_HEADING && !name.empty())
76 return true;
78 // Focusable nodes with text can drop their children.
79 if (HasState(ui::AX_STATE_FOCUSABLE) && !name.empty())
80 return true;
82 // Nodes with only static text as children can drop their children.
83 if (HasOnlyStaticTextChildren())
84 return true;
86 return BrowserAccessibility::PlatformIsLeaf();
89 bool BrowserAccessibilityAndroid::IsCheckable() const {
90 bool checkable = false;
91 bool is_aria_pressed_defined;
92 bool is_mixed;
93 GetAriaTristate("aria-pressed", &is_aria_pressed_defined, &is_mixed);
94 if (GetRole() == ui::AX_ROLE_CHECK_BOX ||
95 GetRole() == ui::AX_ROLE_RADIO_BUTTON ||
96 is_aria_pressed_defined) {
97 checkable = true;
99 if (HasState(ui::AX_STATE_CHECKED))
100 checkable = true;
101 return checkable;
104 bool BrowserAccessibilityAndroid::IsChecked() const {
105 return HasState(ui::AX_STATE_CHECKED);
108 bool BrowserAccessibilityAndroid::IsClickable() const {
109 return (PlatformIsLeaf() && !GetText().empty());
112 bool BrowserAccessibilityAndroid::IsCollection() const {
113 return (GetRole() == ui::AX_ROLE_GRID ||
114 GetRole() == ui::AX_ROLE_LIST ||
115 GetRole() == ui::AX_ROLE_LIST_BOX ||
116 GetRole() == ui::AX_ROLE_TABLE ||
117 GetRole() == ui::AX_ROLE_TREE);
120 bool BrowserAccessibilityAndroid::IsCollectionItem() const {
121 return (GetRole() == ui::AX_ROLE_CELL ||
122 GetRole() == ui::AX_ROLE_COLUMN_HEADER ||
123 GetRole() == ui::AX_ROLE_DESCRIPTION_LIST_TERM ||
124 GetRole() == ui::AX_ROLE_LIST_BOX_OPTION ||
125 GetRole() == ui::AX_ROLE_LIST_ITEM ||
126 GetRole() == ui::AX_ROLE_ROW_HEADER ||
127 GetRole() == ui::AX_ROLE_TREE_ITEM);
130 bool BrowserAccessibilityAndroid::IsContentInvalid() const {
131 std::string invalid;
132 return GetHtmlAttribute("aria-invalid", &invalid);
135 bool BrowserAccessibilityAndroid::IsDismissable() const {
136 return false; // No concept of "dismissable" on the web currently.
139 bool BrowserAccessibilityAndroid::IsEnabled() const {
140 return HasState(ui::AX_STATE_ENABLED);
143 bool BrowserAccessibilityAndroid::IsFocusable() const {
144 bool focusable = HasState(ui::AX_STATE_FOCUSABLE);
145 if (IsIframe() ||
146 GetRole() == ui::AX_ROLE_WEB_AREA) {
147 focusable = false;
149 return focusable;
152 bool BrowserAccessibilityAndroid::IsFocused() const {
153 return manager()->GetFocus(manager()->GetRoot()) == this;
156 bool BrowserAccessibilityAndroid::IsHeading() const {
157 return (GetRole() == ui::AX_ROLE_COLUMN_HEADER ||
158 GetRole() == ui::AX_ROLE_HEADING ||
159 GetRole() == ui::AX_ROLE_ROW_HEADER);
162 bool BrowserAccessibilityAndroid::IsHierarchical() const {
163 return (GetRole() == ui::AX_ROLE_LIST ||
164 GetRole() == ui::AX_ROLE_TREE);
167 bool BrowserAccessibilityAndroid::IsLink() const {
168 return GetRole() == ui::AX_ROLE_LINK ||
169 GetRole() == ui::AX_ROLE_IMAGE_MAP_LINK;
172 bool BrowserAccessibilityAndroid::IsMultiLine() const {
173 return GetRole() == ui::AX_ROLE_TEXT_AREA;
176 bool BrowserAccessibilityAndroid::IsPassword() const {
177 return HasState(ui::AX_STATE_PROTECTED);
180 bool BrowserAccessibilityAndroid::IsRangeType() const {
181 return (GetRole() == ui::AX_ROLE_PROGRESS_INDICATOR ||
182 GetRole() == ui::AX_ROLE_SCROLL_BAR ||
183 GetRole() == ui::AX_ROLE_SLIDER);
186 bool BrowserAccessibilityAndroid::IsScrollable() const {
187 int dummy;
188 return GetIntAttribute(ui::AX_ATTR_SCROLL_X_MAX, &dummy);
191 bool BrowserAccessibilityAndroid::IsSelected() const {
192 return HasState(ui::AX_STATE_SELECTED);
195 bool BrowserAccessibilityAndroid::IsVisibleToUser() const {
196 return !HasState(ui::AX_STATE_INVISIBLE);
199 bool BrowserAccessibilityAndroid::CanOpenPopup() const {
200 return HasState(ui::AX_STATE_HASPOPUP);
203 const char* BrowserAccessibilityAndroid::GetClassName() const {
204 const char* class_name = NULL;
206 switch(GetRole()) {
207 case ui::AX_ROLE_EDITABLE_TEXT:
208 case ui::AX_ROLE_SPIN_BUTTON:
209 case ui::AX_ROLE_TEXT_AREA:
210 case ui::AX_ROLE_TEXT_FIELD:
211 class_name = "android.widget.EditText";
212 break;
213 case ui::AX_ROLE_SLIDER:
214 class_name = "android.widget.SeekBar";
215 break;
216 case ui::AX_ROLE_COMBO_BOX:
217 class_name = "android.widget.Spinner";
218 break;
219 case ui::AX_ROLE_BUTTON:
220 case ui::AX_ROLE_MENU_BUTTON:
221 case ui::AX_ROLE_POP_UP_BUTTON:
222 class_name = "android.widget.Button";
223 break;
224 case ui::AX_ROLE_CHECK_BOX:
225 class_name = "android.widget.CheckBox";
226 break;
227 case ui::AX_ROLE_RADIO_BUTTON:
228 class_name = "android.widget.RadioButton";
229 break;
230 case ui::AX_ROLE_TOGGLE_BUTTON:
231 class_name = "android.widget.ToggleButton";
232 break;
233 case ui::AX_ROLE_CANVAS:
234 case ui::AX_ROLE_IMAGE:
235 class_name = "android.widget.Image";
236 break;
237 case ui::AX_ROLE_PROGRESS_INDICATOR:
238 class_name = "android.widget.ProgressBar";
239 break;
240 case ui::AX_ROLE_TAB_LIST:
241 class_name = "android.widget.TabWidget";
242 break;
243 case ui::AX_ROLE_GRID:
244 case ui::AX_ROLE_TABLE:
245 class_name = "android.widget.GridView";
246 break;
247 case ui::AX_ROLE_LIST:
248 case ui::AX_ROLE_LIST_BOX:
249 class_name = "android.widget.ListView";
250 break;
251 case ui::AX_ROLE_DIALOG:
252 class_name = "android.app.Dialog";
253 break;
254 case ui::AX_ROLE_ROOT_WEB_AREA:
255 class_name = "android.webkit.WebView";
256 break;
257 default:
258 class_name = "android.view.View";
259 break;
262 return class_name;
265 base::string16 BrowserAccessibilityAndroid::GetText() const {
266 if (IsIframe() ||
267 GetRole() == ui::AX_ROLE_WEB_AREA) {
268 return base::string16();
271 // See comment in browser_accessibility_win.cc for details.
272 // The difference here is that we can only expose one accessible
273 // name on Android, not 2 or 3 like on Windows or Mac.
275 // The basic rule is: prefer description (aria-labelledby or aria-label),
276 // then help (title), then name (inner text), then value (control value).
277 // However, if title_elem_id is set, that means there's a label element
278 // supplying the name and then name takes precedence over help.
279 // TODO(dmazzoni): clean this up by providing more granular labels in
280 // Blink, making the platform-specific mapping to accessible text simpler.
281 base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION);
282 base::string16 help = GetString16Attribute(ui::AX_ATTR_HELP);
283 int title_elem_id = GetIntAttribute(
284 ui::AX_ATTR_TITLE_UI_ELEMENT);
285 base::string16 text;
286 if (!description.empty())
287 text = description;
288 else if (title_elem_id && !name().empty())
289 text = base::UTF8ToUTF16(name());
290 else if (!help.empty())
291 text = help;
292 else if (!name().empty())
293 text = base::UTF8ToUTF16(name());
294 else if (!value().empty())
295 text = base::UTF8ToUTF16(value());
297 // This is called from PlatformIsLeaf, so don't call PlatformChildCount
298 // from within this!
299 if (text.empty() && HasOnlyStaticTextChildren()) {
300 for (uint32 i = 0; i < InternalChildCount(); i++) {
301 BrowserAccessibility* child = InternalGetChild(i);
302 text += static_cast<BrowserAccessibilityAndroid*>(child)->GetText();
306 switch(GetRole()) {
307 case ui::AX_ROLE_HEADING:
308 // Only append "heading" if this node already has text.
309 if (!text.empty())
310 text += base::ASCIIToUTF16(" Heading");
311 break;
314 if (text.empty() && IsLink()) {
315 base::string16 url = GetString16Attribute(ui::AX_ATTR_URL);
316 // Given a url like http://foo.com/bar/baz.png, just return the
317 // base name, e.g., "baz".
318 int trailing_slashes = 0;
319 while (url.size() - trailing_slashes > 0 &&
320 url[url.size() - trailing_slashes - 1] == '/') {
321 trailing_slashes++;
323 if (trailing_slashes)
324 url = url.substr(0, url.size() - trailing_slashes);
325 size_t slash_index = url.rfind('/');
326 if (slash_index != std::string::npos)
327 url = url.substr(slash_index + 1);
328 size_t dot_index = url.rfind('.');
329 if (dot_index != std::string::npos)
330 url = url.substr(0, dot_index);
331 text = url;
334 return text;
337 int BrowserAccessibilityAndroid::GetItemIndex() const {
338 int index = 0;
339 switch(GetRole()) {
340 case ui::AX_ROLE_LIST_ITEM:
341 case ui::AX_ROLE_LIST_BOX_OPTION:
342 case ui::AX_ROLE_TREE_ITEM:
343 index = GetIndexInParent();
344 break;
345 case ui::AX_ROLE_SLIDER:
346 case ui::AX_ROLE_PROGRESS_INDICATOR: {
347 float value_for_range;
348 if (GetFloatAttribute(
349 ui::AX_ATTR_VALUE_FOR_RANGE, &value_for_range)) {
350 index = static_cast<int>(value_for_range);
352 break;
355 return index;
358 int BrowserAccessibilityAndroid::GetItemCount() const {
359 int count = 0;
360 switch(GetRole()) {
361 case ui::AX_ROLE_LIST:
362 case ui::AX_ROLE_LIST_BOX:
363 count = PlatformChildCount();
364 break;
365 case ui::AX_ROLE_SLIDER:
366 case ui::AX_ROLE_PROGRESS_INDICATOR: {
367 float max_value_for_range;
368 if (GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE,
369 &max_value_for_range)) {
370 count = static_cast<int>(max_value_for_range);
372 break;
375 return count;
378 int BrowserAccessibilityAndroid::GetScrollX() const {
379 int value = 0;
380 GetIntAttribute(ui::AX_ATTR_SCROLL_X, &value);
381 return value;
384 int BrowserAccessibilityAndroid::GetScrollY() const {
385 int value = 0;
386 GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &value);
387 return value;
390 int BrowserAccessibilityAndroid::GetMaxScrollX() const {
391 int value = 0;
392 GetIntAttribute(ui::AX_ATTR_SCROLL_X_MAX, &value);
393 return value;
396 int BrowserAccessibilityAndroid::GetMaxScrollY() const {
397 int value = 0;
398 GetIntAttribute(ui::AX_ATTR_SCROLL_Y_MAX, &value);
399 return value;
402 int BrowserAccessibilityAndroid::GetTextChangeFromIndex() const {
403 size_t index = 0;
404 while (index < old_value_.length() &&
405 index < new_value_.length() &&
406 old_value_[index] == new_value_[index]) {
407 index++;
409 return index;
412 int BrowserAccessibilityAndroid::GetTextChangeAddedCount() const {
413 size_t old_len = old_value_.length();
414 size_t new_len = new_value_.length();
415 size_t left = 0;
416 while (left < old_len &&
417 left < new_len &&
418 old_value_[left] == new_value_[left]) {
419 left++;
421 size_t right = 0;
422 while (right < old_len &&
423 right < new_len &&
424 old_value_[old_len - right - 1] == new_value_[new_len - right - 1]) {
425 right++;
427 return (new_len - left - right);
430 int BrowserAccessibilityAndroid::GetTextChangeRemovedCount() const {
431 size_t old_len = old_value_.length();
432 size_t new_len = new_value_.length();
433 size_t left = 0;
434 while (left < old_len &&
435 left < new_len &&
436 old_value_[left] == new_value_[left]) {
437 left++;
439 size_t right = 0;
440 while (right < old_len &&
441 right < new_len &&
442 old_value_[old_len - right - 1] == new_value_[new_len - right - 1]) {
443 right++;
445 return (old_len - left - right);
448 base::string16 BrowserAccessibilityAndroid::GetTextChangeBeforeText() const {
449 return old_value_;
452 int BrowserAccessibilityAndroid::GetSelectionStart() const {
453 int sel_start = 0;
454 GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, &sel_start);
455 return sel_start;
458 int BrowserAccessibilityAndroid::GetSelectionEnd() const {
459 int sel_end = 0;
460 GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, &sel_end);
461 return sel_end;
464 int BrowserAccessibilityAndroid::GetEditableTextLength() const {
465 return value().length();
468 int BrowserAccessibilityAndroid::AndroidInputType() const {
469 std::string html_tag = GetStringAttribute(
470 ui::AX_ATTR_HTML_TAG);
471 if (html_tag != "input")
472 return ANDROID_TEXT_INPUTTYPE_TYPE_NULL;
474 std::string type;
475 if (!GetHtmlAttribute("type", &type))
476 return ANDROID_TEXT_INPUTTYPE_TYPE_TEXT;
478 if (type == "" || type == "text" || type == "search")
479 return ANDROID_TEXT_INPUTTYPE_TYPE_TEXT;
480 else if (type == "date")
481 return ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME_DATE;
482 else if (type == "datetime" || type == "datetime-local")
483 return ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME;
484 else if (type == "email")
485 return ANDROID_TEXT_INPUTTYPE_TYPE_TEXT_WEB_EMAIL;
486 else if (type == "month")
487 return ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME_DATE;
488 else if (type == "number")
489 return ANDROID_TEXT_INPUTTYPE_TYPE_NUMBER;
490 else if (type == "password")
491 return ANDROID_TEXT_INPUTTYPE_TYPE_TEXT_WEB_PASSWORD;
492 else if (type == "tel")
493 return ANDROID_TEXT_INPUTTYPE_TYPE_PHONE;
494 else if (type == "time")
495 return ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME_TIME;
496 else if (type == "url")
497 return ANDROID_TEXT_INPUTTYPE_TYPE_TEXT_URI;
498 else if (type == "week")
499 return ANDROID_TEXT_INPUTTYPE_TYPE_DATETIME;
501 return ANDROID_TEXT_INPUTTYPE_TYPE_NULL;
504 int BrowserAccessibilityAndroid::AndroidLiveRegionType() const {
505 std::string live = GetStringAttribute(
506 ui::AX_ATTR_LIVE_STATUS);
507 if (live == "polite")
508 return ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_POLITE;
509 else if (live == "assertive")
510 return ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_ASSERTIVE;
511 return ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_NONE;
514 int BrowserAccessibilityAndroid::AndroidRangeType() const {
515 return ANDROID_VIEW_ACCESSIBILITY_RANGE_TYPE_FLOAT;
518 int BrowserAccessibilityAndroid::RowCount() const {
519 if (GetRole() == ui::AX_ROLE_GRID ||
520 GetRole() == ui::AX_ROLE_TABLE) {
521 return CountChildrenWithRole(ui::AX_ROLE_ROW);
524 if (GetRole() == ui::AX_ROLE_LIST ||
525 GetRole() == ui::AX_ROLE_LIST_BOX ||
526 GetRole() == ui::AX_ROLE_TREE) {
527 return PlatformChildCount();
530 return 0;
533 int BrowserAccessibilityAndroid::ColumnCount() const {
534 if (GetRole() == ui::AX_ROLE_GRID ||
535 GetRole() == ui::AX_ROLE_TABLE) {
536 return CountChildrenWithRole(ui::AX_ROLE_COLUMN);
538 return 0;
541 int BrowserAccessibilityAndroid::RowIndex() const {
542 if (GetRole() == ui::AX_ROLE_LIST_ITEM ||
543 GetRole() == ui::AX_ROLE_LIST_BOX_OPTION ||
544 GetRole() == ui::AX_ROLE_TREE_ITEM) {
545 return GetIndexInParent();
548 return GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX);
551 int BrowserAccessibilityAndroid::RowSpan() const {
552 return GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_SPAN);
555 int BrowserAccessibilityAndroid::ColumnIndex() const {
556 return GetIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX);
559 int BrowserAccessibilityAndroid::ColumnSpan() const {
560 return GetIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN);
563 float BrowserAccessibilityAndroid::RangeMin() const {
564 return GetFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE);
567 float BrowserAccessibilityAndroid::RangeMax() const {
568 return GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE);
571 float BrowserAccessibilityAndroid::RangeCurrentValue() const {
572 return GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE);
575 bool BrowserAccessibilityAndroid::HasFocusableChild() const {
576 // This is called from PlatformIsLeaf, so don't call PlatformChildCount
577 // from within this!
578 for (uint32 i = 0; i < InternalChildCount(); i++) {
579 BrowserAccessibility* child = InternalGetChild(i);
580 if (child->HasState(ui::AX_STATE_FOCUSABLE))
581 return true;
582 if (static_cast<BrowserAccessibilityAndroid*>(child)->HasFocusableChild())
583 return true;
585 return false;
588 bool BrowserAccessibilityAndroid::HasOnlyStaticTextChildren() const {
589 // This is called from PlatformIsLeaf, so don't call PlatformChildCount
590 // from within this!
591 for (uint32 i = 0; i < InternalChildCount(); i++) {
592 BrowserAccessibility* child = InternalGetChild(i);
593 if (child->GetRole() != ui::AX_ROLE_STATIC_TEXT)
594 return false;
596 return true;
599 bool BrowserAccessibilityAndroid::IsIframe() const {
600 base::string16 html_tag = GetString16Attribute(
601 ui::AX_ATTR_HTML_TAG);
602 return html_tag == base::ASCIIToUTF16("iframe");
605 void BrowserAccessibilityAndroid::OnDataChanged() {
606 BrowserAccessibility::OnDataChanged();
608 if (IsEditableText()) {
609 if (base::UTF8ToUTF16(value()) != new_value_) {
610 old_value_ = new_value_;
611 new_value_ = base::UTF8ToUTF16(value());
615 if (GetRole() == ui::AX_ROLE_ALERT && first_time_)
616 manager()->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, this);
618 base::string16 live;
619 if (GetString16Attribute(
620 ui::AX_ATTR_CONTAINER_LIVE_STATUS, &live)) {
621 NotifyLiveRegionUpdate(live);
624 first_time_ = false;
627 void BrowserAccessibilityAndroid::NotifyLiveRegionUpdate(
628 base::string16& aria_live) {
629 if (!EqualsASCII(aria_live, aria_strings::kAriaLivePolite) &&
630 !EqualsASCII(aria_live, aria_strings::kAriaLiveAssertive))
631 return;
633 base::string16 text = GetText();
634 if (cached_text_ != text) {
635 if (!text.empty()) {
636 manager()->NotifyAccessibilityEvent(ui::AX_EVENT_SHOW,
637 this);
639 cached_text_ = text;
643 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const {
644 int count = 0;
645 for (uint32 i = 0; i < PlatformChildCount(); i++) {
646 if (PlatformGetChild(i)->GetRole() == role)
647 count++;
649 return count;
652 } // namespace content