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 eff3be63e195a3631f866e9a43184484bd63dfad..56608f846a9005b1e95ad91956fab97352354fed 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. |
@@ -277,8 +280,13 @@ void TouchSelectionControllerImpl::SelectionChanged(const gfx::Point& p1, |
} else { |
UpdateContextMenu(p1, p2); |
sky
2011/09/06 17:43:27
Should this be moved to 194ish and around line 290
sadrul
2011/09/06 20:23:31
I do not think I understand: do you mean do the sa
sky
2011/09/06 20:33:36
I'm suggesting:
if (dragging_handle_) {
...
} e
sadrul
2011/09/06 20:36:51
Ah, I see. It looks like UpdateContextMenu already
|
- // 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; |