Title: [164194] trunk/Source/WebCore
- Revision
- 164194
- Author
- [email protected]
- Date
- 2014-02-16 14:00:21 -0800 (Sun, 16 Feb 2014)
Log 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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (164193 => 164194)
--- trunk/Source/WebCore/ChangeLog 2014-02-16 21:38:16 UTC (rev 164193)
+++ trunk/Source/WebCore/ChangeLog 2014-02-16 22:00:21 UTC (rev 164194)
@@ -1,3 +1,19 @@
+2014-02-16 Ryosuke Niwa <[email protected]>
+
+ 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.
+
2014-02-16 Dan Bernstein <[email protected]>
Stop using PLATFORM(MAC) in Source except where it means “OS X but not iOS”
Modified: trunk/Source/WebCore/editing/FrameSelection.cpp (164193 => 164194)
--- trunk/Source/WebCore/editing/FrameSelection.cpp 2014-02-16 21:38:16 UTC (rev 164193)
+++ trunk/Source/WebCore/editing/FrameSelection.cpp 2014-02-16 22:00:21 UTC (rev 164194)
@@ -164,6 +164,12 @@
setSelection(VisibleSelection(base, extent, affinity, selectionHasDirection), defaultSetSelectionOptions(userTriggered));
}
+void FrameSelection::moveTo(const Position& base, const Position& extent, bool selectionHasDirection, bool shouldSetFocus)
+{
+ setSelection(VisibleSelection(base, extent, DOWNSTREAM, selectionHasDirection),
+ defaultSetSelectionOptions() | (shouldSetFocus ? 0 : DoNotSetFocus));
+}
+
void DragCaretController::setCaretPosition(const VisiblePosition& position)
{
if (Node* node = m_position.deepEquivalent().deprecatedNode())
Modified: trunk/Source/WebCore/editing/FrameSelection.h (164193 => 164194)
--- trunk/Source/WebCore/editing/FrameSelection.h 2014-02-16 21:38:16 UTC (rev 164193)
+++ trunk/Source/WebCore/editing/FrameSelection.h 2014-02-16 22:00:21 UTC (rev 164194)
@@ -140,6 +140,7 @@
void moveTo(const VisiblePosition&, const VisiblePosition&, EUserTriggered = NotUserTriggered);
void moveTo(const Position&, EAffinity, EUserTriggered = NotUserTriggered);
void moveTo(const Position&, const Position&, EAffinity, EUserTriggered = NotUserTriggered);
+ void moveTo(const Position&, const Position&, bool selectionHasDirection, bool shouldSetFocus);
const VisibleSelection& selection() const { return m_selection; }
void setSelection(const VisibleSelection&, SetSelectionOptions = defaultSetSelectionOptions(), CursorAlignOnScroll = AlignCursorOnScrollIfNeeded, TextGranularity = CharacterGranularity);
Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (164193 => 164194)
--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp 2014-02-16 21:38:16 UTC (rev 164193)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp 2014-02-16 22:00:21 UTC (rev 164194)
@@ -306,21 +306,16 @@
Position endPosition;
if (start == end)
endPosition = startPosition;
- else
- endPosition = positionForIndex(innerText, end);
+ else {
+ if (direction == SelectionHasBackwardDirection) {
+ endPosition = startPosition;
+ startPosition = positionForIndex(innerText, end);
+ } else
+ endPosition = positionForIndex(innerText, end);
+ }
- VisibleSelection newSelection;
- if (direction == SelectionHasBackwardDirection)
- newSelection = VisibleSelection(endPosition, startPosition);
- else
- newSelection = VisibleSelection(startPosition, endPosition);
- newSelection.setIsDirectional(direction != SelectionHasNoDirection);
-
- FrameSelection::SetSelectionOptions options = FrameSelection::defaultSetSelectionOptions();
- if (hasFocus)
- options |= FrameSelection::DoNotSetFocus;
if (Frame* frame = document().frame())
- frame->selection().setSelection(newSelection, options);
+ frame->selection().moveTo(startPosition, endPosition, direction != SelectionHasNoDirection, !hasFocus);
}
int HTMLTextFormControlElement::indexForVisiblePosition(const VisiblePosition& position) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes