DescriptionEnsure selection is reset after inserting new list of different type over existing selection consisting of the last list item.
When an existing selection spanning across multiple list items and consisting of the last list item is converted into a new list of a different type, the ending selection is not set properly which results in the content before the
original selection getting the selection after inserting the new list.
In case the selection is a range and spans across multiple paragraphs, we apply the command paragraph by paragraph. We make the currentSelection point to one paragraph at a time
and then apply the command over it.
A call to doApplyForSingleParagraph() can however remove nodes thereby removing or orphaning a VisiblePosition pointing to the end of the selection.
Based on this VisiblePosition we try to set the original selection after executing the command.
So, after a call to doApplyForSingleParagraph() we try to reset the VisiblePosition pointing to the end of the selection.
However, when doing this for the last paragraph consisting of the contents of the last list item in its entirety, after a call to doApplyForSingleParagraph(), if the position pointing to the end of the selection becomes invalid, we should not use the endingSelection() to restore
the same since endingSelection() itself would not be pointing to the correct end of selection position. Instead we should use the previously computed |indexForEndOfSelection| using the TextIterator and set the end of selection using that.
Post which we can correctly set the ending selection.
Also, |indexForEndOfSelection| needs to be computed only once since the index pointing to the original end of selection shall not change. Hence this particular computation can be moved outside of the while.
Even as per the FIXME associated with this, computation of |indexForEndOfSelection| is inefficient.
An existing test expectation changes in that it now sets the focus/caret at the end of the last list item instead of incorrectly setting it to the beginning of the last list item.
The testcase itself takes all the contents of an unordered list and tries to change the type of selection for it.
Since all of its contents are being selected, the end caret/focus should point to the end of the last list item contained within the selection.
BUG=327261
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=163661
Patch Set 1 #Patch Set 2 : Computing indexForEndOfSelection only once #
Messages
Total messages: 4 (0 generated)
|