[editing] Normalize caret position in the flat tree
VisiblePosition::Create canonicalizes positions using MostBackwardCaretPosition and MostForwardCaretPosition. For positions based on the DOM tree, this happened in the DOM tree too, so they might consider two positions to be visually the same, even though in the flat tree there was some content between them. To solve the problem, this patch makes them convert the Position into a PositionInFlatTree, canonicalize in the flat tree, and then convert the result back into a Position, but clamping to avoid crossing shadow boundaries. Bug: 1145595 TEST=EditingUtilitiesTest.firstEditablePositionAfterPositionInRoot TEST=EditingUtilitiesTest.lastEditablePositionBeforePositionInRoot TEST=EditingUtilitiesTest.NextVisuallyDistinctCandidate TEST=VisiblePositionTest.ShadowV0DistributedNodes TEST=VisibleUnitsLineTest.endOfLine TEST=VisibleUnitsLineTest.isEndOfLine TEST=VisibleUnitsLineTest.isLogicalEndOfLine TEST=VisibleUnitsLineTest.isStartOfLine TEST=VisibleUnitsLineTest.logicalEndOfLine TEST=VisibleUnitsLineTest.logicalStartOfLine TEST=VisibleUnitsLineTest.startOfLine TEST=VisibleUnitsTest.characterAfter TEST=VisibleUnitsTest.characterBefore TEST=VisibleUnitsTest.mostForwardCaretPositionAfterAnchor TEST=VisibleUnitsTest.nextPositionOf TEST=VisibleUnitsTest.previousPositionOf TEST=All/ParameterizedVisibleUnitsLineTest.inSameLine/* TEST=All/ParameterizedVisibleUnitsWordTest.EndOfWordShadowDOM/* TEST=All/ParameterizedVisibleUnitsWordTest.StartOfWordShadowDOM/* TEST=third_party/blink/web_tests/editing/execCommand/insert-list-with-progress-crash.html TEST=third_party/blink/web_tests/editing/selection/collapse/collapse_before_select.html Change-Id: I793c07c7ffbecdaf6cc619c6043f90475c922fda Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2517686 Commit-Queue: Oriol Brufau <obrufau@igalia.com> Reviewed-by:Yoshifumi Inoue <yosin@chromium.org> Cr-Commit-Position: refs/heads/master@{#832706}
Showing
This diff is collapsed.
Please register or sign in to comment