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

Remove AtkText event workaround for anonymous blocks

Orca no longer needs this because it no longer assumes that the document
doesn't include anonymous block text in its own AtkText.

Bug: 959659
Change-Id: If9f0c2de7678e66cec94e998ea9fcdf1ed4440dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1728659Reviewed-by: default avatarJoanmarie Diggs <jdiggs@igalia.com>
Commit-Queue: Martin Robinson <mrobinson@igalia.com>
Cr-Commit-Position: refs/heads/master@{#682723}
parent 666e4840
...@@ -930,24 +930,37 @@ IN_PROC_BROWSER_TEST_F(AccessibilityAuraLinuxBrowserTest, ...@@ -930,24 +930,37 @@ IN_PROC_BROWSER_TEST_F(AccessibilityAuraLinuxBrowserTest,
<html> <html>
<body> <body>
<div contenteditable="true">Text inside field</div> <div contenteditable="true">Text inside field</div>
anonymous block
</body> </body>
</html>)HTML")); </html>)HTML"));
AtkObject* document = GetRendererAccessible(); AtkObject* document = GetRendererAccessible();
EXPECT_EQ(1, atk_object_get_n_accessible_children(document)); EXPECT_EQ(2, atk_object_get_n_accessible_children(document));
AtkText* div_element = ATK_TEXT(atk_object_ref_accessible_child(document, 0)); AtkText* div_element = ATK_TEXT(atk_object_ref_accessible_child(document, 0));
EXPECT_EQ(1, atk_object_get_n_accessible_children(ATK_OBJECT(div_element))); EXPECT_EQ(1, atk_object_get_n_accessible_children(ATK_OBJECT(div_element)));
AtkText* text = AtkText* text =
ATK_TEXT(atk_object_ref_accessible_child(ATK_OBJECT(div_element), 0)); ATK_TEXT(atk_object_ref_accessible_child(ATK_OBJECT(div_element), 0));
AtkText* anonymous_block =
ATK_TEXT(atk_object_ref_accessible_child(document, 1));
auto callback = G_CALLBACK(+[](AtkText*, gint, bool* flag) { *flag = true; }); auto callback = G_CALLBACK(+[](AtkText*, gint, bool* flag) { *flag = true; });
bool saw_caret_move_in_text = false; bool saw_caret_move_in_text = false;
bool saw_caret_move_in_div = false;
g_signal_connect(text, "text-caret-moved", callback, &saw_caret_move_in_text); g_signal_connect(text, "text-caret-moved", callback, &saw_caret_move_in_text);
bool saw_caret_move_in_div = false;
g_signal_connect(div_element, "text-caret-moved", callback, g_signal_connect(div_element, "text-caret-moved", callback,
&saw_caret_move_in_div); &saw_caret_move_in_div);
bool saw_caret_move_in_anonymous_block = false;
g_signal_connect(anonymous_block, "text-caret-moved", callback,
&saw_caret_move_in_anonymous_block);
bool saw_caret_move_in_document = false;
g_signal_connect(document, "text-caret-moved", callback,
&saw_caret_move_in_document);
AccessibilityNotificationWaiter selection_waiter( AccessibilityNotificationWaiter selection_waiter(
shell()->web_contents(), ui::kAXModeComplete, shell()->web_contents(), ui::kAXModeComplete,
ax::mojom::Event::kTextSelectionChanged); ax::mojom::Event::kTextSelectionChanged);
...@@ -965,8 +978,19 @@ IN_PROC_BROWSER_TEST_F(AccessibilityAuraLinuxBrowserTest, ...@@ -965,8 +978,19 @@ IN_PROC_BROWSER_TEST_F(AccessibilityAuraLinuxBrowserTest,
// We should see the event happen in div and not the static text element. // We should see the event happen in div and not the static text element.
EXPECT_TRUE(saw_caret_move_in_div); EXPECT_TRUE(saw_caret_move_in_div);
EXPECT_FALSE(saw_caret_move_in_text); EXPECT_FALSE(saw_caret_move_in_text);
EXPECT_FALSE(saw_caret_move_in_anonymous_block);
EXPECT_FALSE(saw_caret_move_in_document);
saw_caret_move_in_div = false;
atk_text_set_caret_offset(anonymous_block, 3);
EXPECT_FALSE(saw_caret_move_in_div);
EXPECT_FALSE(saw_caret_move_in_text);
EXPECT_FALSE(saw_caret_move_in_anonymous_block);
EXPECT_TRUE(saw_caret_move_in_document);
g_object_unref(div_element); g_object_unref(div_element);
g_object_unref(anonymous_block);
g_object_unref(text); g_object_unref(text);
} }
......
...@@ -192,23 +192,6 @@ bool EmitsAtkTextEvents(AtkObject* atk_object) { ...@@ -192,23 +192,6 @@ bool EmitsAtkTextEvents(AtkObject* atk_object) {
if (atk_object_get_n_accessible_children(atk_object)) if (atk_object_get_n_accessible_children(atk_object))
return true; return true;
// If this node is an anonymous block that is a static text leaf node, it
// should also emit events. The heuristic that Orca uses for this is to check
// whether or not it has any non-static-text siblings. We duplicate that here
// to maintain compatibility.
AtkObject* parent = atk_object_get_parent(atk_object);
if (!parent)
return false;
int num_siblings = atk_object_get_n_accessible_children(parent);
for (int i = 0; i < num_siblings; i++) {
AtkObject* sibling = atk_object_ref_accessible_child(parent, i);
AtkRole role = atk_object_get_role(sibling);
g_object_unref(sibling);
if (role != ATK_ROLE_TEXT)
return true;
}
return false; return false;
} }
......
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