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..7123894df99cdce42fcb9763ce1488062a57ba98 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), |
bulach
2013/12/02 18:24:51
nit: wouldn't make any difference, but 0.0f would
Dominik Grewe
2013/12/02 18:50:04
Done.
|
+ 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_) { |
+ if (params_.total_num_pixels_covered == 0) |
+ return SyntheticGesture::GESTURE_FINISHED; |
+ |
+ SetupCoordinates(target); |
+ |
touch_event_.PressPoint(params_.anchor.x(), current_y_0_); |
touch_event_.PressPoint(params_.anchor.x(), current_y_1_); |
ForwardTouchEvent(target); |
@@ -101,6 +90,27 @@ void SyntheticPinchGesture::ForwardTouchEvent(SyntheticGestureTarget* target) { |
InputEvent(touch_event_, ui::LatencyInfo(), false)); |
} |
+void SyntheticPinchGesture::SetupCoordinates(SyntheticGestureTarget* target) { |
+ 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(); |
bulach
2013/12/02 18:24:51
nit: "target->GetTouchSlopInDips()" is going to ja
Dominik Grewe
2013/12/02 18:50:04
Done.
|
+ |
+ // 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; |
+ } |
+} |
+ |
float SyntheticPinchGesture::GetDeltaForPointer0( |
const base::TimeDelta& interval) const { |
float total_abs_delta = |