-
Siye Liu authored
This partially reverts commit d46bdb4f. Reason for revert: the change causes a regression where inserting text at end of current block and next block is an inline block, then the new selection will be end up at the beginning of next block. Per suggestion in crbug.com/1161370#c15, we only need to partially revert the change( change made in VisiblePositionTemplate::Create. Original change's description: > [Editing] Fix canonical caret position at line break > > Consider this testcase: > <style>div { width: min-content; padding: 5px; }</style> > <div contenteditable>line1<wbr>line2</div> > which is rendered as > line1 > line2 > > Before this patch, when clicking at the beginning of the 2nd line, the > caret would appear at the end of the 1st one, because CanonicalPosition > would search backwards even with a downstream affinity. > > Also, when clicking at the beginning of the 1st line and pressing the > down arrow key, the caret would move to the end of the 1st line instead > of to the beginning of the 2nd one. And pressing the key again would > have no effect, the caret would refuse to go down. > > This patch fixes these problems by making CanonicalPosition take a > TextAffinity parameter which affects whether the canonical position is > first searched backwards or forwards. If no suitable candidate is found, > it will still search in the other direction. > > And then, VisiblePosition::Create takes care of deciding between the > upstream and the downstream canonical positions, depending on the > affinity and whether there is a line break. > > Bug: 1002937 > > Web tests: > TEST=external/wpt/editing/run/caret-navigation-around-line-break.html > > Unit tests: > TEST=All/ParameterizedVisibleUnitsLineTest.inSameLine/0 > TEST=All/ParameterizedVisibleUnitsLineTest.inSameLine/1 > TEST=All/ParameterizedVisibleUnitsWordTest.StartOfWordShadowDOM/0 > TEST=All/ParameterizedVisibleUnitsWordTest.StartOfWordShadowDOM/1 > 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.canonicalPositionOfWithHTMLHtmlElement > TEST=VisibleUnitsTest.canonicalPositionOfWithInputElement > TEST=VisibleUnitsTest.canonicalizationWithCollapsedSpaceAndIsolatedCombiningCharacter > > Change-Id: I82d86d40a87513b2e92c024735957e9f71154094 > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2410404 > Commit-Queue: Oriol Brufau <obrufau@igalia.com> > Reviewed-by: Yoshifumi Inoue <yosin@chromium.org> > Cr-Commit-Position: refs/heads/master@{#813744} Bug: 1002937 Bug: 1161370 Change-Id: I65dbc8b442ae308f42582095e4693d9f146b8b32 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2616734Reviewed-by:
Siye Liu <siliu@microsoft.com> Reviewed-by:
Oriol Brufau <obrufau@igalia.com> Commit-Queue: Siye Liu <siliu@microsoft.com> Cr-Commit-Position: refs/heads/master@{#841598}
e75497d4