Commit 6ff04804 authored by Nektarios Paisios's avatar Nektarios Paisios Committed by Commit Bot

Take boundary direction into account when computing parent equivalent positions

Imagine the following scenario:
1. An embedded object, e.g. a link, spans multiple lines.
2. There is some text before and after the embedded object.
"Before <embedded_object> after".

In IA2 and ATK, embedded objects are represented by an embedded object character in their parent's text.

Calling IAccessibleText::get_textAtOffset, or an equivalent API, and trying to determine the bounds
of the current line should return an offset range that includes the embedded object character, both when the call is made
somewhere inside the text "Before" as well as when the call is made somewhere inside the text "after".
This is necessary in order to signal to ATs that the embedded object starts somewhere inside the first line
and also that it ends somewhere inside the last line.
Otherwise, ATs Jaws and NVDA read only part of the last line when moving by line.
R=aleventhal@chromium.org, dmazzoni@chromium.org

Change-Id: I6f141e4fff5f60c05edbf80ff3f19ba920be7c31
Bug: 1028301
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1934312
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720572}
parent 9f567ad6
......@@ -3349,6 +3349,58 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
L"\"KHTML, like\".");
}
IN_PROC_BROWSER_TEST_F(
AccessibilityWinBrowserTest,
TestTextAtOffsetWithBoundaryLineAndMultiLineEmbeddedObject) {
// There should be two lines in this contenteditable.
//
// Half of the link is on the first line, and the other half is on the second
// line.
LoadInitialAccessibilityTreeFromHtml(R"HTML(<!DOCTYPE html>
<div contenteditable style="width: 70px">
Hello
<a href="#">this is a</a>
test.
</div>
)HTML");
Microsoft::WRL::ComPtr<IAccessible> document(GetRendererAccessible());
std::vector<base::win::ScopedVariant> document_children =
GetAllAccessibleChildren(document.Get());
ASSERT_EQ(1u, document_children.size());
Microsoft::WRL::ComPtr<IAccessible2> contenteditable;
ASSERT_HRESULT_SUCCEEDED(QueryIAccessible2(
GetAccessibleFromVariant(document.Get(), document_children[0].AsInput())
.Get(),
&contenteditable));
Microsoft::WRL::ComPtr<IAccessibleText> contenteditable_text;
ASSERT_HRESULT_SUCCEEDED(contenteditable.As(&contenteditable_text));
LONG n_characters;
ASSERT_HRESULT_SUCCEEDED(
contenteditable_text->get_nCharacters(&n_characters));
ASSERT_EQ(13, n_characters);
// Line one.
//
// The embedded object character representing the link is at offset 6.
for (LONG i = 0; i <= 6; ++i) {
CheckTextAtOffset(contenteditable_text, i, IA2_TEXT_BOUNDARY_LINE, 0, 7,
L"Hello \xFFFC");
}
// Line two.
//
// Note that the caret can also be at the end of the contenteditable, so an
// offset that is equal to "n_characters" is also permitted.
for (LONG i = 7; i <= n_characters; ++i) {
CheckTextAtOffset(contenteditable_text, i, IA2_TEXT_BOUNDARY_LINE, 6,
n_characters, L"\xFFFC test.");
}
}
IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
TestParagraphTextAtOffsetWithBoundaryLine) {
Microsoft::WRL::ComPtr<IAccessibleText> paragraph_text;
......
......@@ -356,7 +356,7 @@ IFACEMETHODIMP BrowserAccessibilityComWin::get_textAtOffset(
LONG start = FindIA2Boundary(boundary_type, offset,
ui::AXTextBoundaryDirection::kBackwards);
LONG end = FindIA2Boundary(boundary_type, start,
LONG end = FindIA2Boundary(boundary_type, offset,
ui::AXTextBoundaryDirection::kForwards);
if (end < offset)
return S_FALSE;
......
This diff is collapsed.
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