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

Side by Side Diff: content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.cc

Issue 95153002: Make touch-based synthetic gesture take touch slop into account. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unused variable. Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h" 5 #include "content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "content/common/input/input_event.h" 9 #include "content/common/input/input_event.h"
10 #include "ui/events/latency_info.h" 10 #include "ui/events/latency_info.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 return (state_ == DONE) ? SyntheticGesture::GESTURE_FINISHED 44 return (state_ == DONE) ? SyntheticGesture::GESTURE_FINISHED
45 : SyntheticGesture::GESTURE_RUNNING; 45 : SyntheticGesture::GESTURE_RUNNING;
46 } 46 }
47 47
48 void SyntheticSmoothScrollGesture::ForwardTouchInputEvents( 48 void SyntheticSmoothScrollGesture::ForwardTouchInputEvents(
49 const base::TimeDelta& interval, SyntheticGestureTarget* target) { 49 const base::TimeDelta& interval, SyntheticGestureTarget* target) {
50 switch (state_) { 50 switch (state_) {
51 case STARTED: 51 case STARTED:
52 // Check for an early finish. 52 // Check for an early finish.
53 if (HasScrolledEntireDistance()) { 53 if (params_.distance == 0) {
54 state_ = DONE; 54 state_ = DONE;
55 break; 55 break;
56 } 56 }
57 if (params_.distance > 0)
58 params_.distance += target->GetTouchSlopInDips();
59 else
60 params_.distance -= target->GetTouchSlopInDips();
57 touch_event_.PressPoint(params_.anchor.x(), current_y_); 61 touch_event_.PressPoint(params_.anchor.x(), current_y_);
58 ForwardTouchEvent(target); 62 ForwardTouchEvent(target);
59 state_ = MOVING; 63 state_ = MOVING;
60 break; 64 break;
61 case MOVING: 65 case MOVING:
62 current_y_ += GetPositionDelta(interval); 66 current_y_ += GetPositionDelta(interval);
63 touch_event_.MovePoint(0, params_.anchor.x(), current_y_); 67 touch_event_.MovePoint(0, params_.anchor.x(), current_y_);
64 ForwardTouchEvent(target); 68 ForwardTouchEvent(target);
65 69
66 if (HasScrolledEntireDistance()) 70 if (HasScrolledEntireDistance())
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 params_.distance > 0 ? remaining_distance : -remaining_distance; 160 params_.distance > 0 ? remaining_distance : -remaining_distance;
157 DCHECK_GE(abs_remaining_distance, 0); 161 DCHECK_GE(abs_remaining_distance, 0);
158 return abs_remaining_distance; 162 return abs_remaining_distance;
159 } 163 }
160 164
161 bool SyntheticSmoothScrollGesture::HasScrolledEntireDistance() const { 165 bool SyntheticSmoothScrollGesture::HasScrolledEntireDistance() const {
162 return ComputeAbsoluteRemainingDistance() == 0; 166 return ComputeAbsoluteRemainingDistance() == 0;
163 } 167 }
164 168
165 } // namespace content 169 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/synthetic_smooth_scroll_gesture.h ('k') | content/common/android/view_configuration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698