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

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

Issue 2912923002: Make SelectionController to call TextDistance() with proper range (Closed)
Patch Set: 2017-05-30T18:30:35 Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ec1a74b99081c0097b403bbd31034d84da345feb..5c0399a18c0e52f2789c6235cd3dbe11c0c762f7 100644
--- a/third_party/WebKit/Source/core/editing/SelectionController.cpp
+++ b/third_party/WebKit/Source/core/editing/SelectionController.cpp
@@ -215,10 +215,18 @@ bool SelectionController::HandleSingleClick(
// Shift+Click deselects when selection was created right-to-left
const PositionInFlatTree& start = selection.Start();
const PositionInFlatTree& end = selection.end();
- const int distance_to_start = TextDistance(start, pos);
- const int distance_to_end = TextDistance(pos, end);
- builder.SetBaseAndExtent(
- distance_to_start <= distance_to_end ? end : start, pos);
+ if (pos < start) {
+ // |distance_to_start < distance_to_end|.
+ builder.SetBaseAndExtent(end, pos);
+ } else if (end < pos) {
+ // |distance_to_start > distance_to_end|.
+ builder.SetBaseAndExtent(start, pos);
+ } else {
+ const int distance_to_start = TextDistance(start, pos);
+ const int distance_to_end = TextDistance(pos, end);
+ builder.SetBaseAndExtent(
+ distance_to_start <= distance_to_end ? end : start, pos);
+ }
}
UpdateSelectionForMouseDownDispatchingSelectStart(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698