Commit 40a9583e authored by Hui Shu's avatar Hui Shu Committed by Android (Google) Code Review
Browse files

Merge "Accessible name of text fields on Android should prefer field value" into lmp-dev

parents 3dfff5ce 3ba7d4f0
......@@ -271,10 +271,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.
......
......@@ -475,6 +475,10 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
RunTest(FILE_PATH_LITERAL("input-text-name-calc.html"));
}
IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityInputTextValue) {
RunTest(FILE_PATH_LITERAL("input-text-value.html"));
}
// crbug.com/98976 will cause new elements to be added to the Blink a11y tree
// Re-baseline after the Blink change goes in
IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
......
android.webkit.WebView focusable focused scrollable
android.view.View
android.view.View clickable name='l1'
android.widget.EditText editable_text focusable input_type=1
android.view.View clickable name='l2'
android.widget.EditText clickable editable_text focusable name='value' input_type=1
android.widget.EditText clickable editable_text focusable name='l2' input_type=1
android.widget.EditText clickable editable_text focusable name='value' input_type=1
android.view.View clickable name='Email'
android.widget.EditText clickable editable_text focusable name='Email' input_type=1
android.widget.EditText clickable editable_text focusable name='value' input_type=1
android.widget.EditText clickable editable_text focusable multiline name='l5'
android.widget.EditText clickable editable_text focusable multiline name='Value'
#<skip -- need to generate>
#<skip -- need to generate>
<!--
@WIN-ALLOW:description*
-->
<html>
<body>
<label for="i1">l1</label>
<input id="i1">
<label for="i2">l2</label>
<input id="i2" value="value">
<input aria-label="l2">
<input aria-label="l2" value="value">
<label id="l3">Email</label>
<span id="l4"></span>
<input aria-labelledby="l3 42">
<input aria-labelledby="l3 l4" value="value">
<textarea aria-label="l5"></textarea>
<textarea aria-label="l6">Value</textarea>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment