Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Issue 111463002: Ensure selection is reset after changing the list type of existing list items including the last. (Closed)

Created:
7 years ago by arpitab_
Modified:
7 years ago
CC:
blink-reviews
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Visibility:
Public.

Description

Ensure 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 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+34 lines, -4 lines) Patch
M LayoutTests/editing/execCommand/insert-list-nested-with-orphaned-expected.txt View 1 chunk +1 line, -1 line 0 comments Download
A LayoutTests/editing/execCommand/selection-after-insert-list.html View 1 1 chunk +17 lines, -0 lines 0 comments Download
A LayoutTests/editing/execCommand/selection-after-insert-list-expected.txt View 1 chunk +9 lines, -0 lines 0 comments Download
M Source/core/editing/InsertListCommand.cpp View 1 3 chunks +7 lines, -3 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
arpitab_
7 years ago (2013-12-10 09:27:45 UTC) #1
ojan
lgtm
7 years ago (2013-12-10 23:47:38 UTC) #2
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/a.bah@samsung.com/111463002/20001
7 years ago (2013-12-10 23:48:25 UTC) #3
commit-bot: I haz the power
7 years ago (2013-12-11 02:09:04 UTC) #4
Message was sent while issue was closed.
Change committed as 163661

Powered by Google App Engine
This is Rietveld 408576698