Commit 1f64bccf authored by Hiroki Sato's avatar Hiroki Sato Committed by Chromium LUCI CQ

arc-a11y: Fix focus computation in non full focus mode

We introduced full focus mode to simulate TalkBack's focusability
and announcement computation.
AXTreeSourceArc.FindFirstFocusableNode() uses
AccessibilityNodeInfoWrapper.IsAccessibilityFocusableContainer(), which
expects to be in the full focus mode.

This fixes usages of FindFirstFocusableNode() so that the magnifier's
focus following feature works well in ARC++ apps.

AX-Relnotes: None. Fix of regression.
Bug: b:175362381
Test: manual. In PlayStore, magnifier correctly follows the focus.
Change-Id: I0d000e2009137a68f8bd1cf6cbaac45cf087b834
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586499Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Reviewed-by: default avatarSara Kato <sarakato@chromium.org>
Commit-Queue: Hiroki Sato <hirokisato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836517}
parent 98e61b1d
......@@ -419,7 +419,8 @@ bool AXTreeSourceArc::UpdateAndroidFocusedId(const AXEventData& event_data) {
if (source_node && source_node->IsVisibleToUser()) {
// Sometimes Android sets focus on unfocusable node, e.g. ListView.
AccessibilityInfoDataWrapper* adjusted_node =
FindFirstFocusableNode(source_node);
UseFullFocusMode() ? FindFirstFocusableNode(source_node)
: source_node;
if (IsValid(adjusted_node))
android_focused_id_ = adjusted_node->GetId();
}
......@@ -466,7 +467,7 @@ bool AXTreeSourceArc::UpdateAndroidFocusedId(const AXEventData& event_data) {
new_focus = GetFromId(itr->second);
// Otherwise, try focus on the first focusable node.
if (!IsValid(new_focus))
if (!IsValid(new_focus) && UseFullFocusMode())
new_focus = FindFirstFocusableNode(GetFromId(event_data.source_id));
if (IsValid(new_focus))
......
......@@ -713,6 +713,8 @@ TEST_F(AXTreeSourceArcTest, OnViewSelectedEvent) {
}
TEST_F(AXTreeSourceArcTest, OnWindowStateChangedEvent) {
set_full_focus_mode(true);
auto event = AXEventData::New();
event->task_id = 1;
......@@ -805,6 +807,8 @@ TEST_F(AXTreeSourceArcTest, OnWindowStateChangedEvent) {
}
TEST_F(AXTreeSourceArcTest, OnFocusEvent) {
set_full_focus_mode(true);
auto event = AXEventData::New();
event->task_id = 1;
event->event_type = AXEventType::VIEW_FOCUSED;
......@@ -858,7 +862,6 @@ TEST_F(AXTreeSourceArcTest, OnFocusEvent) {
// VIEW_ACCESSIBILITY_FOCUSED event also updates the focus in screen reader
// mode.
set_full_focus_mode(true);
SetProperty(node1, AXBooleanProperty::ACCESSIBILITY_FOCUSED, false);
SetProperty(node2, AXBooleanProperty::ACCESSIBILITY_FOCUSED, true);
event->event_type = AXEventType::VIEW_ACCESSIBILITY_FOCUSED;
......
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