Changeset 181465 in webkit


Ignore:
Timestamp:
Mar 12, 2015, 5:57:10 PM (10 years ago)
Author:
rniwa@webkit.org
Message:

REGRESSION(r180726): Removing an empty line at the end of textarea clears the entire texture
https://bugs.webkit.org/show_bug.cgi?id=142646

Reviewed by Darin Adler.

Source/WebCore:

The bug was caused by TypingCommand::deleteKeyPressed erroneously determining the editable root to be empty because
Position::atStartOfTree returns true when it's anchored at a BR that is immediately below the root editable element.

Fixed the bug by replacing the use of the deprecated atFirstEditingPositionForNode by a code that understands modern
position types such as PositionIsBeforeAnchor in atStartOfTree and atEndOfTree. These two functions will no longer
return true when anchored before or after BR after this patch.

Test: editing/deleting/delete-empty-line-breaks-at-end-of-textarea.html

  • dom/Position.cpp:

(WebCore::Position::atStartOfTree):
(WebCore::Position::atEndOfTree):

LayoutTests:

Added a regression test for deleting empty lines at the end of a textarea element.

  • editing/deleting/delete-empty-line-breaks-at-end-of-textarea-expected.txt: Added.
  • editing/deleting/delete-empty-line-breaks-at-end-of-textarea.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r181458 r181465  
     12015-03-12  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        REGRESSION(r180726): Removing an empty line at the end of textarea clears the entire texture
     4        https://bugs.webkit.org/show_bug.cgi?id=142646
     5
     6        Reviewed by Darin Adler.
     7
     8        Added a regression test for deleting empty lines at the end of a textarea element.
     9
     10        * editing/deleting/delete-empty-line-breaks-at-end-of-textarea-expected.txt: Added.
     11        * editing/deleting/delete-empty-line-breaks-at-end-of-textarea.html: Added.
     12
    1132015-03-12  Yusuke Suzuki  <utatane.tea@gmail.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r181458 r181465  
     12015-03-12  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        REGRESSION(r180726): Removing an empty line at the end of textarea clears the entire texture
     4        https://bugs.webkit.org/show_bug.cgi?id=142646
     5
     6        Reviewed by Darin Adler.
     7
     8        The bug was caused by TypingCommand::deleteKeyPressed erroneously determining the editable root to be empty because
     9        Position::atStartOfTree returns true when it's anchored at a BR that is immediately below the root editable element.
     10
     11        Fixed the bug by replacing the use of the deprecated atFirstEditingPositionForNode by a code that understands modern
     12        position types such as PositionIsBeforeAnchor in atStartOfTree and atEndOfTree. These two functions will no longer
     13        return true when anchored before or after BR after this patch.
     14
     15        Test: editing/deleting/delete-empty-line-breaks-at-end-of-textarea.html
     16
     17        * dom/Position.cpp:
     18        (WebCore::Position::atStartOfTree):
     19        (WebCore::Position::atEndOfTree):
     20
    1212015-03-12  Yusuke Suzuki  <utatane.tea@gmail.com>
    222
  • trunk/Source/WebCore/dom/Position.cpp

    r181166 r181465  
    477477    if (isNull())
    478478        return true;
    479     return !findParent(containerNode()) && atFirstEditingPositionForNode();
     479    if (findParent(containerNode()))
     480        return false;
     481
     482    switch (m_anchorType) {
     483    case PositionIsOffsetInAnchor:
     484        return m_offset <= 0;
     485    case PositionIsBeforeAnchor:
     486        return !m_anchorNode->previousSibling();
     487    case PositionIsAfterAnchor:
     488        return false;
     489    case PositionIsBeforeChildren:
     490        return true;
     491    case PositionIsAfterChildren:
     492        return !lastOffsetForEditing(m_anchorNode.get());
     493    }
     494    ASSERT_NOT_REACHED();
     495    return false;
    480496}
    481497
     
    484500    if (isNull())
    485501        return true;
    486     return !findParent(containerNode()) && atLastEditingPositionForNode();
     502    if (findParent(containerNode()))
     503        return false;
     504
     505    switch (m_anchorType) {
     506    case PositionIsOffsetInAnchor:
     507        return m_offset >= lastOffsetForEditing(m_anchorNode.get());
     508    case PositionIsBeforeAnchor:
     509        return false;
     510    case PositionIsAfterAnchor:
     511        return !m_anchorNode->nextSibling();
     512    case PositionIsBeforeChildren:
     513        return !lastOffsetForEditing(m_anchorNode.get());
     514    case PositionIsAfterChildren:
     515        return true;
     516    }
     517    ASSERT_NOT_REACHED();
     518    return false;
    487519}
    488520
Note: See TracChangeset for help on using the changeset viewer.