| 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 96429b4038d30623d4e1f5d33974ab77feb5d794..9c576c97d1b5ce9e959655d2734156df1ff5c166 100644
|
| --- a/third_party/WebKit/Source/core/editing/SelectionController.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/SelectionController.cpp
|
| @@ -140,16 +140,6 @@ 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;
|
| - }
|
| - }
|
| -
|
| VisiblePositionInFlatTree visiblePos =
|
| visiblePositionOfHitTestResult(event.hitTestResult());
|
| if (visiblePos.isNull())
|
| @@ -161,9 +151,21 @@ bool SelectionController::handleMousePressEventSingleClick(
|
| selection().visibleSelection<EditingInFlatTreeStrategy>();
|
| TextGranularity granularity = CharacterGranularity;
|
|
|
| + // Don't restart the selection when the mouse is pressed on an
|
| + // existing selection so we can allow for text dragging.
|
| + if (!extendSelection && selection().contains(event.hitTestResult())) {
|
| + m_mouseDownWasSingleClickInSelection = true;
|
| + if (!event.event().fromTouch())
|
| + return false;
|
| +
|
| + if (!selection().isHandleVisible()) {
|
| + updateSelectionForMouseDownDispatchingSelectStart(
|
| + innerNode, newSelection, granularity, HandleVisibility::Visible);
|
| + return false;
|
| + }
|
| + }
|
| +
|
| if (extendSelection && !newSelection.isNone()) {
|
| - // Note: "fast/events/shift-click-user-select-none.html" makes
|
| - // |pos.isNull()| true.
|
| SelectionInFlatTree::Builder builder;
|
| if (pos.isNotNull())
|
| builder.collapse(pos);
|
| @@ -210,10 +212,25 @@ bool SelectionController::handleMousePressEventSingleClick(
|
| }
|
| }
|
|
|
| + bool isHandleVisible = false;
|
| + if (newSelection.isContentEditable()) {
|
| + 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();
|
| + }
|
| +
|
| // Updating the selection is considered side-effect of the event and so it
|
| // doesn't impact the handled state.
|
| - updateSelectionForMouseDownDispatchingSelectStart(innerNode, newSelection,
|
| - granularity);
|
| + updateSelectionForMouseDownDispatchingSelectStart(
|
| + innerNode, newSelection, granularity, isHandleVisible
|
| + ? HandleVisibility::Visible
|
| + : HandleVisibility::NotVisible);
|
| return false;
|
| }
|
|
|
| @@ -336,13 +353,15 @@ void SelectionController::updateSelectionForMouseDrag(
|
| newSelection.expandUsingGranularity(selection().granularity());
|
|
|
| setNonDirectionalSelectionIfNeeded(newSelection, selection().granularity(),
|
| - AdjustEndpointsAtBidiBoundary);
|
| + AdjustEndpointsAtBidiBoundary,
|
| + HandleVisibility::NotVisible);
|
| }
|
|
|
| bool SelectionController::updateSelectionForMouseDownDispatchingSelectStart(
|
| Node* targetNode,
|
| const VisibleSelectionInFlatTree& selection,
|
| - TextGranularity granularity) {
|
| + TextGranularity granularity,
|
| + HandleVisibility handleVisibility) {
|
| if (targetNode && targetNode->layoutObject() &&
|
| !targetNode->layoutObject()->isSelectable())
|
| return false;
|
| @@ -365,7 +384,7 @@ bool SelectionController::updateSelectionForMouseDownDispatchingSelectStart(
|
| }
|
|
|
| setNonDirectionalSelectionIfNeeded(selection, granularity,
|
| - DoNotAdjustEndpoints);
|
| + DoNotAdjustEndpoints, handleVisibility);
|
|
|
| return true;
|
| }
|
| @@ -398,6 +417,7 @@ void SelectionController::selectClosestWordFromHitTestResult(
|
| newSelection.expandUsingGranularity(WordGranularity);
|
| }
|
|
|
| + 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.
|
| @@ -415,6 +435,7 @@ void SelectionController::selectClosestWordFromHitTestResult(
|
| newSelection.rootEditableElement())
|
| .deepEquivalent())
|
| return;
|
| + visibility = HandleVisibility::Visible;
|
| }
|
|
|
| if (appendTrailingWhitespace == AppendTrailingWhitespace::ShouldAppend &&
|
| @@ -423,7 +444,7 @@ void SelectionController::selectClosestWordFromHitTestResult(
|
|
|
| updateSelectionForMouseDownDispatchingSelectStart(
|
| innerNode, expandSelectionToRespectUserSelectAll(innerNode, newSelection),
|
| - WordGranularity);
|
| + WordGranularity, visibility);
|
| }
|
|
|
| void SelectionController::selectClosestMisspellingFromHitTestResult(
|
| @@ -458,7 +479,7 @@ void SelectionController::selectClosestMisspellingFromHitTestResult(
|
|
|
| updateSelectionForMouseDownDispatchingSelectStart(
|
| innerNode, expandSelectionToRespectUserSelectAll(innerNode, newSelection),
|
| - WordGranularity);
|
| + WordGranularity, HandleVisibility::NotVisible);
|
| }
|
|
|
| void SelectionController::selectClosestWordFromMouseEvent(
|
| @@ -515,7 +536,7 @@ void SelectionController::selectClosestWordOrLinkFromMouseEvent(
|
|
|
| updateSelectionForMouseDownDispatchingSelectStart(
|
| innerNode, expandSelectionToRespectUserSelectAll(innerNode, newSelection),
|
| - WordGranularity);
|
| + WordGranularity, HandleVisibility::NotVisible);
|
| }
|
|
|
| bool SelectionController::handleMousePressEventDoubleClick(
|
| @@ -577,9 +598,12 @@ bool SelectionController::handleMousePressEventTripleClick(
|
| newSelection.expandUsingGranularity(ParagraphGranularity);
|
| }
|
|
|
| + bool isHandleVisible = event.event().fromTouch() && newSelection.isRange();
|
| +
|
| return updateSelectionForMouseDownDispatchingSelectStart(
|
| innerNode, expandSelectionToRespectUserSelectAll(innerNode, newSelection),
|
| - ParagraphGranularity);
|
| + ParagraphGranularity, isHandleVisible ? HandleVisibility::Visible
|
| + : HandleVisibility::NotVisible);
|
| }
|
|
|
| void SelectionController::handleMousePressEvent(
|
| @@ -780,7 +804,7 @@ void SelectionController::sendContextMenuEvent(
|
| const LayoutPoint& position) {
|
| if (!selection().isAvailable())
|
| return;
|
| - if (selection().contains(position) || mev.scrollbar() ||
|
| + if (selection().contains(mev.hitTestResult()) || mev.scrollbar() ||
|
| // FIXME: In the editable case, word selection sometimes selects content
|
| // that isn't underneath the mouse.
|
| // If the selection is non-editable, we do word selection to make it
|
| @@ -809,8 +833,7 @@ void SelectionController::passMousePressEventToSubframe(
|
| // greyed out even though we're clicking on the selection. This looks
|
| // really strange (having the whole frame be greyed out), so we deselect the
|
| // selection.
|
| - IntPoint p = m_frame->view()->rootFrameToContents(mev.event().position());
|
| - if (!selection().contains(p))
|
| + if (!selection().contains(mev.hitTestResult()))
|
| return;
|
|
|
| // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
|
|
|