OLD | NEW |
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/i18n/break_iterator.h" | 7 #include "base/i18n/break_iterator.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 bool is_aria_pressed_defined; | 138 bool is_aria_pressed_defined; |
139 bool is_mixed; | 139 bool is_mixed; |
140 GetAriaTristate("aria-pressed", &is_aria_pressed_defined, &is_mixed); | 140 GetAriaTristate("aria-pressed", &is_aria_pressed_defined, &is_mixed); |
141 if (GetRole() == ui::AX_ROLE_CHECK_BOX || | 141 if (GetRole() == ui::AX_ROLE_CHECK_BOX || |
142 GetRole() == ui::AX_ROLE_RADIO_BUTTON || | 142 GetRole() == ui::AX_ROLE_RADIO_BUTTON || |
143 GetRole() == ui::AX_ROLE_MENU_ITEM_CHECK_BOX || | 143 GetRole() == ui::AX_ROLE_MENU_ITEM_CHECK_BOX || |
144 GetRole() == ui::AX_ROLE_MENU_ITEM_RADIO || | 144 GetRole() == ui::AX_ROLE_MENU_ITEM_RADIO || |
145 is_aria_pressed_defined) { | 145 is_aria_pressed_defined) { |
146 checkable = true; | 146 checkable = true; |
147 } | 147 } |
148 if (HasState(ui::AX_STATE_CHECKED)) | 148 // TODO(aleventhal) does this ever happen when checkable is not true yet? |
| 149 if (HasIntAttribute(ui::AX_ATTR_CHECKED_STATE)) |
149 checkable = true; | 150 checkable = true; |
150 return checkable; | 151 return checkable; |
151 } | 152 } |
152 | 153 |
153 bool BrowserAccessibilityAndroid::IsChecked() const { | 154 bool BrowserAccessibilityAndroid::IsChecked() const { |
154 return (HasState(ui::AX_STATE_CHECKED) || HasState(ui::AX_STATE_PRESSED)); | 155 const auto checked_state = static_cast<ui::AXCheckedState>( |
| 156 GetIntAttribute(ui::AX_ATTR_CHECKED_STATE)); |
| 157 return (checked_state == ui::AX_CHECKED_STATE_TRUE || |
| 158 HasState(ui::AX_STATE_PRESSED)); |
155 } | 159 } |
156 | 160 |
157 bool BrowserAccessibilityAndroid::IsClickable() const { | 161 bool BrowserAccessibilityAndroid::IsClickable() const { |
158 // If it has a default action, it's definitely clickable. | 162 // If it has a default action, it's definitely clickable. |
159 if (HasIntAttribute(ui::AX_ATTR_ACTION)) | 163 if (HasIntAttribute(ui::AX_ATTR_ACTION)) |
160 return true; | 164 return true; |
161 | 165 |
162 // Otherwise return true if it's focusable, but skip web areas and iframes. | 166 // Otherwise return true if it's focusable, but skip web areas and iframes. |
163 if (IsIframe() || (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA)) | 167 if (IsIframe() || (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA)) |
164 return false; | 168 return false; |
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { | 1507 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { |
1504 int count = 0; | 1508 int count = 0; |
1505 for (uint32_t i = 0; i < PlatformChildCount(); i++) { | 1509 for (uint32_t i = 0; i < PlatformChildCount(); i++) { |
1506 if (PlatformGetChild(i)->GetRole() == role) | 1510 if (PlatformGetChild(i)->GetRole() == role) |
1507 count++; | 1511 count++; |
1508 } | 1512 } |
1509 return count; | 1513 return count; |
1510 } | 1514 } |
1511 | 1515 |
1512 } // namespace content | 1516 } // namespace content |
OLD | NEW |