Changeset 147467 in webkit


Ignore:
Timestamp:
Apr 2, 2013 11:17:10 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[BlackBerry] Create a selection from two points irregardless of the caret position.
https://bugs.webkit.org/show_bug.cgi?id=113795

Patch by Nima Ghanavatian <nghanavatian@blackberry.com> on 2013-04-02
Reviewed by Rob Buis.

Internally reviewed by Mike Fenton.

PR276577
If we are to set both the base and extent of a selection, we should maintain the base upon setting the extent.
This prevents us from overwriting the previous calculation when setting extent.
Further, instead of setting and manipulating the selection, simply set up start and end VisiblePositions and
create a new directional selection so as to set the base and extent simultaneously.

  • WebKitSupport/SelectionHandler.cpp:

(BlackBerry::WebKit::SelectionHandler::setSelection):

Location:
trunk/Source/WebKit/blackberry
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/blackberry/ChangeLog

    r147386 r147467  
     12013-04-02  Nima Ghanavatian  <nghanavatian@blackberry.com>
     2
     3        [BlackBerry] Create a selection from two points irregardless of the caret position.
     4        https://bugs.webkit.org/show_bug.cgi?id=113795
     5
     6        Reviewed by Rob Buis.
     7
     8        Internally reviewed by Mike Fenton.
     9
     10        PR276577
     11        If we are to set both the base and extent of a selection, we should maintain the base upon setting the extent.
     12        This prevents us from overwriting the previous calculation when setting extent.
     13        Further, instead of setting and manipulating the selection, simply set up start and end VisiblePositions and
     14        create a new directional selection so as to set the base and extent simultaneously.
     15
     16        * WebKitSupport/SelectionHandler.cpp:
     17        (BlackBerry::WebKit::SelectionHandler::setSelection):
     18
    1192013-04-01  Konrad Piascik  <kpiascik@blackberry.com>
    220
  • trunk/Source/WebKit/blackberry/WebKitSupport/SelectionHandler.cpp

    r147189 r147467  
    508508    WebCore::IntPoint relativeEnd = end;
    509509
    510     VisibleSelection newSelection(controller->selection());
    511 
    512     // We need the selection to be ordered base then extent.
    513     if (!controller->selection().isBaseFirst())
    514         controller->setSelection(VisibleSelection(controller->selection().start(), controller->selection().end(), true /* isDirectional */));
     510    // Initialize the new start and end of our selection at the current positions.
     511    VisiblePosition newStart = controller->selection().visibleStart();
     512    VisiblePosition newEnd = controller->selection().visibleEnd();
    515513
    516514    // We don't return early in the following, so that we can do input field scrolling if the
     
    519517    if (startIsValid) {
    520518        relativeStart = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), focusedFrame, start);
    521 
    522519        VisiblePosition base = visiblePositionForPointIgnoringClipping(*focusedFrame, clipPointToVisibleContainer(start));
    523         if (base.isNotNull()) {
    524             // The function setBase validates the "base"
    525             newSelection.setBase(base);
    526             newSelection.setWithoutValidation(newSelection.base(), controller->selection().end());
    527             // Don't return early.
    528         }
     520        if (base.isNotNull())
     521            newStart = base;
    529522    }
    530523
    531524    if (m_lastUpdatedEndPointIsValid) {
    532525        relativeEnd = DOMSupport::convertPointToFrame(m_webPage->mainFrame(), focusedFrame, end);
    533 
    534526        VisiblePosition extent = visiblePositionForPointIgnoringClipping(*focusedFrame, clipPointToVisibleContainer(end));
    535         if (extent.isNotNull()) {
    536             // The function setExtent validates the "extent"
    537             newSelection.setExtent(extent);
    538             newSelection.setWithoutValidation(controller->selection().start(), newSelection.extent());
    539             // Don't return early.
    540         }
    541     }
     527        if (extent.isNotNull())
     528            newEnd = extent;
     529    }
     530
     531    VisibleSelection newSelection(newStart, newEnd, true /* isDirectional */);
    542532
    543533    if (!controller->selection().isRange())
    544534        m_webPage->updateSelectionScrollView(newSelection.visibleEnd().deepEquivalent().anchorNode());
    545 
    546     newSelection.setIsDirectional(true);
    547535
    548536    if (m_webPage->m_inputHandler->isInputMode()) {
Note: See TracChangeset for help on using the changeset viewer.