When trying to break a line after an image followed by some text, contrary to the expected behavior the text doesn't move to a new line, instead, the caret position just shifts to the end of line.

As per the existing implementation for inserting a paragraph separator,
the insertion position obtained corresponds to the point after the image
element.
Since the insertion position doesn't resolve to being offset in the
following text node (0 offset), no splitting of text occurs and the block
to be inserted is placed after the containing (start) block (thereby
causing the caret position to shift).

If the computed insertionPosition points to an element that shall be
ignored for editing purposes (i.e. cannot have a VisiblePosition inside
it), and the position lies either at the start or at the end of such
an element, we should move our Position either upstream or
downstream (respectively) so as to obtain a valid position which can
be used further for splitting of the text.

Moving the insertionPosition either upstream or downstream, if the point
lies either at the start or at the end of the anchor node.
The ensuing position, if a text node, can then be used for splitting of
the text correctly.

This patch has landed in Webkit: https://trac.webkit.org/changeset/151604

BUG=251209
R=leviw@chromium.org

Review URL: https://chromiumcodereview.appspot.com/17381003

git-svn-id: svn://svn.chromium.org/blink/trunk@153866 bbb929c8-8fbe-4397-9dbb-9b2b20218538
3 files changed