Changeset 83967 in webkit


Ignore:
Timestamp:
Apr 15, 2011 6:44:54 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-04-15 Alice Boxhall <aboxhall@chromium.org>

Reviewed by Ryosuke Niwa.

Text selection changes unexpectedly when dragging out of the <input>
https://bugs.webkit.org/show_bug.cgi?id=55552

Tests that dragging outside of a contenteditable, input or textarea selects to the end of the
element, rather than jumping back to the beginning.

  • editing/selection/resources/select-out-of-floated-editable.js: Added. (log): (else.window.onmouseup): (getSelectionStart): (getSelectionEnd): (checkSelection):
  • editing/selection/select-out-of-editable-expected.txt: Added.
  • editing/selection/select-out-of-editable.html: Added.
  • editing/selection/select-out-of-floated-contenteditable-expected.txt: Added.
  • editing/selection/select-out-of-floated-contenteditable.html: Added.
  • editing/selection/select-out-of-floated-input-expected.txt: Added.
  • editing/selection/select-out-of-floated-input.html: Added.
  • editing/selection/select-out-of-floated-textarea-expected.txt: Added.
  • editing/selection/select-out-of-floated-textarea.html: Added.

2011-04-15 Alice Boxhall <aboxhall@chromium.org>

Reviewed by Ryosuke Niwa.

Text selection changes unexpectedly when dragging out of the <input>
https://bugs.webkit.org/show_bug.cgi?id=55552

Tests: editing/selection/select-out-of-editable.html

editing/selection/select-out-of-floated-contenteditable.html
editing/selection/select-out-of-floated-input.html
editing/selection/select-out-of-floated-textarea.html

  • page/EventHandler.cpp: (WebCore::selectionExtentRespectingEditingBoundary): When dragging from an editable element, check that the endpoint is not outside the element. If it is, translate the point into a local point within the editable element. (WebCore::EventHandler::updateSelectionForMouseDrag): Call targetPositionForSelectionEndpoint() to calculate the selection endpoint.
Location:
trunk
Files:
9 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r83966 r83967  
     12011-04-15  Alice Boxhall  <aboxhall@chromium.org>
     2
     3        Reviewed by Ryosuke Niwa.
     4
     5        Text selection changes unexpectedly when dragging out of the <input>
     6        https://bugs.webkit.org/show_bug.cgi?id=55552
     7
     8        Tests that dragging outside of a contenteditable, input or textarea selects to the end of the
     9        element, rather than jumping back to the beginning.
     10
     11        * editing/selection/resources/select-out-of-floated-editable.js: Added.
     12        (log):
     13        (else.window.onmouseup):
     14        (getSelectionStart):
     15        (getSelectionEnd):
     16        (checkSelection):
     17        * editing/selection/select-out-of-editable-expected.txt: Added.
     18        * editing/selection/select-out-of-editable.html: Added.
     19        * editing/selection/select-out-of-floated-contenteditable-expected.txt: Added.
     20        * editing/selection/select-out-of-floated-contenteditable.html: Added.
     21        * editing/selection/select-out-of-floated-input-expected.txt: Added.
     22        * editing/selection/select-out-of-floated-input.html: Added.
     23        * editing/selection/select-out-of-floated-textarea-expected.txt: Added.
     24        * editing/selection/select-out-of-floated-textarea.html: Added.
     25
    1262011-04-15  Adam Roben  <aroben@apple.com>
    227
  • trunk/Source/WebCore/ChangeLog

    r83963 r83967  
     12011-04-15  Alice Boxhall  <aboxhall@chromium.org>
     2
     3        Reviewed by Ryosuke Niwa.
     4
     5        Text selection changes unexpectedly when dragging out of the <input>
     6        https://bugs.webkit.org/show_bug.cgi?id=55552
     7
     8        Tests: editing/selection/select-out-of-editable.html
     9               editing/selection/select-out-of-floated-contenteditable.html
     10               editing/selection/select-out-of-floated-input.html
     11               editing/selection/select-out-of-floated-textarea.html
     12
     13        * page/EventHandler.cpp:
     14        (WebCore::selectionExtentRespectingEditingBoundary): When dragging from an editable element, check that
     15        the endpoint is not outside the element. If it is, translate the point into a local point within
     16        the editable element.
     17        (WebCore::EventHandler::updateSelectionForMouseDrag): Call targetPositionForSelectionEndpoint() to
     18        calculate the selection endpoint.
     19
    1202011-04-15  Adam Roben  <aroben@apple.com>
    221
  • trunk/Source/WebCore/page/EventHandler.cpp

    r83832 r83967  
    623623}
    624624
     625static VisiblePosition selectionExtentRespectingEditingBoundary(const VisibleSelection& selection, const IntPoint& localPoint, Node* targetNode)
     626{
     627    IntPoint selectionEndPoint = localPoint;
     628    Element* editableElement = selection.rootEditableElement();
     629    Node* selectionEndNode = targetNode;
     630
     631    if (editableElement && !editableElement->contains(targetNode)) {
     632        selectionEndNode = editableElement;
     633
     634        if (!selectionEndNode->renderer())
     635            return VisiblePosition();
     636
     637        FloatPoint absolutePoint = targetNode->renderer()->localToAbsolute(FloatPoint(selectionEndPoint));
     638        selectionEndPoint = roundedIntPoint(selectionEndNode->renderer()->absoluteToLocal(absolutePoint));
     639    }
     640
     641    if (!selectionEndNode->renderer())
     642        return VisiblePosition();
     643
     644    return selectionEndNode->renderer()->positionForPoint(selectionEndPoint);
     645}
     646
    625647void EventHandler::updateSelectionForMouseDrag(const HitTestResult& hitTestResult)
    626648{
     
    635657        return;
    636658
    637     RenderObject* targetRenderer = target->renderer();
    638     if (!targetRenderer)
    639         return;
    640 
    641     VisiblePosition targetPosition = targetRenderer->positionForPoint(hitTestResult.localPoint());
     659    VisiblePosition targetPosition = selectionExtentRespectingEditingBoundary(m_frame->selection()->selection(), hitTestResult.localPoint(), target);
    642660
    643661    // Don't modify the selection if we're not on a node.
Note: See TracChangeset for help on using the changeset viewer.