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

Fall back to simple accessibility boundary analysis for sentences

This support is required for ATs on AuraLinux, so fall back instead of
triggering an assertion failure and a null position. We can remove this
workaround once sentence boundary analysis support is added to
AXPosition.

Bug: 1000049
Change-Id: I00c4eee451c75e7efe8e132d15995899eccca049
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832811Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Commit-Queue: Martin Robinson <mrobinson@igalia.com>
Cr-Commit-Position: refs/heads/master@{#714265}
parent abf52b44
...@@ -144,8 +144,9 @@ void AccessibilityAuraLinuxBrowserTest::CheckTextAtOffset( ...@@ -144,8 +144,9 @@ void AccessibilityAuraLinuxBrowserTest::CheckTextAtOffset(
int expected_end_offset, int expected_end_offset,
const char* expected_text) { const char* expected_text) {
testing::Message message; testing::Message message;
message << "While checking for \'" << expected_text << "\' at " message << "While checking at index \'" << offset << "\' for \'"
<< expected_start_offset << '-' << expected_end_offset << '.'; << expected_text << "\' at " << expected_start_offset << '-'
<< expected_end_offset << '.';
SCOPED_TRACE(message); SCOPED_TRACE(message);
int start_offset = 0; int start_offset = 0;
...@@ -299,6 +300,49 @@ IN_PROC_BROWSER_TEST_F(AccessibilityAuraLinuxBrowserTest, ...@@ -299,6 +300,49 @@ IN_PROC_BROWSER_TEST_F(AccessibilityAuraLinuxBrowserTest,
g_object_unref(atk_text); g_object_unref(atk_text);
} }
IN_PROC_BROWSER_TEST_F(AccessibilityAuraLinuxBrowserTest,
TestParagraphTextAtOffsetWithBoundarySentence) {
LoadInitialAccessibilityTreeFromHtml(std::string(
R"HTML(<!DOCTYPE html>
<html>
<body>
<div>One sentence. Two sentences. Three sentences!</div>
</body>
</html>)HTML"));
AtkObject* document = GetRendererAccessible();
EXPECT_EQ(1, atk_object_get_n_accessible_children(document));
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)));
AtkText* atk_text =
ATK_TEXT(atk_object_ref_accessible_child(ATK_OBJECT(div_element), 0));
int first_sentence_offset = 14;
int second_sentence_offset = first_sentence_offset + 15;
int third_sentence_offset = second_sentence_offset + 16;
for (int i = 0; i < first_sentence_offset; ++i) {
CheckTextAtOffset(atk_text, i, ATK_TEXT_BOUNDARY_SENTENCE_START, 0,
first_sentence_offset, "One sentence. ");
}
for (int i = first_sentence_offset + 1; i < second_sentence_offset; ++i) {
CheckTextAtOffset(atk_text, i, ATK_TEXT_BOUNDARY_SENTENCE_START,
first_sentence_offset, second_sentence_offset,
"Two sentences. ");
}
for (int i = second_sentence_offset + 1; i < third_sentence_offset; ++i) {
CheckTextAtOffset(atk_text, i, ATK_TEXT_BOUNDARY_SENTENCE_START,
second_sentence_offset, third_sentence_offset,
"Three sentences!");
}
g_object_unref(atk_text);
g_object_unref(div_element);
}
#if defined(ATK_CHECK_VERSION) && ATK_CHECK_VERSION(2, 30, 0) #if defined(ATK_CHECK_VERSION) && ATK_CHECK_VERSION(2, 30, 0)
#define ATK_230 #define ATK_230
#endif #endif
......
...@@ -1638,10 +1638,12 @@ int AXPlatformNodeBase::FindTextBoundary( ...@@ -1638,10 +1638,12 @@ int AXPlatformNodeBase::FindTextBoundary(
int offset, int offset,
AXTextBoundaryDirection direction, AXTextBoundaryDirection direction,
ax::mojom::TextAffinity affinity) const { ax::mojom::TextAffinity affinity) const {
if (boundary != AXTextBoundary::kSentenceStart) {
base::Optional<int> boundary_offset = base::Optional<int> boundary_offset =
GetDelegate()->FindTextBoundary(boundary, offset, direction, affinity); GetDelegate()->FindTextBoundary(boundary, offset, direction, affinity);
if (boundary_offset.has_value()) if (boundary_offset.has_value())
return *boundary_offset; return *boundary_offset;
}
std::vector<int32_t> unused_line_start_offsets; std::vector<int32_t> unused_line_start_offsets;
return static_cast<int>( return static_cast<int>(
......
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