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

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

Issue 2074093003: Fix more corner cases for empty touch selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove std::string in test Created 4 years, 6 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 240120e08bb49f1d0e51d4ba0d6278f4c93f4a6c..d5cfe61d4806e0235279054e62df41781e04ab39 100644
--- a/third_party/WebKit/Source/core/editing/SelectionController.cpp
+++ b/third_party/WebKit/Source/core/editing/SelectionController.cpp
@@ -303,9 +303,9 @@ void SelectionController::selectClosestWordFromHitTestResult(const HitTestResult
// Special-case image local offset to always be zero, to avoid triggering
// LayoutReplaced::positionFromPoint's advancement of the position at the
// mid-point of the the image (which was intended for mouse-drag selection
- // and isn't desirable for long-press).
+ // and isn't desirable for touch).
HitTestResult adjustedHitTestResult = result;
- if (selectInputEventType == SelectInputEventType::GestureLongPress && result.image())
+ if (selectInputEventType == SelectInputEventType::Touch && result.image())
adjustedHitTestResult.setNodeAndPosition(result.innerNode(), LayoutPoint(0, 0));
const VisiblePositionInFlatTree& pos = visiblePositionOfHitTestResult(adjustedHitTestResult);
@@ -314,13 +314,16 @@ void SelectionController::selectClosestWordFromHitTestResult(const HitTestResult
newSelection.expandUsingGranularity(WordGranularity);
}
- if (selectInputEventType == SelectInputEventType::GestureLongPress) {
+ if (selectInputEventType == SelectInputEventType::Touch) {
// If node doesn't have text except space, tab or line break, do not
// select that 'empty' area.
EphemeralRangeInFlatTree range(newSelection.start(), newSelection.end());
const String& str = plainText(range, TextIteratorEmitsObjectReplacementCharacter);
if (str.isEmpty() || str.simplifyWhiteSpace().containsOnlyWhitespace())
return;
+
+ if (newSelection.rootEditableElement() && pos.deepEquivalent() == VisiblePositionInFlatTree::lastPositionInNode(newSelection.rootEditableElement()).deepEquivalent())
+ return;
}
if (appendTrailingWhitespace == AppendTrailingWhitespace::ShouldAppend && newSelection.isRange())
@@ -362,7 +365,7 @@ void SelectionController::selectClosestWordFromMouseEvent(const MouseEventWithHi
AppendTrailingWhitespace appendTrailingWhitespace = (result.event().clickCount() == 2 && m_frame->editor().isSelectTrailingWhitespaceEnabled()) ? AppendTrailingWhitespace::ShouldAppend : AppendTrailingWhitespace::DontAppend;
- return selectClosestWordFromHitTestResult(result.hitTestResult(), appendTrailingWhitespace, SelectInputEventType::Mouse);
+ return selectClosestWordFromHitTestResult(result.hitTestResult(), appendTrailingWhitespace, result.event().fromTouch() ? SelectInputEventType::Touch : SelectInputEventType::Mouse);
}
void SelectionController::selectClosestMisspellingFromMouseEvent(const MouseEventWithHitTestResults& result)
@@ -579,7 +582,7 @@ bool SelectionController::handleGestureLongPress(const PlatformGestureEvent& ges
if (!innerNodeIsSelectable)
return false;
- selectClosestWordFromHitTestResult(hitTestResult, AppendTrailingWhitespace::DontAppend, SelectInputEventType::GestureLongPress);
+ selectClosestWordFromHitTestResult(hitTestResult, AppendTrailingWhitespace::DontAppend, SelectInputEventType::Touch);
if (!selection().isAvailable()) {
// "editing/selection/longpress-selection-in-iframe-removed-crash.html"
// reach here.
« no previous file with comments | « third_party/WebKit/Source/core/editing/SelectionController.h ('k') | third_party/WebKit/Source/web/tests/WebViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698