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

Review URL: https://codereview.chromium.org/111463002

git-svn-id: svn://svn.chromium.org/blink/trunk@163661 bbb929c8-8fbe-4397-9dbb-9b2b20218538