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

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

Issue 1046883002: Use multiline attribute to check for IA2_STATE_MULTILINE. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing textarea Created 5 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
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/i18n/break_iterator.h" 7 #include "base/i18n/break_iterator.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 bool BrowserAccessibilityAndroid::IsContentInvalid() const { 165 bool BrowserAccessibilityAndroid::IsContentInvalid() const {
166 std::string invalid; 166 std::string invalid;
167 return GetHtmlAttribute("aria-invalid", &invalid); 167 return GetHtmlAttribute("aria-invalid", &invalid);
168 } 168 }
169 169
170 bool BrowserAccessibilityAndroid::IsDismissable() const { 170 bool BrowserAccessibilityAndroid::IsDismissable() const {
171 return false; // No concept of "dismissable" on the web currently. 171 return false; // No concept of "dismissable" on the web currently.
172 } 172 }
173 173
174 bool BrowserAccessibilityAndroid::IsEditableText() const { 174 bool BrowserAccessibilityAndroid::IsEditableText() const {
175 return (GetRole() == ui::AX_ROLE_TEXT_AREA || 175 return GetRole() == ui::AX_ROLE_TEXT_FIELD;
176 GetRole() == ui::AX_ROLE_TEXT_FIELD);
177 } 176 }
178 177
179 bool BrowserAccessibilityAndroid::IsEnabled() const { 178 bool BrowserAccessibilityAndroid::IsEnabled() const {
180 return HasState(ui::AX_STATE_ENABLED); 179 return HasState(ui::AX_STATE_ENABLED);
181 } 180 }
182 181
183 bool BrowserAccessibilityAndroid::IsFocusable() const { 182 bool BrowserAccessibilityAndroid::IsFocusable() const {
184 bool focusable = HasState(ui::AX_STATE_FOCUSABLE); 183 bool focusable = HasState(ui::AX_STATE_FOCUSABLE);
185 if (IsIframe() || 184 if (IsIframe() ||
186 GetRole() == ui::AX_ROLE_WEB_AREA) { 185 GetRole() == ui::AX_ROLE_WEB_AREA) {
(...skipping 22 matching lines...) Expand all
209 GetRole() == ui::AX_ROLE_DESCRIPTION_LIST || 208 GetRole() == ui::AX_ROLE_DESCRIPTION_LIST ||
210 GetRole() == ui::AX_ROLE_TREE); 209 GetRole() == ui::AX_ROLE_TREE);
211 } 210 }
212 211
213 bool BrowserAccessibilityAndroid::IsLink() const { 212 bool BrowserAccessibilityAndroid::IsLink() const {
214 return (GetRole() == ui::AX_ROLE_LINK || 213 return (GetRole() == ui::AX_ROLE_LINK ||
215 GetRole() == ui::AX_ROLE_IMAGE_MAP_LINK); 214 GetRole() == ui::AX_ROLE_IMAGE_MAP_LINK);
216 } 215 }
217 216
218 bool BrowserAccessibilityAndroid::IsMultiLine() const { 217 bool BrowserAccessibilityAndroid::IsMultiLine() const {
219 return GetRole() == ui::AX_ROLE_TEXT_AREA; 218 return HasState(ui::AX_STATE_MULTILINE);
220 } 219 }
221 220
222 bool BrowserAccessibilityAndroid::IsPassword() const { 221 bool BrowserAccessibilityAndroid::IsPassword() const {
223 return HasState(ui::AX_STATE_PROTECTED); 222 return HasState(ui::AX_STATE_PROTECTED);
224 } 223 }
225 224
226 bool BrowserAccessibilityAndroid::IsRangeType() const { 225 bool BrowserAccessibilityAndroid::IsRangeType() const {
227 return (GetRole() == ui::AX_ROLE_PROGRESS_INDICATOR || 226 return (GetRole() == ui::AX_ROLE_PROGRESS_INDICATOR ||
228 GetRole() == ui::AX_ROLE_METER || 227 GetRole() == ui::AX_ROLE_METER ||
229 GetRole() == ui::AX_ROLE_SCROLL_BAR || 228 GetRole() == ui::AX_ROLE_SCROLL_BAR ||
(...skipping 20 matching lines...) Expand all
250 bool BrowserAccessibilityAndroid::CanOpenPopup() const { 249 bool BrowserAccessibilityAndroid::CanOpenPopup() const {
251 return HasState(ui::AX_STATE_HASPOPUP); 250 return HasState(ui::AX_STATE_HASPOPUP);
252 } 251 }
253 252
254 const char* BrowserAccessibilityAndroid::GetClassName() const { 253 const char* BrowserAccessibilityAndroid::GetClassName() const {
255 const char* class_name = NULL; 254 const char* class_name = NULL;
256 255
257 switch (GetRole()) { 256 switch (GetRole()) {
258 case ui::AX_ROLE_SEARCH_BOX: 257 case ui::AX_ROLE_SEARCH_BOX:
259 case ui::AX_ROLE_SPIN_BUTTON: 258 case ui::AX_ROLE_SPIN_BUTTON:
260 case ui::AX_ROLE_TEXT_AREA:
261 case ui::AX_ROLE_TEXT_FIELD: 259 case ui::AX_ROLE_TEXT_FIELD:
262 class_name = "android.widget.EditText"; 260 class_name = "android.widget.EditText";
263 break; 261 break;
264 case ui::AX_ROLE_SLIDER: 262 case ui::AX_ROLE_SLIDER:
265 class_name = "android.widget.SeekBar"; 263 class_name = "android.widget.SeekBar";
266 break; 264 break;
267 case ui::AX_ROLE_COLOR_WELL: 265 case ui::AX_ROLE_COLOR_WELL:
268 case ui::AX_ROLE_COMBO_BOX: 266 case ui::AX_ROLE_COMBO_BOX:
269 case ui::AX_ROLE_DATE: 267 case ui::AX_ROLE_DATE:
270 case ui::AX_ROLE_POP_UP_BUTTON: 268 case ui::AX_ROLE_POP_UP_BUTTON:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 // First, always return the |value| attribute if this is an 336 // First, always return the |value| attribute if this is an
339 // input field. 337 // input field.
340 base::string16 value = GetString16Attribute(ui::AX_ATTR_VALUE); 338 base::string16 value = GetString16Attribute(ui::AX_ATTR_VALUE);
341 if (!value.empty()) { 339 if (!value.empty()) {
342 if (HasState(ui::AX_STATE_EDITABLE)) 340 if (HasState(ui::AX_STATE_EDITABLE))
343 return value; 341 return value;
344 342
345 switch (GetRole()) { 343 switch (GetRole()) {
346 case ui::AX_ROLE_COMBO_BOX: 344 case ui::AX_ROLE_COMBO_BOX:
347 case ui::AX_ROLE_POP_UP_BUTTON: 345 case ui::AX_ROLE_POP_UP_BUTTON:
348 case ui::AX_ROLE_TEXT_AREA:
349 case ui::AX_ROLE_TEXT_FIELD: 346 case ui::AX_ROLE_TEXT_FIELD:
350 return value; 347 return value;
351 } 348 }
352 } 349 }
353 350
354 // For color wells, the color is stored in separate attributes. 351 // For color wells, the color is stored in separate attributes.
355 // Perhaps we could return color names in the future? 352 // Perhaps we could return color names in the future?
356 if (GetRole() == ui::AX_ROLE_COLOR_WELL) { 353 if (GetRole() == ui::AX_ROLE_COLOR_WELL) {
357 int red = GetIntAttribute(ui::AX_ATTR_COLOR_VALUE_RED); 354 int red = GetIntAttribute(ui::AX_ATTR_COLOR_VALUE_RED);
358 int green = GetIntAttribute(ui::AX_ATTR_COLOR_VALUE_GREEN); 355 int green = GetIntAttribute(ui::AX_ATTR_COLOR_VALUE_GREEN);
(...skipping 15 matching lines...) Expand all
374 // title_elem_id is set, that means there's a label element 371 // title_elem_id is set, that means there's a label element
375 // supplying the name and then name takes precedence over help. 372 // supplying the name and then name takes precedence over help.
376 // TODO(dmazzoni): clean this up by providing more granular labels in 373 // TODO(dmazzoni): clean this up by providing more granular labels in
377 // Blink, making the platform-specific mapping to accessible text simpler. 374 // Blink, making the platform-specific mapping to accessible text simpler.
378 base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION); 375 base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION);
379 base::string16 help = GetString16Attribute(ui::AX_ATTR_HELP); 376 base::string16 help = GetString16Attribute(ui::AX_ATTR_HELP);
380 377
381 base::string16 placeholder; 378 base::string16 placeholder;
382 switch (GetRole()) { 379 switch (GetRole()) {
383 case ui::AX_ROLE_DATE: 380 case ui::AX_ROLE_DATE:
384 case ui::AX_ROLE_TEXT_AREA:
385 case ui::AX_ROLE_TEXT_FIELD: 381 case ui::AX_ROLE_TEXT_FIELD:
386 case ui::AX_ROLE_TIME: 382 case ui::AX_ROLE_TIME:
387 GetHtmlAttribute("placeholder", &placeholder); 383 GetHtmlAttribute("placeholder", &placeholder);
388 } 384 }
389 385
390 int title_elem_id = GetIntAttribute( 386 int title_elem_id = GetIntAttribute(
391 ui::AX_ATTR_TITLE_UI_ELEMENT); 387 ui::AX_ATTR_TITLE_UI_ELEMENT);
392 base::string16 text; 388 base::string16 text;
393 if (!description.empty()) 389 if (!description.empty())
394 text = description; 390 text = description;
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { 875 int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const {
880 int count = 0; 876 int count = 0;
881 for (uint32 i = 0; i < PlatformChildCount(); i++) { 877 for (uint32 i = 0; i < PlatformChildCount(); i++) {
882 if (PlatformGetChild(i)->GetRole() == role) 878 if (PlatformGetChild(i)->GetRole() == role)
883 count++; 879 count++;
884 } 880 }
885 return count; 881 return count;
886 } 882 }
887 883
888 } // namespace content 884 } // 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