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

Unified Diff: content/browser/renderer_host/input/synthetic_pinch_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: undo pinch refactoring; get device scale factor from gfx::Screen 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/synthetic_pinch_gesture.cc
diff --git a/content/browser/renderer_host/input/synthetic_pinch_gesture.cc b/content/browser/renderer_host/input/synthetic_pinch_gesture.cc
index 7700b6d59a587cac17af2b3b6800647be9c979f9..159927fe776bcb4c4a6ebf37c63981e78589c2b4 100644
--- a/content/browser/renderer_host/input/synthetic_pinch_gesture.cc
+++ b/content/browser/renderer_host/input/synthetic_pinch_gesture.cc
@@ -19,26 +19,13 @@ const float kMinPointerDistance = 40.0f;
SyntheticPinchGesture::SyntheticPinchGesture(
const SyntheticPinchGestureParams& params)
- : params_(params), started_(false) {
+ : params_(params),
+ current_y_0_(0),
+ current_y_1_(0),
+ target_y_0_(0),
+ target_y_1_(0),
+ started_(false) {
DCHECK_GE(params_.total_num_pixels_covered, 0);
-
- float inner_distance_to_anchor = kMinPointerDistance / 2.0f;
- float outer_distance_to_anchor =
- inner_distance_to_anchor + params_.total_num_pixels_covered / 2.0f;
-
- // Move pointers away from each other to zoom in
- // or towards each other to zoom out.
- if (params_.zoom_in) {
- current_y_0_ = params_.anchor.y() - inner_distance_to_anchor;
- current_y_1_ = params_.anchor.y() + inner_distance_to_anchor;
- target_y_0_ = params_.anchor.y() - outer_distance_to_anchor;
- target_y_1_ = params_.anchor.y() + outer_distance_to_anchor;
- } else {
- current_y_0_ = params_.anchor.y() - outer_distance_to_anchor;
- current_y_1_ = params_.anchor.y() + outer_distance_to_anchor;
- target_y_0_ = params_.anchor.y() - inner_distance_to_anchor;
- target_y_1_ = params_.anchor.y() + inner_distance_to_anchor;
- }
}
SyntheticPinchGesture::~SyntheticPinchGesture() {}
@@ -62,10 +49,12 @@ SyntheticGesture::Result SyntheticPinchGesture::ForwardInputEvents(
SyntheticGesture::Result SyntheticPinchGesture::ForwardTouchInputEvents(
const base::TimeDelta& interval, SyntheticGestureTarget* target) {
- if (HasFinished())
- return SyntheticGesture::GESTURE_FINISHED;
-
if (!started_) {
+ SetupCoordinates(target);
+
+ if (HasFinished())
+ return SyntheticGesture::GESTURE_FINISHED;
+
touch_event_.PressPoint(params_.anchor.x(), current_y_0_);
touch_event_.PressPoint(params_.anchor.x(), current_y_1_);
ForwardTouchEvent(target);
@@ -96,6 +85,27 @@ SyntheticGesture::Result SyntheticPinchGesture::ForwardTouchInputEvents(
return SyntheticGesture::GESTURE_RUNNING;
}
+void SyntheticPinchGesture::SetupCoordinates(SyntheticGestureTarget* target) {
jdduke (slow) 2013/12/02 16:29:43 Nit: Move this below |ForwardTouchEvent()| for con
Dominik Grewe 2013/12/02 16:42:26 Done.
+ float inner_distance_to_anchor = 2 * target->GetTouchSlopInDips();
+ float outer_distance_to_anchor = inner_distance_to_anchor +
+ params_.total_num_pixels_covered / 2.0f +
+ target->GetTouchSlopInDips();
+
+ // Move pointers away from each other to zoom in
+ // or towards each other to zoom out.
+ if (params_.zoom_in) {
+ current_y_0_ = params_.anchor.y() - inner_distance_to_anchor;
+ current_y_1_ = params_.anchor.y() + inner_distance_to_anchor;
+ target_y_0_ = params_.anchor.y() - outer_distance_to_anchor;
+ target_y_1_ = params_.anchor.y() + outer_distance_to_anchor;
+ } else {
+ current_y_0_ = params_.anchor.y() - outer_distance_to_anchor;
+ current_y_1_ = params_.anchor.y() + outer_distance_to_anchor;
+ target_y_0_ = params_.anchor.y() - inner_distance_to_anchor;
+ target_y_1_ = params_.anchor.y() + inner_distance_to_anchor;
+ }
+}
+
void SyntheticPinchGesture::ForwardTouchEvent(SyntheticGestureTarget* target) {
target->DispatchInputEventToPlatform(
InputEvent(touch_event_, ui::LatencyInfo(), false));

Powered by Google App Engine
This is Rietveld 408576698