Changeset 158186 in webkit


Ignore:
Timestamp:
Oct 29, 2013 1:38:22 AM (10 years ago)
Author:
commit-queue@webkit.org
Message:

Text selected with double-click gets unselected after DOM modification
https://bugs.webkit.org/show_bug.cgi?id=114227

Patch by Santosh Mahto <santosh.ma@samsung.com> on 2013-10-29
Reviewed by Ryosuke Niwa.

Source/WebCore:

Before this patch when selection is done by double-click (start and base remain
same) and DOM is modified then selection gets vanished. This does not
happen when selection is done by dragging mouse. This happens because
on double-click base and extent remain the same and on DOM
modification we update the selection with base and extent, so we loose
the selection. Since in double-click case start/end contain the
correct selection, same should be used after dom modification to
update selection.

Test: editing/selection/double-click-selection-with-dom-mutation.html

  • editing/FrameSelection.cpp:

(WebCore::FrameSelection::textWasReplaced): use start/end to update
selection in case double click selection. Added a check for base !=
extent, if base != extent use base/extent to update the selection
otherwise use start/end with directionality check.

LayoutTests:

New Testcase to test that selection remain intact when selection is
created by double-click and then dom is modified.

  • editing/selection/double-click-selection-with-dom-mutation-expected.txt: Added.
  • editing/selection/double-click-selection-with-dom-mutation.html: Added.

Rebaselined the below test cases.

  • platform/mac/editing/deleting/smart-delete-003-expected.txt:
  • platform/mac/editing/deleting/smart-delete-004-expected.txt:
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r158184 r158186  
     12013-10-29  Santosh Mahto  <santosh.ma@samsung.com>
     2
     3        Text selected with double-click gets unselected after DOM modification
     4        https://bugs.webkit.org/show_bug.cgi?id=114227
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        New Testcase to test that selection remain intact when selection is
     9        created by double-click and then dom is modified.
     10
     11        * editing/selection/double-click-selection-with-dom-mutation-expected.txt: Added.
     12        * editing/selection/double-click-selection-with-dom-mutation.html: Added.
     13
     14        Rebaselined the below test cases.
     15        * platform/mac/editing/deleting/smart-delete-003-expected.txt:
     16        * platform/mac/editing/deleting/smart-delete-004-expected.txt:
     17
    1182013-10-29  Mihnea Ovidenie  <mihnea@adobe.com>
    219
  • trunk/LayoutTests/platform/mac/editing/deleting/smart-delete-003-expected.txt

    r96264 r158186  
    77EDITING DELEGATE: shouldDeleteDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document
    88EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     9EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     10EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of #text > DIV > BODY > HTML > #document to 0 of #text > DIV > BODY > HTML > #document toDOMRange:range from 3 of #text > DIV > BODY > HTML > #document to 3 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    911EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1012EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
  • trunk/LayoutTests/platform/mac/editing/deleting/smart-delete-004-expected.txt

    r96264 r158186  
    77EDITING DELEGATE: shouldDeleteDOMRange:range from 4 of #text > DIV > BODY > HTML > #document to 1 of #text > DIV > BODY > HTML > #document
    88EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     9EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
     10EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 3 of #text > DIV > BODY > HTML > #document to 0 of #text > DIV > BODY > HTML > #document toDOMRange:range from 3 of #text > DIV > BODY > HTML > #document to 3 of #text > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
    911EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
    1012EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
  • trunk/Source/WebCore/ChangeLog

    r158184 r158186  
     12013-10-29  Santosh Mahto  <santosh.ma@samsung.com>
     2
     3        Text selected with double-click gets unselected after DOM modification
     4        https://bugs.webkit.org/show_bug.cgi?id=114227
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Before this patch when selection is done by double-click (start and base remain
     9        same) and DOM is modified then selection gets vanished. This does not
     10        happen when selection is done by dragging mouse. This happens because
     11        on double-click base and extent remain the same and on DOM
     12        modification we update the selection with base and extent, so we loose
     13        the selection. Since in double-click case start/end contain the
     14        correct selection, same should be used after dom modification to
     15        update selection.
     16
     17        Test: editing/selection/double-click-selection-with-dom-mutation.html
     18
     19        * editing/FrameSelection.cpp:
     20        (WebCore::FrameSelection::textWasReplaced): use start/end to update
     21        selection in case double click selection. Added a check for base !=
     22        extent, if base != extent use base/extent to update the selection
     23        otherwise use start/end with directionality check.
     24
    1252013-10-29  Mihnea Ovidenie  <mihnea@adobe.com>
    226
  • trunk/Source/WebCore/editing/FrameSelection.cpp

    r158163 r158186  
    461461    if (base != m_selection.base() || extent != m_selection.extent() || start != m_selection.start() || end != m_selection.end()) {
    462462        VisibleSelection newSelection;
    463         newSelection.setWithoutValidation(base, extent);
     463        if (base != extent)
     464            newSelection.setWithoutValidation(base, extent);
     465        else if (m_selection.isDirectional() && !m_selection.isBaseFirst())
     466            newSelection.setWithoutValidation(end, start);
     467        else
     468            newSelection.setWithoutValidation(start, end);
     469
    464470        m_frame->document()->updateLayout();
    465471        setSelection(newSelection, DoNotSetFocus);
Note: See TracChangeset for help on using the changeset viewer.