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 273f30bd96ac0dd2820734fadfc0b647076ed76b..b4f743dbe1fc6e440bb4d1041470dc2015cdcd24 100644 |
--- a/views/touchui/touch_selection_controller_impl.cc |
+++ b/views/touchui/touch_selection_controller_impl.cc |
@@ -161,18 +161,10 @@ void TouchSelectionControllerImpl::SelectionChanged(const gfx::Point& p1, |
if (dragging_handle_) { |
// We need to reposition only the selection handle that is being dragged. |
- // The other handle stays the same. |
- SelectionHandleView* fixed_handle = selection_handle_1_.get(); |
- if (fixed_handle == dragging_handle_) |
- fixed_handle = selection_handle_2_.get(); |
- |
- gfx::Point fixed_handle_pos = fixed_handle->GetScreenPosition(); |
- fixed_handle_pos.Offset(kSelectionHandleRadius, 0); |
- |
- if (fixed_handle_pos == screen_pos_1) |
- dragging_handle_->SetScreenPosition(screen_pos_2); |
- else |
- dragging_handle_->SetScreenPosition(screen_pos_1); |
+ // The other handle stays the same. Also, the selection handle being dragged |
+ // will always be at the end of selection, while the other handle will be at |
+ // the start. |
+ dragging_handle_->SetScreenPosition(screen_pos_2); |
} else { |
// Check if there is any selection at all. |
if (screen_pos_1 == screen_pos_2) { |
@@ -181,14 +173,14 @@ void TouchSelectionControllerImpl::SelectionChanged(const gfx::Point& p1, |
return; |
} |
- if (client_view_->bounds().Contains(p1)) { |
+ if (isPointInClientView(p1)) { |
selection_handle_1_->SetScreenPosition(screen_pos_1); |
selection_handle_1_->SetVisible(true); |
} else { |
selection_handle_1_->SetVisible(false); |
} |
- if (client_view_->bounds().Contains(p2)) { |
+ if (isPointInClientView(p2)) { |
selection_handle_2_->SetScreenPosition(screen_pos_2); |
selection_handle_2_->SetVisible(true); |
} else { |
@@ -233,6 +225,12 @@ void TouchSelectionControllerImpl::ConvertPointToClientView( |
View::ConvertPointFromWidget(client_view_, point); |
} |
+bool TouchSelectionControllerImpl::isPointInClientView(const gfx::Point& p) { |
sky
2011/08/22 14:21:37
is -> Is
varunjain
2011/08/22 16:58:50
Done.
|
+ gfx::Rect r = client_view_->bounds(); |
+ return p.x() >= r.x() && p.x() <= r.x() + r.width() && |
sky
2011/08/22 14:21:37
return r.Contains(p)
varunjain
2011/08/22 16:58:50
Rect::Contains checks for strict inclusion and ret
|
+ p.y() >= r.y() && p.y() <= r.y() + r.height(); |
+} |
+ |
gfx::Point TouchSelectionControllerImpl::GetSelectionHandle1Position() { |
return selection_handle_1_->GetScreenPosition(); |
} |