Commit c824fa5a authored by Martin Robinson's avatar Martin Robinson Committed by Commit Bot

Emit an ATK text-caret-moved signal on anchor navigation

This will ensure that Orca knows to properly move the text caret after
anchor navigation even when Chromium-based text caret navigation is
disabled. Normally, this is handled by the sequential focus navigation
starting point, but this value is not propagated to the accessibility
layer.

Bug: 1011942
Change-Id: I21d2cde59e12f8aff212b2d9bf3700dad27242c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1871887
Commit-Queue: Martin Robinson <mrobinson@igalia.com>
Commit-Queue: Joanmarie Diggs <jdiggs@igalia.com>
Auto-Submit: Martin Robinson <mrobinson@igalia.com>
Reviewed-by: default avatarJoanmarie Diggs <jdiggs@igalia.com>
Cr-Commit-Position: refs/heads/master@{#708185}
parent cd94fd4f
...@@ -106,7 +106,14 @@ void BrowserAccessibilityManagerAuraLinux::FireBlinkEvent( ...@@ -106,7 +106,14 @@ void BrowserAccessibilityManagerAuraLinux::FireBlinkEvent(
ax::mojom::Event event_type, ax::mojom::Event event_type,
BrowserAccessibility* node) { BrowserAccessibility* node) {
BrowserAccessibilityManager::FireBlinkEvent(event_type, node); BrowserAccessibilityManager::FireBlinkEvent(event_type, node);
// Need to implement.
switch (event_type) {
case ax::mojom::Event::kScrolledToAnchor:
ToBrowserAccessibilityAuraLinux(node)->GetNode()->OnScrolledToAnchor();
break;
default:
break;
}
} }
void BrowserAccessibilityManagerAuraLinux::FireNameChangedEvent( void BrowserAccessibilityManagerAuraLinux::FireNameChangedEvent(
......
...@@ -3186,6 +3186,12 @@ void AXPlatformNodeAuraLinux::OnWindowVisibilityChanged() { ...@@ -3186,6 +3186,12 @@ void AXPlatformNodeAuraLinux::OnWindowVisibilityChanged() {
atk_object_notify_state_change(atk_object, ATK_STATE_ICONIFIED, minimized); atk_object_notify_state_change(atk_object, ATK_STATE_ICONIFIED, minimized);
} }
void AXPlatformNodeAuraLinux::OnScrolledToAnchor() {
AtkObject* atk_object = GetOrCreateAtkObject();
DCHECK(ATK_IS_TEXT(atk_object));
g_signal_emit_by_name(atk_object, "text-caret-moved", 0);
}
void AXPlatformNodeAuraLinux::OnFocused() { void AXPlatformNodeAuraLinux::OnFocused() {
AtkObject* atk_object = GetOrCreateAtkObject(); AtkObject* atk_object = GetOrCreateAtkObject();
......
...@@ -167,6 +167,7 @@ class AX_EXPORT AXPlatformNodeAuraLinux : public AXPlatformNodeBase { ...@@ -167,6 +167,7 @@ class AX_EXPORT AXPlatformNodeAuraLinux : public AXPlatformNodeBase {
void OnSubtreeWillBeDeleted(); void OnSubtreeWillBeDeleted();
void OnParentChanged(); void OnParentChanged();
void OnWindowVisibilityChanged(); void OnWindowVisibilityChanged();
void OnScrolledToAnchor();
bool SupportsSelectionWithAtkSelection(); bool SupportsSelectionWithAtkSelection();
bool SelectionAndFocusAreTheSame(); bool SelectionAndFocusAreTheSame();
......
...@@ -2338,4 +2338,32 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkObjectParentChanged) { ...@@ -2338,4 +2338,32 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkObjectParentChanged) {
ASSERT_TRUE(saw_parent_changed); ASSERT_TRUE(saw_parent_changed);
} }
TEST_F(AXPlatformNodeAuraLinuxTest, TestScrolledToAnchorEvent) {
AXNodeData root_data;
root_data.id = 1;
root_data.role = ax::mojom::Role::kListBox;
root_data.child_ids.push_back(2);
AXNodeData item_1_data;
item_1_data.id = 2;
item_1_data.role = ax::mojom::Role::kListBoxOption;
Init(root_data, item_1_data);
AXNode* item_1 = GetRootNode()->children()[0];
AtkObject* atk_object = AtkObjectFromNode(item_1);
bool saw_caret_moved = false;
g_signal_connect(
atk_object, "text-caret-moved",
G_CALLBACK(+[](AtkObject*, int position, bool* saw_caret_moved) {
*saw_caret_moved = true;
}),
&saw_caret_moved);
GetPlatformNode(item_1)->OnScrolledToAnchor();
ASSERT_TRUE(saw_caret_moved);
}
} // namespace ui } // namespace ui
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