Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/SelectionController.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/SelectionController.cpp b/third_party/WebKit/Source/core/editing/SelectionController.cpp |
| index a079a51049e3e9e42e895a375a3eb1fde3484b08..feb5d2f6aac62c0822b58fed4c75f4560de296b4 100644 |
| --- a/third_party/WebKit/Source/core/editing/SelectionController.cpp |
| +++ b/third_party/WebKit/Source/core/editing/SelectionController.cpp |
| @@ -132,13 +132,16 @@ bool SelectionController::handleMousePressEventSingleClick(const MouseEventWithH |
| // Extend the selection if the Shift key is down, unless the click is in a link or image. |
| bool extendSelection = isExtendingSelection(event); |
| + VisibleSelectionInFlatTree newSelection = selection().visibleSelection<EditingInFlatTreeStrategy>(); |
| + |
| // Don't restart the selection when the mouse is pressed on an |
| // existing selection so we can allow for text dragging. |
| if (FrameView* view = m_frame->view()) { |
| LayoutPoint vPoint = view->rootFrameToContents(event.event().position()); |
| if (!extendSelection && selection().contains(vPoint)) { |
| m_mouseDownWasSingleClickInSelection = true; |
| - return false; |
| + if (newSelection.isHandleVisible() || !event.event().fromTouch()) |
| + return false; |
| } |
| } |
| @@ -147,10 +150,11 @@ bool SelectionController::handleMousePressEventSingleClick(const MouseEventWithH |
| visiblePos = createVisiblePosition(PositionInFlatTree::firstPositionInOrBeforeNode(innerNode)); |
| PositionInFlatTree pos = visiblePos.deepEquivalent(); |
| - VisibleSelectionInFlatTree newSelection = selection().visibleSelection<EditingInFlatTreeStrategy>(); |
| TextGranularity granularity = CharacterGranularity; |
| - if (extendSelection && !newSelection.isNone()) { |
| + if (mouseDownWasSingleClickInSelection()) { |
| + newSelection.setIsHandleVisible(true); |
| + } else if (extendSelection && !newSelection.isNone()) { |
| const VisibleSelectionInFlatTree selectionInUserSelectAll(expandSelectionToRespectUserSelectAll(innerNode, VisibleSelectionInFlatTree(createVisiblePosition(pos)))); |
| if (selectionInUserSelectAll.isRange()) { |
| if (selectionInUserSelectAll.start().compareTo(newSelection.start()) < 0) |
| @@ -182,6 +186,12 @@ bool SelectionController::handleMousePressEventSingleClick(const MouseEventWithH |
| } |
| } else if (m_selectionState != SelectionState::ExtendedSelection) { |
| newSelection = expandSelectionToRespectUserSelectAll(innerNode, VisibleSelectionInFlatTree(visiblePos)); |
| + if (newSelection.isContentEditable()) { |
| + bool isTextBoxEmpty = VisibleSelection::selectionFromContentsOfNode(innerNode).isCaret(); |
| + bool isRightClick = event.event().button() == RightButton; |
| + if (!isTextBoxEmpty || isRightClick) |
| + newSelection.setIsHandleVisible(event.event().fromTouch()); |
|
aelias_OOO_until_Jul13
2016/08/08 21:30:51
The changes in this file are intentionally changin
|
| + } |
| } |
| // Updating the selection is considered side-effect of the event and so it doesn't impact the handled state. |
| @@ -325,6 +335,7 @@ void SelectionController::selectClosestWordFromHitTestResult(const HitTestResult |
| if (newSelection.rootEditableElement() && pos.deepEquivalent() == VisiblePositionInFlatTree::lastPositionInNode(newSelection.rootEditableElement()).deepEquivalent()) |
| return; |
| + newSelection.setIsHandleVisible(true); |
| } |
| if (appendTrailingWhitespace == AppendTrailingWhitespace::ShouldAppend && newSelection.isRange()) |
| @@ -450,6 +461,8 @@ bool SelectionController::handleMousePressEventTripleClick(const MouseEventWithH |
| newSelection.expandUsingGranularity(ParagraphGranularity); |
| } |
| + newSelection.setIsHandleVisible(event.event().fromTouch()); |
| + |
| return updateSelectionForMouseDownDispatchingSelectStart(innerNode, expandSelectionToRespectUserSelectAll(innerNode, newSelection), ParagraphGranularity); |
| } |
| @@ -584,6 +597,18 @@ bool SelectionController::handleGestureLongPress(const PlatformGestureEvent& ges |
| if (!innerNodeIsSelectable) |
| return false; |
| + // If longpress occurs inside of a selection that doesn't have handles |
| + // then we want to show the handes on the entire selection. |
| + if (FrameView* view = m_frame->view()) { |
| + LayoutPoint vPoint = view->rootFrameToContents(gestureEvent.position()); |
| + VisibleSelectionInFlatTree newSelection = selection().visibleSelection<EditingInFlatTreeStrategy>(); |
| + if (selection().contains(vPoint) && !newSelection.isHandleVisible()) { |
|
aelias_OOO_until_Jul13
2016/08/08 21:30:51
FrameSelection::contains() performs another hit te
amaralp
2016/10/14 00:53:07
Done.
|
| + newSelection.setIsHandleVisible(true); |
| + selection().setNonDirectionalSelectionIfNeeded(newSelection, selection().granularity()); |
| + return true; |
| + } |
| + } |
| + |
| selectClosestWordFromHitTestResult(hitTestResult, AppendTrailingWhitespace::DontAppend, SelectInputEventType::Touch); |
| if (!selection().isAvailable()) { |
| // "editing/selection/longpress-selection-in-iframe-removed-crash.html" |