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

Unified Diff: content/browser/accessibility/browser_accessibility_android.cc

Issue 661393005: Accessible name of text fields on Android should prefer field value (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scroll_to_make_visible
Patch Set: Remove extra line on win Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/accessibility/dump_accessibility_tree_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/accessibility/browser_accessibility_android.cc
diff --git a/content/browser/accessibility/browser_accessibility_android.cc b/content/browser/accessibility/browser_accessibility_android.cc
index dd1511d58de3308a89c7205f89997b717e649211..4ff8cfe27cf8e038bc9d903b758fabd3f0863fd5 100644
--- a/content/browser/accessibility/browser_accessibility_android.cc
+++ b/content/browser/accessibility/browser_accessibility_android.cc
@@ -280,10 +280,21 @@ base::string16 BrowserAccessibilityAndroid::GetText() const {
// See comment in browser_accessibility_win.cc for details.
// The difference here is that we can only expose one accessible
// name on Android, not 2 or 3 like on Windows or Mac.
- //
- // The basic rule is: prefer description (aria-labelledby or aria-label),
- // then help (title), then name (inner text), then value (control value).
- // However, if title_elem_id is set, that means there's a label element
+
+ // First, always return the |value| attribute if this is an
+ // accessible text.
+ if (!value().empty() &&
+ (GetRole() == ui::AX_ROLE_EDITABLE_TEXT ||
+ GetRole() == ui::AX_ROLE_TEXT_AREA ||
+ GetRole() == ui::AX_ROLE_TEXT_FIELD ||
+ HasState(ui::AX_STATE_EDITABLE))) {
+ return base::UTF8ToUTF16(value());
+ }
+
+ // If there's no text value, the basic rule is: prefer description
+ // (aria-labelledby or aria-label), then help (title), then name
+ // (inner text), then value (control value). However, if
+ // title_elem_id is set, that means there's a label element
// supplying the name and then name takes precedence over help.
// TODO(dmazzoni): clean this up by providing more granular labels in
// Blink, making the platform-specific mapping to accessible text simpler.
« no previous file with comments | « no previous file | content/browser/accessibility/dump_accessibility_tree_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698