Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Unified Diff: third_party/WebKit/Source/core/editing/SelectionController.cpp

Issue 2201853002: Blink handle selection handle visibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing aura problems Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..cf02d5a75252ad3ec8e4d7ab566171b325b8f6f2 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())
+ 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(true);
+ }
}
// 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())
@@ -584,6 +595,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()) {
+ 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"

Powered by Google App Engine
This is Rietveld 408576698