Commit 8522e889 authored by Nektarios Paisios's avatar Nektarios Paisios Committed by Commit Bot

Always exposes an offset on a leaf object as a text position

When the anchor or the focus objects for a selection are on a platform leaf object,
then the anchor and focus offsets should necessarily refer to a text position
and not a tree position, since leaf objects never have children and therefore any
anchor or focus offsets cannot refer to child indices.
Objects that are designated as leaves on certain platforms might not be leaves on every platform.
For example, in the internal accessibility tree, native text fields are not leaf objects. They include a whole
subtree inside them, which exposes all of the text.
However, AXSelection in Blink should never return positions that are inaccessible to platform APIs so
it is a safe assumption that any position on a platform leaf object should refer to a text object.

The user visible change is that editing now works on the Mac without random navigation errors.

R=aleventhal@chromium.org

Bug: 988139
Change-Id: I1180274222b8899ec81bb031c35def98d89594bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1725129
Commit-Queue: Nektarios Paisios <nektar@chromium.org>
Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#682293}
parent 8bc3914c
......@@ -268,11 +268,11 @@ AXPlatformRange CreateAXPlatformRange(const BrowserAccessibility& start_object,
int end_offset,
ax::mojom::TextAffinity end_affinity) {
BrowserAccessibilityPositionInstance anchor =
start_object.IsTextOnlyObject()
start_object.PlatformIsLeaf()
? CreateTextPosition(start_object, start_offset, start_affinity)
: CreateTreePosition(start_object, start_offset);
BrowserAccessibilityPositionInstance focus =
end_object.IsTextOnlyObject()
end_object.PlatformIsLeaf()
? CreateTextPosition(end_object, end_offset, end_affinity)
: CreateTreePosition(end_object, end_offset);
// |AXPlatformRange| takes ownership of its anchor and focus.
......
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