Commit 7934ec52 authored by Ethan Jimenez's avatar Ethan Jimenez Committed by Commit Bot

Fix CreateNextLineStartPosition and CreatePreviousLineEndPosition

1. There was a bug in `AXPosition::CreateNextLineStartPosition` where we
   assumed that, after moving past the end of an `AXTree` not finding a
   next line start, the end of the original anchor would be the same as
   the end of the entire tree's text representation.

   This was not true if the last line of the text representation was
   composed by multiple anchors and the function was called from a leaf
   text position located at one of such anchors other than the last.

   Fixing such issue by returning `CreatePositionAtEndOfAnchor` from the
   last leaf text position of the `AXTree` (rooted at the original
   position's anchor if the result is its descendant).

   The same bug was present in `CreatePreviousLineEndPosition`, but in
   the inverted scenario of the previous line end of the first line.

2. Adding unit test to cover the scenario mentioned above.

Bug: 928948
Change-Id: I7c98aa5ae6d881cc884cd2fc8bf517780e82dccf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1747854
Commit-Queue: Ethan Jimenez <ethavar@microsoft.com>
Reviewed-by: default avatarKurt Catti-Schmidt <kschmi@microsoft.com>
Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686547}
parent d16beea7
This diff is collapsed.
......@@ -2725,8 +2725,8 @@ TEST_F(AXPlatformNodeTextRangeProviderTest,
// <button>Button</button><input type="checkbox">Line 1<br>Line 2
// |---------------------||---------------------|
ASSERT_HRESULT_SUCCEEDED(text_range_provider->MoveEndpointByUnit(
TextPatternRangeEndpoint_End, TextUnit_Line, /*count*/ -1, &count));
ASSERT_EQ(-1, count);
TextPatternRangeEndpoint_End, TextUnit_Word, /*count*/ -2, &count));
ASSERT_EQ(-2, count);
EXPECT_HRESULT_SUCCEEDED(
text_range_provider->GetBoundingRectangles(rectangles.Receive()));
expected_values = {20, 20, 200, 30, /* button */
......
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