• Ethan Jimenez's avatar
    Fix ExpandToEnclosingUnit issue with positions between text anchors · 0a2e826a
    Ethan Jimenez authored
    1. Previously, our implementation of `ExpandToEnclosingUnit` didn't take
       into account that, since we changed the behavior of text positions to
       be able to reach the maximum text offset of its anchor, there are
       multiple text positions that are equal when compared, but are located
       in different anchors.
    
       For example, the end position of an anchor and the start position of
       the next text anchor. This could get even trickier with empty text
       anchors between characters in the text representation.
    
       Such scenarios are relevant to some assistive technologies since the
       anchors that the enclosing range spans affect `GetEnclosingElement`,
       ultimately breaking functions of these ATs.
    
       Implementing two new methods `AsPositionBeforeCharacter` and
       `AsPositionAfterCharacter` in `AXPosition`, which we will use to
       normalize positions between characters of the text representation.
    
    2. Adding unit tests for both new methods in `AXPositionTest`.
    
    3. Improving `TestITextRangeProviderExpandToEnclosingCharacter` coverage
       in `AXPlatformNodeTextRangeProviderTest` to check that the enclosing
       element resolved from the expanded range matches AT expectations.
    
    4. Addressing a bug in `ExpandToEnclosingUnit` where the position at the
       end of the last anchor of the tree does not expand to the last
       character of its text representation.
    
    Bug: 961893
    Change-Id: Ib168d680578a3b460b57b7ca9808987568743a95
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1614940Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
    Reviewed-by: default avatarKurt Catti-Schmidt <kschmi@microsoft.com>
    Commit-Queue: Ethan Jimenez <ethavar@microsoft.com>
    Cr-Commit-Position: refs/heads/master@{#660881}
    0a2e826a
ax_position.h 67.6 KB