Reland "[Editing] Fix canonical caret position at line break"
This is a reland of d46bdb4f It was reverted because the new test could time out in Mac. Fixed by adding '<meta name="timeout" content="long">'. 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 Change-Id: Ida01b6d838f03cfbe66e4cba86472ed90499af45 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2450292Reviewed-by:Xiaocheng Hu <xiaochengh@chromium.org> Commit-Queue: Oriol Brufau <obrufau@igalia.com> Cr-Commit-Position: refs/heads/master@{#814053}
Showing
Please register or sign in to comment