Commit ebd5f7cb authored by Hiroki Sato's avatar Hiroki Sato Committed by Commit Bot

Wire window title to ARC root node's name property

Previously, when the root node in ARC gets focus from ChromeVox,
ChromeVox reads the entire window content.

This CL prevents it by assigning the window title to the root node.

Bug: None (preparation of b:148356674)
Test: unit_tests --gtest_filter="AXTreeSourceArcTest.*"
Change-Id: I884e2c19188468c48f6c26a4d4cb3eb72dc31144
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2024635
Commit-Queue: Hiroki Sato <hirokisato@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Reviewed-by: default avatarSara Kato <sarakato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736766}
parent 9cc51862
......@@ -352,6 +352,19 @@ void AccessibilityNodeInfoDataWrapper::Serialize(
ComputeNameFromContents(this, &names);
if (!names.empty())
out_data->SetName(base::JoinString(names, " "));
} else if (is_node_tree_root) {
AccessibilityInfoDataWrapper* parent =
tree_source_->GetParent(tree_source_->GetFromId(node_ptr_->id));
if (parent && parent->GetWindow()) {
std::string title;
if (arc::GetProperty(parent->GetWindow()->string_properties,
mojom::AccessibilityWindowStringProperty::TITLE,
&title) &&
!title.empty()) {
out_data->SetName(title);
out_data->SetNameFrom(ax::mojom::NameFrom::kTitle);
}
}
}
std::string role_description;
......
......@@ -513,6 +513,15 @@ TEST_F(AXTreeSourceArcTest, AccessibleNameComputation) {
CallSerializeNode(root, &data);
ASSERT_FALSE(
data->GetStringAttribute(ax::mojom::StringAttribute::kName, &name));
// Root window title propagates to the name of the root node of the window if
// it isn't specified.
SetProperty(root_window, AXWindowStringProperty::TITLE, "Window Title");
CallNotifyAccessibilityEvent(event.get());
CallSerializeNode(root, &data);
ASSERT_TRUE(
data->GetStringAttribute(ax::mojom::StringAttribute::kName, &name));
ASSERT_EQ("Window Title", name);
}
TEST_F(AXTreeSourceArcTest, AccessibleNameComputationTextField) {
......
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