Index: views/touchui/touch_selection_controller_impl.cc |
diff --git a/views/touchui/touch_selection_controller_impl.cc b/views/touchui/touch_selection_controller_impl.cc |
index 0de16ce8dec7d1187b42f116d9791469943a63dc..87cee31bf95c0fe1f344b49e75526bbc047010da 100644 |
--- a/views/touchui/touch_selection_controller_impl.cc |
+++ b/views/touchui/touch_selection_controller_impl.cc |
@@ -31,6 +31,9 @@ const int kSelectionHandleAlpha = 0x7F; |
const SkColor kSelectionHandleColor = |
SkColorSetA(SK_ColorBLUE, kSelectionHandleAlpha); |
+// The minimum selection size to trigger selection controller. |
+const int kMinSelectionSize = 4; |
+ |
const int kContextMenuCommands[] = {IDS_APP_CUT, |
IDS_APP_COPY, |
// TODO(varunjain): PASTE is acting funny due to some gtk clipboard issue. |
@@ -279,8 +282,13 @@ void TouchSelectionControllerImpl::SelectionChanged(const gfx::Point& p1, |
} else { |
UpdateContextMenu(p1, p2); |
- // Check if there is any selection at all. |
- if (screen_pos_1 == screen_pos_2) { |
+ // Check if there is any selection at all. The points may not match exactly, |
+ // since the selection range computation may introduce some floating point |
+ // errors. So check for a minimum size to decide whether or not there is any |
+ // selection. |
+ int delta_x = screen_pos_2.x() - screen_pos_1.x(); |
+ int delta_y = screen_pos_2.y() - screen_pos_1.y(); |
+ if (abs(delta_x) < kMinSelectionSize && abs(delta_y) < kMinSelectionSize) { |
selection_handle_1_->SetVisible(false); |
selection_handle_2_->SetVisible(false); |
return; |