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

Unified Diff: ui/touch_selection/touch_handle.cc

Issue 1087893003: Support longpress drag selection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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 | « ui/touch_selection/touch_handle.h ('k') | ui/touch_selection/touch_handle_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/touch_selection/touch_handle.cc
diff --git a/ui/touch_selection/touch_handle.cc b/ui/touch_selection/touch_handle.cc
index cea93885f51582696204a4f49a0071f65fbe4bdb..e2faff1f382cf4b85ea2892dbb1f4e7965ed03ad 100644
--- a/ui/touch_selection/touch_handle.cc
+++ b/ui/touch_selection/touch_handle.cc
@@ -167,24 +167,19 @@ bool TouchHandle::WillHandleTouchEvent(const MotionEvent& event) {
return false;
}
touch_down_position_ = touch_point;
- touch_to_focus_offset_ = position_ - touch_down_position_;
+ touch_drag_offset_ = position_ - touch_down_position_;
touch_down_time_ = event.GetEventTime();
BeginDrag();
} break;
case MotionEvent::ACTION_MOVE: {
gfx::PointF touch_move_position(event.GetX(), event.GetY());
- if (is_drag_within_tap_region_) {
- const float tap_slop = client_->GetTapSlop();
- is_drag_within_tap_region_ =
- (touch_move_position - touch_down_position_).LengthSquared() <
- tap_slop * tap_slop;
- }
+ is_drag_within_tap_region_ &=
+ client_->IsWithinTapSlop(touch_down_position_ - touch_move_position);
// Note that we signal drag update even if we're inside the tap region,
// as there are cases where characters are narrower than the slop length.
- client_->OnHandleDragUpdate(*this,
- touch_move_position + touch_to_focus_offset_);
+ client_->OnDragUpdate(*this, touch_move_position + touch_drag_offset_);
} break;
case MotionEvent::ACTION_UP: {
@@ -207,6 +202,10 @@ bool TouchHandle::WillHandleTouchEvent(const MotionEvent& event) {
return true;
}
+bool TouchHandle::IsActive() const {
+ return is_dragging_;
+}
+
bool TouchHandle::Animate(base::TimeTicks frame_time) {
if (fade_end_time_ == base::TimeTicks())
return false;
@@ -242,7 +241,7 @@ void TouchHandle::BeginDrag() {
EndFade();
is_dragging_ = true;
is_drag_within_tap_region_ = true;
- client_->OnHandleDragBegin(*this);
+ client_->OnDragBegin(*this, position());
}
void TouchHandle::EndDrag() {
@@ -252,7 +251,7 @@ void TouchHandle::EndDrag() {
is_dragging_ = false;
is_drag_within_tap_region_ = false;
- client_->OnHandleDragEnd(*this);
+ client_->OnDragEnd(*this);
if (deferred_orientation_ != TouchHandleOrientation::UNDEFINED) {
TouchHandleOrientation deferred_orientation = deferred_orientation_;
« no previous file with comments | « ui/touch_selection/touch_handle.h ('k') | ui/touch_selection/touch_handle_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698