Commit b2cb7a66 authored by Dominic Mazzoni's avatar Dominic Mazzoni Committed by Commit Bot

Android accessible hint text should include placeholder.

Previously a text field's placeholder was exposed as the
hint in many circumstances, but a field that had
aria-describedby would override the placeholder.

Update the logic so that the placeholder text is
always included in the hint text for a node.

Bug: 677147
Change-Id: I15c7cfede914db6096d88039213793ec2eaa8ad4
Reviewed-on: https://chromium-review.googlesource.com/c/1385724
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#622150}
parent 8abb2b7c
...@@ -486,21 +486,32 @@ base::string16 BrowserAccessibilityAndroid::GetText() const { ...@@ -486,21 +486,32 @@ base::string16 BrowserAccessibilityAndroid::GetText() const {
} }
base::string16 BrowserAccessibilityAndroid::GetHint() const { base::string16 BrowserAccessibilityAndroid::GetHint() const {
base::string16 description = std::vector<base::string16> strings;
GetString16Attribute(ax::mojom::StringAttribute::kDescription);
// If we're returning the value as the main text, then return both the // If we're returning the value as the main text, the name needs to be
// accessible name and description as the hint. // part of the hint.
if (ShouldExposeValueAsName()) { if (ShouldExposeValueAsName()) {
base::string16 name = base::string16 name =
GetString16Attribute(ax::mojom::StringAttribute::kName); GetString16Attribute(ax::mojom::StringAttribute::kName);
if (!name.empty() && !description.empty()) if (!name.empty())
return name + base::ASCIIToUTF16(" ") + description; strings.push_back(name);
else if (!name.empty()) }
return name;
if (GetData().GetNameFrom() != ax::mojom::NameFrom::kPlaceholder &&
GetData().GetIntAttribute(ax::mojom::IntAttribute::kDescriptionFrom) !=
static_cast<int32_t>(ax::mojom::DescriptionFrom::kPlaceholder)) {
base::string16 placeholder =
GetString16Attribute(ax::mojom::StringAttribute::kPlaceholder);
if (!placeholder.empty())
strings.push_back(placeholder);
} }
return description; base::string16 description =
GetString16Attribute(ax::mojom::StringAttribute::kDescription);
if (!description.empty())
strings.push_back(description);
return base::JoinString(strings, base::ASCIIToUTF16(" "));
} }
std::string BrowserAccessibilityAndroid::GetRoleString() const { std::string BrowserAccessibilityAndroid::GetRoleString() const {
......
android.webkit.WebView focusable focused scrollable android.webkit.WebView focusable focused scrollable
++android.widget.EditText clickable editable_text focusable hint='aria-placeholder1' input_type=1 ++android.widget.EditText clickable editable_text focusable hint='aria-placeholder1' input_type=1
++android.widget.EditText clickable editable_text focusable hint='placeholder2' input_type=1 ++android.widget.EditText clickable editable_text focusable hint='placeholder2' input_type=1
++android.widget.EditText clickable editable_text focusable hint='aria-label3' input_type=1 ++android.widget.EditText clickable editable_text focusable hint='aria-label3 placeholder3' input_type=1
++android.widget.EditText clickable editable_text focusable hint='aria-label4' input_type=1 ++android.widget.EditText clickable editable_text focusable hint='aria-label4 aria-placeholder4' input_type=1
++android.widget.EditText clickable editable_text focusable hint='aria-label5 aria-description5' input_type=1 ++android.widget.EditText clickable editable_text focusable hint='aria-label5 placeholder5 aria-description5' input_type=1
++android.view.View name='aria-description5' ++android.view.View name='aria-description5'
++android.widget.EditText clickable editable_text focusable hint='aria-placeholder6 title6' input_type=1 ++android.widget.EditText clickable editable_text focusable hint='aria-placeholder6 title6' input_type=1
\ No newline at end of file
...@@ -7,4 +7,5 @@ android.webkit.WebView focusable focused scrollable ...@@ -7,4 +7,5 @@ android.webkit.WebView focusable focused scrollable
++android.widget.EditText clickable editable_text focusable hint='ARIA Placeholder4a' input_type=1 ++android.widget.EditText clickable editable_text focusable hint='ARIA Placeholder4a' input_type=1
++android.widget.EditText clickable editable_text focusable hint='Placeholder4b' input_type=1 ++android.widget.EditText clickable editable_text focusable hint='Placeholder4b' input_type=1
++android.widget.EditText clickable editable_text focusable hint='Placeholder5 Title5' input_type=1 ++android.widget.EditText clickable editable_text focusable hint='Placeholder5 Title5' input_type=1
++android.widget.EditText clickable editable_text focusable hint='LabelledBy6 DescribedBy6' input_type=1 ++android.widget.EditText clickable editable_text focusable hint='LabelledBy6 DescribedBy6' input_type=1
\ No newline at end of file ++android.widget.EditText clickable editable_text focusable hint='AriaLabel7 Placeholder7 DescribedBy7' input_type=1
\ No newline at end of file
...@@ -8,3 +8,4 @@ ...@@ -8,3 +8,4 @@
++[entry] name='Placeholder4b' explicit-name:true ++[entry] name='Placeholder4b' explicit-name:true
++[entry] name='Placeholder5' description='Title5' explicit-name:true ++[entry] name='Placeholder5' description='Title5' explicit-name:true
++[entry] name='LabelledBy6' description='DescribedBy6' explicit-name:true ++[entry] name='LabelledBy6' description='DescribedBy6' explicit-name:true
++[entry] name='AriaLabel7' description='DescribedBy7' explicit-name:true
\ No newline at end of file
...@@ -16,4 +16,6 @@ rootWebArea ...@@ -16,4 +16,6 @@ rootWebArea
++textField description='Title5' name='Placeholder5' descriptionFrom=attribute ++textField description='Title5' name='Placeholder5' descriptionFrom=attribute
++++genericContainer ++++genericContainer
++textField description='DescribedBy6' name='LabelledBy6' descriptionFrom=relatedElement ++textField description='DescribedBy6' name='LabelledBy6' descriptionFrom=relatedElement
++++genericContainer
++textField description='DescribedBy7' name='AriaLabel7' descriptionFrom=relatedElement
++++genericContainer ++++genericContainer
\ No newline at end of file
...@@ -7,4 +7,5 @@ ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE ...@@ -7,4 +7,5 @@ ROLE_SYSTEM_DOCUMENT READONLY FOCUSABLE
++ROLE_SYSTEM_TEXT name='ARIA Placeholder4a' FOCUSABLE explicit-name:true ++ROLE_SYSTEM_TEXT name='ARIA Placeholder4a' FOCUSABLE explicit-name:true
++ROLE_SYSTEM_TEXT name='Placeholder4b' FOCUSABLE explicit-name:true ++ROLE_SYSTEM_TEXT name='Placeholder4b' FOCUSABLE explicit-name:true
++ROLE_SYSTEM_TEXT name='Placeholder5' FOCUSABLE explicit-name:true description='Title5' ++ROLE_SYSTEM_TEXT name='Placeholder5' FOCUSABLE explicit-name:true description='Title5'
++ROLE_SYSTEM_TEXT name='LabelledBy6' FOCUSABLE explicit-name:true description='DescribedBy6' ++ROLE_SYSTEM_TEXT name='LabelledBy6' FOCUSABLE explicit-name:true description='DescribedBy6'
\ No newline at end of file ++ROLE_SYSTEM_TEXT name='AriaLabel7' FOCUSABLE explicit-name:true description='DescribedBy7'
\ No newline at end of file
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
aria-label="AriaLabel6" aria-labelledby="lb6" aria-label="AriaLabel6" aria-labelledby="lb6"
aria-describedby="db6"> aria-describedby="db6">
<input id="c7" type="text" aria-label="AriaLabel7"
placeholder="Placeholder7" aria-describedby="db7">
<p aria-label="@NO_DUMP"> <p aria-label="@NO_DUMP">
<label for="c1">Label1</label> <label for="c1">Label1</label>
<label for="c2">Label2</label> <label for="c2">Label2</label>
...@@ -34,6 +37,8 @@ ...@@ -34,6 +37,8 @@
<span id="lb6">LabelledBy6</span> <span id="lb6">LabelledBy6</span>
<span id="db6">DescribedBy6</span> <span id="db6">DescribedBy6</span>
<span id="db7">DescribedBy7</span>
</p> </p>
</body> </body>
</html> </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