Changeset 164194 in webkit


Ignore:
Timestamp:
Feb 16, 2014 2:00:21 PM (10 years ago)
Author:
rniwa@webkit.org
Message:

setSelectionRange shouldn't directly instantiate VisibleSelection
https://bugs.webkit.org/show_bug.cgi?id=128881

Reviewed by Andreas Kling.

Added a new version of moveTo for setSelectionRange.

  • editing/FrameSelection.cpp:

(WebCore::FrameSelection::moveTo): Added.

  • editing/FrameSelection.h:
  • html/HTMLTextFormControlElement.cpp:

(WebCore::HTMLTextFormControlElement::setSelectionRange): Use the newly added FrameSelection::moveTo
instead of manually instantiating VisibleSelection here.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r164192 r164194  
     12014-02-16  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        setSelectionRange shouldn't directly instantiate VisibleSelection
     4        https://bugs.webkit.org/show_bug.cgi?id=128881
     5
     6        Reviewed by Andreas Kling.
     7
     8        Added a new version of moveTo for setSelectionRange.
     9
     10        * editing/FrameSelection.cpp:
     11        (WebCore::FrameSelection::moveTo): Added.
     12        * editing/FrameSelection.h:
     13        * html/HTMLTextFormControlElement.cpp:
     14        (WebCore::HTMLTextFormControlElement::setSelectionRange): Use the newly added FrameSelection::moveTo
     15        instead of manually instantiating VisibleSelection here.
     16
    1172014-02-16  Dan Bernstein  <mitz@apple.com>
    218
  • trunk/Source/WebCore/editing/FrameSelection.cpp

    r164186 r164194  
    163163    const bool selectionHasDirection = true;
    164164    setSelection(VisibleSelection(base, extent, affinity, selectionHasDirection), defaultSetSelectionOptions(userTriggered));
     165}
     166
     167void FrameSelection::moveTo(const Position& base, const Position& extent, bool selectionHasDirection, bool shouldSetFocus)
     168{
     169    setSelection(VisibleSelection(base, extent, DOWNSTREAM, selectionHasDirection),
     170        defaultSetSelectionOptions() | (shouldSetFocus ? 0 : DoNotSetFocus));
    165171}
    166172
  • trunk/Source/WebCore/editing/FrameSelection.h

    r164186 r164194  
    141141    void moveTo(const Position&, EAffinity, EUserTriggered = NotUserTriggered);
    142142    void moveTo(const Position&, const Position&, EAffinity, EUserTriggered = NotUserTriggered);
     143    void moveTo(const Position&, const Position&, bool selectionHasDirection, bool shouldSetFocus);
    143144
    144145    const VisibleSelection& selection() const { return m_selection; }
  • trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp

    r164183 r164194  
    307307    if (start == end)
    308308        endPosition = startPosition;
    309     else
    310         endPosition = positionForIndex(innerText, end);
    311 
    312     VisibleSelection newSelection;
    313     if (direction == SelectionHasBackwardDirection)
    314         newSelection = VisibleSelection(endPosition, startPosition);
    315     else
    316         newSelection = VisibleSelection(startPosition, endPosition);
    317     newSelection.setIsDirectional(direction != SelectionHasNoDirection);
    318 
    319     FrameSelection::SetSelectionOptions options = FrameSelection::defaultSetSelectionOptions();
    320     if (hasFocus)
    321         options |= FrameSelection::DoNotSetFocus;
     309    else {
     310        if (direction == SelectionHasBackwardDirection) {
     311            endPosition = startPosition;
     312            startPosition = positionForIndex(innerText, end);
     313        } else
     314            endPosition = positionForIndex(innerText, end);
     315    }
     316
    322317    if (Frame* frame = document().frame())
    323         frame->selection().setSelection(newSelection, options);
     318        frame->selection().moveTo(startPosition, endPosition, direction != SelectionHasNoDirection, !hasFocus);
    324319}
    325320
Note: See TracChangeset for help on using the changeset viewer.