• Ian Prest's avatar
    A11y: Fix a hang on placeholder text · 1db2ac29
    Ian Prest authored
    The `CreateNextWord*Position` functions were not updating their iterator
    in certain edge cases, which caused an infinite loop.  (Notably, the
    `CreatePreviousWord*Position` functions *are* updating their iterators
    in the same scenarios.)
    
    The new test included in this change would hang before the fix.
    
    The following is a detailed description of the error scenario:
    -- Start with a AXTextPosition (at index 0) at a high level in the tree.
    -- Call one of the `CreateNextWord*Position` functions.
    -- These functions start by getting a "leaf" text position, which drills
       down deeper in the tree.  Specifically, they drill down into a node
       that includes placeholder text (which appears as part of their
       hypertext, but not in the hypertext of the outer node).
    -- The function then tries to advance to the next word, and finds a
       valid word stop.
    -- The end of this loop compares the new position against the original.
    -- operator==/CompareTo must adjust the positions to be relative to the
       same node, which it does using repeated calls to GetParentPosition().
    -- GetParentPosition() determines that the text-offset in the deep node
       is not valid in the outer node, so it resets the index to zero.
       (This workaround was added in CL:1661548.)
    -- As a result, CompareTo determines that the two nodes are equal.
    -- Therefore, we loop in CreateNextWord*Position.
    -- Because the iterator was not updated, we loop infinitely.
    
    Bug: 994871
    Change-Id: I6e5880bfa7073e2ca672d281fca223e90e5fe288
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1758590Reviewed-by: default avatarKevin Babbitt <kbabbitt@microsoft.com>
    Reviewed-by: default avatarAaron Leventhal <aleventhal@chromium.org>
    Commit-Queue: Ian Prest <iapres@microsoft.com>
    Cr-Commit-Position: refs/heads/master@{#688611}
    1db2ac29
ax_position.h 115 KB