Changeset 151604 in webkit


Ignore:
Timestamp:
Jun 14, 2013 1:13:57 PM (11 years ago)
Author:
a.bah@samsung.com
Message:

Editing: wrong text position when you click enter on the text behind the image
https://bugs.webkit.org/show_bug.cgi?id=115023

Reviewed by Ryosuke Niwa.

Source/WebCore:

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.

Test: editing/inserting/insert-paragraph-after-non-editable-node-before-text.html

  • editing/InsertParagraphSeparatorCommand.cpp:

(WebCore::InsertParagraphSeparatorCommand::doApply):
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.

LayoutTests:

  • editing/inserting/insert-paragraph-after-non-editable-node-before-text-expected.txt: Added.
  • editing/inserting/insert-paragraph-after-non-ediatble-node-before-text.html: Added.

Layout test added for verifying the insert paragraph behavior between an inline node
which is ignored for editing purposes and some text.

Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r151600 r151604  
     12013-06-14  Arpita Bahuguna  <a.bah@samsung.com>
     2
     3        Editing: wrong text position when you click enter on the text behind the image
     4        https://bugs.webkit.org/show_bug.cgi?id=115023
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * editing/inserting/insert-paragraph-after-non-editable-node-before-text-expected.txt: Added.
     9        * editing/inserting/insert-paragraph-after-non-ediatble-node-before-text.html: Added.
     10        Layout test added for verifying the insert paragraph behavior between an inline node
     11        which is ignored for editing purposes and some text.
     12
    1132013-06-14  Eric Carlson  <eric.carlson@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r151603 r151604  
     12013-06-14  Arpita Bahuguna  <a.bah@samsung.com>
     2
     3        Editing: wrong text position when you click enter on the text behind the image
     4        https://bugs.webkit.org/show_bug.cgi?id=115023
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        When trying to break a line after an image followed by some text, contrary
     9        to the expected behavior the text doesn't move to a new line, instead, the
     10        caret position just shifts to the end of line.
     11
     12        As per the existing implementation for inserting a paragraph separator,
     13        the insertion position obtained corresponds to the point after the image
     14        element.
     15        Since the insertion position doesn't resolve to being offset in the
     16        following text node (0 offset), no splitting of text occurs and the block
     17        to be inserted is placed after the containing (start) block (thereby
     18        causing the caret position to shift).
     19
     20        If the computed insertionPosition points to an element that shall be
     21        ignored for editing purposes (i.e. cannot have a VisiblePosition inside
     22        it), and the position lies either at the start or at the end of such
     23        an element, we should move our Position either upstream or
     24        downstream (respectively) so as to obtain a valid position which can
     25        be used further for splitting of the text.
     26       
     27        Test: editing/inserting/insert-paragraph-after-non-editable-node-before-text.html
     28
     29        * editing/InsertParagraphSeparatorCommand.cpp:
     30        (WebCore::InsertParagraphSeparatorCommand::doApply):
     31        Moving the insertionPosition either upstream or downstream, if the point
     32        lies either at the start or at the end of the anchor node.
     33        The ensuing position, if a text node, can then be used for splitting of
     34        the text correctly.
     35
    1362013-06-14  Alberto Garcia  <agarcia@igalia.com>
    237
  • trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp

    r150481 r151604  
    318318    insertionPosition = positionOutsideTabSpan(VisiblePosition(insertionPosition).deepEquivalent());
    319319
     320    // If the returned position lies either at the end or at the start of an element that is ignored by editing
     321    // we should move to its upstream or downstream position.
     322    if (editingIgnoresContent(insertionPosition.deprecatedNode())) {
     323        if (insertionPosition.atLastEditingPositionForNode())
     324            insertionPosition = insertionPosition.downstream();
     325        else if (insertionPosition.atFirstEditingPositionForNode())
     326            insertionPosition = insertionPosition.upstream();
     327    }
     328
    320329    // Make sure we do not cause a rendered space to become unrendered.
    321330    // FIXME: We need the affinity for pos, but pos.downstream() does not give it
Note: See TracChangeset for help on using the changeset viewer.