Commit a219bb98 authored by Nektarios Paisios's avatar Nektarios Paisios Committed by Chromium LUCI CQ

Cleanup: Renames CreateNext/PreviousTextAnchorPosition to CreateNext/PreviousLeafTextPosition

This is done for three reasons:
1. The two methods don't really check if the next / previous anchor is a text node.
They simply move to the next / previous leaf text position
assuming that every leaf node is a text node.
2. There is already a set of corresponding CreateNext/PreviousLeafTreePosition
methods.
3. There is a similar method `CreateNextLeafTextPosition(bool*)`, used for paragraph boundaries. Making
that method to be an overload of CreateNextLeafTextPosition is clearer, since they both move in
the same way through the AX tree.

Split out from a larger patch that makes AXPosition work with a forest
of accessibility trees at:
https://chromium-review.googlesource.com/c/chromium/src/+/2595454

AX-Relnotes: n/a.

TBR=dmazzoni@chromium.org, aleventhal@chromium.org

Bug: 1049261
Change-Id: Idc56c19f908fde8b145a55fe542ee637ae4cbd44
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2598625Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#838567}
parent 8de47f33
......@@ -670,12 +670,12 @@ class AXPosition {
AXPositionInstance previous_text_position = text_position->Clone();
do {
previous_text_position =
previous_text_position->CreatePreviousTextAnchorPosition(
previous_text_position->CreatePreviousLeafTextPosition(
abort_move_predicate);
// If the previous position is whitespace, then continue searching
// until a non-whitespace leaf text position is found within the
// current paragraph because whitespace is supposed to be collapsed.
// There's a chance that |CreatePreviousTextAnchorPosition| will
// There's a chance that |CreatePreviousLeafTextPosition| will
// return whitespace that should be appended to a previous paragraph
// rather than separating two pieces of the current paragraph.
} while (previous_text_position->IsInWhiteSpace() ||
......@@ -728,7 +728,7 @@ class AXPosition {
// using the paragraph boundary abort predicate.
// If a null position was found, then this position must be the end of
// a paragraph.
// |CreateNextTextAnchorPosition| + |AbortMoveAtParagraphBoundary|
// |CreateNextLeafTextPosition| + |AbortMoveAtParagraphBoundary|
// will return a null position when an anchor movement would
// cross a paragraph boundary and there is no doubt that it is the end
// of a paragraph, or the end of content was reached.
......@@ -741,7 +741,7 @@ class AXPosition {
AXPositionInstance next_text_position = text_position->Clone();
do {
next_text_position = next_text_position->CreateNextTextAnchorPosition(
next_text_position = next_text_position->CreateNextLeafTextPosition(
abort_move_predicate);
} while (next_text_position->IsIgnored());
if (next_text_position->IsNullPosition())
......@@ -793,7 +793,7 @@ class AXPosition {
// This will return a null position when an anchor movement would
// cross a page boundary, or the start of content was reached.
AXPositionInstance previous_text_position =
text_position->CreatePreviousTextAnchorPosition(
text_position->CreatePreviousLeafTextPosition(
base::BindRepeating(&AbortMoveAtPageBoundary));
return previous_text_position->IsNullPosition();
}
......@@ -821,7 +821,7 @@ class AXPosition {
// This will return a null position when an anchor movement would
// cross a page boundary, or the end of content was reached.
AXPositionInstance next_text_position =
text_position->CreateNextTextAnchorPosition(
text_position->CreateNextLeafTextPosition(
base::BindRepeating(&AbortMoveAtPageBoundary));
return next_text_position->IsNullPosition();
}
......@@ -2117,7 +2117,7 @@ class AXPosition {
// Creates a text position using the previous text-only node as its anchor.
// Assumes that text-only nodes are leaf nodes.
AXPositionInstance CreatePreviousLeafTextPosition() const {
return CreatePreviousTextAnchorPosition(
return CreatePreviousLeafTextPosition(
base::BindRepeating(&DefaultAbortMovePredicate));
}
......@@ -3835,9 +3835,9 @@ class AXPosition {
return rightmost_leaf;
}
// Creates a position using the next text-only node as its anchor.
// Assumes that text-only nodes are leaf nodes.
AXPositionInstance CreateNextTextAnchorPosition(
// Creates a text position using the next leaf node as its anchor.
// Leaf nodes often make up the trees text representation.
AXPositionInstance CreateNextLeafTextPosition(
const AbortMovePredicate& abort_predicate) const {
// If this is an ancestor text position, resolve to its leaf text position.
if (IsTextPosition() && !IsLeaf())
......@@ -3851,9 +3851,9 @@ class AXPosition {
return next_leaf->AsLeafTextPosition();
}
// Creates a position using the previous text-only node as its anchor.
// Assumes that text-only nodes are leaf nodes.
AXPositionInstance CreatePreviousTextAnchorPosition(
// Creates a text position using the previous leaf node as its anchor.
// Leaf nodes often make up the trees text representation.
AXPositionInstance CreatePreviousLeafTextPosition(
const AbortMovePredicate& abort_predicate) const {
// If this is an ancestor text position, resolve to its leaf text position.
if (IsTextPosition() && !IsLeaf())
......
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