| 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 774596b2f5a31a260475f316bac27afaf479c1d2..418007b62b09be88fcbc18917ced0f6e9f632862 100644
|
| --- a/third_party/WebKit/Source/core/editing/SelectionController.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/SelectionController.cpp
|
| @@ -167,6 +167,16 @@ bool SelectionController::handleMousePressEventSingleClick(
|
| // link or image.
|
| bool extendSelection = isExtendingSelection(event);
|
|
|
| + // 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;
|
| + }
|
| + }
|
| +
|
| const VisiblePositionInFlatTree& visibleHitPos =
|
| visiblePositionOfHitTestResult(event.hitTestResult());
|
| const VisiblePositionInFlatTree& visiblePos =
|
| @@ -177,25 +187,6 @@ bool SelectionController::handleMousePressEventSingleClick(
|
| const VisibleSelectionInFlatTree& selection =
|
| this->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()) {
|
| - const LayoutPoint vPoint =
|
| - view->rootFrameToContents(event.event().position());
|
| - if (!extendSelection && this->selection().contains(vPoint)) {
|
| - m_mouseDownWasSingleClickInSelection = true;
|
| - if (!event.event().fromTouch())
|
| - return false;
|
| -
|
| - if (!this->selection().isHandleVisible()) {
|
| - updateSelectionForMouseDownDispatchingSelectStart(
|
| - innerNode, selection, CharacterGranularity,
|
| - HandleVisibility::Visible);
|
| - return false;
|
| - }
|
| - }
|
| - }
|
| -
|
| if (extendSelection && !selection.isNone()) {
|
| // Note: "fast/events/shift-click-user-select-none.html" makes
|
| // |pos.isNull()| true.
|
| @@ -220,37 +211,22 @@ bool SelectionController::handleMousePressEventSingleClick(
|
|
|
| updateSelectionForMouseDownDispatchingSelectStart(
|
| innerNode, createVisibleSelection(builder.build()),
|
| - this->selection().granularity(), HandleVisibility::NotVisible);
|
| + this->selection().granularity());
|
| return false;
|
| }
|
|
|
| if (m_selectionState == SelectionState::ExtendedSelection) {
|
| - updateSelectionForMouseDownDispatchingSelectStart(
|
| - innerNode, selection, CharacterGranularity,
|
| - HandleVisibility::NotVisible);
|
| + updateSelectionForMouseDownDispatchingSelectStart(innerNode, selection,
|
| + CharacterGranularity);
|
| return false;
|
| }
|
|
|
| if (visiblePos.isNull()) {
|
| updateSelectionForMouseDownDispatchingSelectStart(
|
| - innerNode, VisibleSelectionInFlatTree(), CharacterGranularity,
|
| - HandleVisibility::NotVisible);
|
| + innerNode, VisibleSelectionInFlatTree(), CharacterGranularity);
|
| return false;
|
| }
|
|
|
| - bool isHandleVisible = false;
|
| - if (hasEditableStyle(*innerNode)) {
|
| - const bool isTextBoxEmpty =
|
| - createVisibleSelection(SelectionInFlatTree::Builder()
|
| - .selectAllChildren(*innerNode)
|
| - .build())
|
| - .isCaret();
|
| - const bool notLeftClick = event.event().pointerProperties().button !=
|
| - WebPointerProperties::Button::Left;
|
| - if (!isTextBoxEmpty || notLeftClick)
|
| - isHandleVisible = event.event().fromTouch();
|
| - }
|
| -
|
| updateSelectionForMouseDownDispatchingSelectStart(
|
| innerNode,
|
| expandSelectionToRespectUserSelectAll(
|
| @@ -258,8 +234,7 @@ bool SelectionController::handleMousePressEventSingleClick(
|
| SelectionInFlatTree::Builder()
|
| .collapse(visiblePos.toPositionWithAffinity())
|
| .build())),
|
| - CharacterGranularity, isHandleVisible ? HandleVisibility::Visible
|
| - : HandleVisibility::NotVisible);
|
| + CharacterGranularity);
|
| return false;
|
| }
|
|
|
| @@ -389,15 +364,13 @@ void SelectionController::updateSelectionForMouseDrag(
|
| }
|
|
|
| setNonDirectionalSelectionIfNeeded(newSelection, selection().granularity(),
|
| - AdjustEndpointsAtBidiBoundary,
|
| - HandleVisibility::NotVisible);
|
| + AdjustEndpointsAtBidiBoundary);
|
| }
|
|
|
| bool SelectionController::updateSelectionForMouseDownDispatchingSelectStart(
|
| Node* targetNode,
|
| const VisibleSelectionInFlatTree& selection,
|
| - TextGranularity granularity,
|
| - HandleVisibility handleVisibility) {
|
| + TextGranularity granularity) {
|
| if (targetNode && targetNode->layoutObject() &&
|
| !targetNode->layoutObject()->isSelectable())
|
| return false;
|
| @@ -420,7 +393,7 @@ bool SelectionController::updateSelectionForMouseDownDispatchingSelectStart(
|
| }
|
|
|
| setNonDirectionalSelectionIfNeeded(selection, granularity,
|
| - DoNotAdjustEndpoints, handleVisibility);
|
| + DoNotAdjustEndpoints);
|
|
|
| return true;
|
| }
|
| @@ -454,7 +427,6 @@ bool SelectionController::selectClosestWordFromHitTestResult(
|
| .build());
|
| }
|
|
|
| - HandleVisibility visibility = HandleVisibility::NotVisible;
|
| if (selectInputEventType == SelectInputEventType::Touch) {
|
| // If node doesn't have text except space, tab or line break, do not
|
| // select that 'empty' area.
|
| @@ -472,8 +444,6 @@ bool SelectionController::selectClosestWordFromHitTestResult(
|
| newSelection.rootEditableElement())
|
| .deepEquivalent())
|
| return false;
|
| -
|
| - visibility = HandleVisibility::Visible;
|
| }
|
|
|
| if (appendTrailingWhitespace == AppendTrailingWhitespace::ShouldAppend)
|
| @@ -481,7 +451,7 @@ bool SelectionController::selectClosestWordFromHitTestResult(
|
|
|
| return updateSelectionForMouseDownDispatchingSelectStart(
|
| innerNode, expandSelectionToRespectUserSelectAll(innerNode, newSelection),
|
| - WordGranularity, visibility);
|
| + WordGranularity);
|
| }
|
|
|
| void SelectionController::selectClosestMisspellingFromHitTestResult(
|
| @@ -515,7 +485,7 @@ void SelectionController::selectClosestMisspellingFromHitTestResult(
|
|
|
| updateSelectionForMouseDownDispatchingSelectStart(
|
| innerNode, expandSelectionToRespectUserSelectAll(innerNode, newSelection),
|
| - WordGranularity, HandleVisibility::NotVisible);
|
| + WordGranularity);
|
| }
|
|
|
| void SelectionController::selectClosestWordFromMouseEvent(
|
| @@ -572,7 +542,7 @@ void SelectionController::selectClosestWordOrLinkFromMouseEvent(
|
|
|
| updateSelectionForMouseDownDispatchingSelectStart(
|
| innerNode, expandSelectionToRespectUserSelectAll(innerNode, newSelection),
|
| - WordGranularity, HandleVisibility::NotVisible);
|
| + WordGranularity);
|
| }
|
|
|
| // TODO(xiaochengh): We should not use reference to return value.
|
| @@ -630,8 +600,7 @@ static void adjustEndpointsAtBidiBoundary(
|
| void SelectionController::setNonDirectionalSelectionIfNeeded(
|
| const VisibleSelectionInFlatTree& passedNewSelection,
|
| TextGranularity granularity,
|
| - EndPointsAdjustmentMode endpointsAdjustmentMode,
|
| - HandleVisibility handleVisibility) {
|
| + EndPointsAdjustmentMode endpointsAdjustmentMode) {
|
| VisibleSelectionInFlatTree newSelection = passedNewSelection;
|
| bool isDirectional =
|
| m_frame->editor().behavior().shouldConsiderSelectionAsDirectional() ||
|
| @@ -671,18 +640,11 @@ void SelectionController::setNonDirectionalSelectionIfNeeded(
|
|
|
| // Adjusting base and extent will make newSelection always directional
|
| newSelection.setIsDirectional(isDirectional);
|
| - const bool isHandleVisible = handleVisibility == HandleVisibility::Visible;
|
| - if (selection().visibleSelection<EditingInFlatTreeStrategy>() ==
|
| - newSelection &&
|
| - selection().isHandleVisible() == isHandleVisible)
|
| + if (selection().visibleSelection<EditingInFlatTreeStrategy>() == newSelection)
|
| return;
|
|
|
| const FrameSelection::SetSelectionOptions options =
|
| - isHandleVisible
|
| - ? FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle |
|
| - FrameSelection::HandleVisible
|
| - : FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle;
|
| -
|
| + FrameSelection::CloseTyping | FrameSelection::ClearTypingStyle;
|
| selection().setSelection(newSelection, options, CursorAlignOnScroll::IfNeeded,
|
| granularity);
|
| }
|
| @@ -705,7 +667,7 @@ void SelectionController::setCaretAtHitTestResult(
|
| SelectionInFlatTree::Builder()
|
| .collapse(visiblePos.toPositionWithAffinity())
|
| .build())),
|
| - CharacterGranularity, HandleVisibility::Visible);
|
| + CharacterGranularity);
|
| }
|
|
|
| bool SelectionController::handleMousePressEventDoubleClick(
|
| @@ -768,13 +730,9 @@ bool SelectionController::handleMousePressEventTripleClick(
|
| .build());
|
| }
|
|
|
| - const bool isHandleVisible =
|
| - event.event().fromTouch() && newSelection.isRange();
|
| -
|
| return updateSelectionForMouseDownDispatchingSelectStart(
|
| innerNode, expandSelectionToRespectUserSelectAll(innerNode, newSelection),
|
| - ParagraphGranularity, isHandleVisible ? HandleVisibility::Visible
|
| - : HandleVisibility::NotVisible);
|
| + ParagraphGranularity);
|
| }
|
|
|
| void SelectionController::handleMousePressEvent(
|
|
|