Commit 5a685fac authored by Sara Kato's avatar Sara Kato Committed by Commit Bot

Append placeholder text to name computation

ChromeVox reading placeholder text was done in a
previous change (crrev/c/1855621). However this placeholder
text should be appended to the name of the node, rather than
part of the hint_ method.

Also note that Android often uses the hint_text attribute
to store the placeholder text in textfields.

TEST: AXTreeSourceArcTest.AccessibleNameComputation
Bug: 1014802
Change-Id: I84863595f84dfa12ddc40c3e96f27bc3d41b51c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1889270
Commit-Queue: Sara Kato <sarakato@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Reviewed-by: default avatarAkihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#716426}
parent 08706391
...@@ -301,8 +301,13 @@ void AccessibilityNodeInfoDataWrapper::Serialize( ...@@ -301,8 +301,13 @@ void AccessibilityNodeInfoDataWrapper::Serialize(
GetProperty(AXStringProperty::PANE_TITLE, &pane_title); GetProperty(AXStringProperty::PANE_TITLE, &pane_title);
// |hint_text| attribute in Android is often used as a placeholder text within
// textfields.
std::string hint_text;
GetProperty(AXStringProperty::HINT_TEXT, &hint_text);
if (!text.empty() || !content_description.empty() || !label.empty() || if (!text.empty() || !content_description.empty() || !label.empty() ||
!pane_title.empty()) { !pane_title.empty() || !hint_text.empty()) {
// Append non empty properties to name attribute. // Append non empty properties to name attribute.
std::vector<std::string> names; std::vector<std::string> names;
if (!content_description.empty()) if (!content_description.empty())
...@@ -321,6 +326,11 @@ void AccessibilityNodeInfoDataWrapper::Serialize( ...@@ -321,6 +326,11 @@ void AccessibilityNodeInfoDataWrapper::Serialize(
names.push_back(text); names.push_back(text);
} }
} }
// Append hint text as part of name attribute.
if (!hint_text.empty())
names.push_back(hint_text);
// TODO (sarakato): Exposing all possible labels for a node, may result in // TODO (sarakato): Exposing all possible labels for a node, may result in
// too much being spoken. For ARC ++, this may result in divergent behaviour // too much being spoken. For ARC ++, this may result in divergent behaviour
// from Talkback. // from Talkback.
...@@ -350,12 +360,6 @@ void AccessibilityNodeInfoDataWrapper::Serialize( ...@@ -350,12 +360,6 @@ void AccessibilityNodeInfoDataWrapper::Serialize(
} }
} }
std::string place_holder;
if (GetProperty(AXStringProperty::HINT_TEXT, &place_holder)) {
out_data->AddStringAttribute(ax::mojom::StringAttribute::kPlaceholder,
place_holder);
}
// If it exists, set tooltip value as on node. // If it exists, set tooltip value as on node.
std::string tooltip; std::string tooltip;
if (GetProperty(AXStringProperty::TOOLTIP, &tooltip)) if (GetProperty(AXStringProperty::TOOLTIP, &tooltip))
......
...@@ -492,6 +492,13 @@ TEST_F(AXTreeSourceArcTest, AccessibleNameComputation) { ...@@ -492,6 +492,13 @@ TEST_F(AXTreeSourceArcTest, AccessibleNameComputation) {
data->GetStringAttribute(ax::mojom::StringAttribute::kName, &name)); data->GetStringAttribute(ax::mojom::StringAttribute::kName, &name));
ASSERT_EQ("root label text", name); ASSERT_EQ("root label text", name);
// The placeholder text on the node, should also be appended to the name.
SetProperty(child2, AXStringProperty::HINT_TEXT, "child2 hint text");
CallSerializeNode(child2, &data);
ASSERT_TRUE(
data->GetStringAttribute(ax::mojom::StringAttribute::kName, &name));
ASSERT_EQ("child2 label text child2 hint text", name);
// Clearing both clickable and name from root, the name should not be // Clearing both clickable and name from root, the name should not be
// populated. // populated.
root->boolean_properties->clear(); root->boolean_properties->clear();
......
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