Index: content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.cc |
diff --git a/content/browser/renderer_host/input/synthetic_pinch_gesture.cc b/content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.cc |
similarity index 76% |
copy from content/browser/renderer_host/input/synthetic_pinch_gesture.cc |
copy to content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.cc |
index 53e15d78fda2dae78b4a1c223d0cc2a5b9685f9c..b3eb9f061ef10da3510d3e2677f4238063ffe555 100644 |
--- a/content/browser/renderer_host/input/synthetic_pinch_gesture.cc |
+++ b/content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "content/browser/renderer_host/input/synthetic_pinch_gesture.h" |
+#include "content/browser/renderer_host/input/synthetic_touchscreen_pinch_gesture.h" |
#include <cmath> |
@@ -11,7 +11,7 @@ |
namespace content { |
-SyntheticPinchGesture::SyntheticPinchGesture( |
+SyntheticTouchscreenPinchGesture::SyntheticTouchscreenPinchGesture( |
const SyntheticPinchGestureParams& params) |
: params_(params), |
start_y_0_(0.0f), |
@@ -19,13 +19,14 @@ SyntheticPinchGesture::SyntheticPinchGesture( |
max_pointer_delta_0_(0.0f), |
gesture_source_type_(SyntheticGestureParams::DEFAULT_INPUT), |
state_(SETUP) { |
- DCHECK_GT(params_.scale_factor, 0.0f); |
+ DCHECK_GT(params_.scale_factor, 0.0f); |
} |
-SyntheticPinchGesture::~SyntheticPinchGesture() {} |
+SyntheticTouchscreenPinchGesture::~SyntheticTouchscreenPinchGesture() {} |
-SyntheticGesture::Result SyntheticPinchGesture::ForwardInputEvents( |
- const base::TimeTicks& timestamp, SyntheticGestureTarget* target) { |
+SyntheticGesture::Result SyntheticTouchscreenPinchGesture::ForwardInputEvents( |
+ const base::TimeTicks& timestamp, |
+ SyntheticGestureTarget* target) { |
if (state_ == SETUP) { |
gesture_source_type_ = params_.gesture_source_type; |
if (gesture_source_type_ == SyntheticGestureParams::DEFAULT_INPUT) |
@@ -36,17 +37,19 @@ SyntheticGesture::Result SyntheticPinchGesture::ForwardInputEvents( |
} |
DCHECK_NE(gesture_source_type_, SyntheticGestureParams::DEFAULT_INPUT); |
- if (gesture_source_type_ == SyntheticGestureParams::TOUCH_INPUT) |
+ if (gesture_source_type_ == SyntheticGestureParams::TOUCH_INPUT) { |
ForwardTouchInputEvents(timestamp, target); |
- else |
+ } else { |
return SyntheticGesture::GESTURE_SOURCE_TYPE_NOT_IMPLEMENTED; |
+ } |
return (state_ == DONE) ? SyntheticGesture::GESTURE_FINISHED |
: SyntheticGesture::GESTURE_RUNNING; |
} |
-void SyntheticPinchGesture::ForwardTouchInputEvents( |
- const base::TimeTicks& timestamp, SyntheticGestureTarget* target) { |
+void SyntheticTouchscreenPinchGesture::ForwardTouchInputEvents( |
+ const base::TimeTicks& timestamp, |
+ SyntheticGestureTarget* target) { |
switch (state_) { |
case STARTED: |
// Check for an early finish. |
@@ -74,16 +77,18 @@ void SyntheticPinchGesture::ForwardTouchInputEvents( |
} |
} |
-void SyntheticPinchGesture::PressTouchPoints(SyntheticGestureTarget* target, |
- const base::TimeTicks& timestamp) { |
+void SyntheticTouchscreenPinchGesture::PressTouchPoints( |
+ SyntheticGestureTarget* target, |
+ const base::TimeTicks& timestamp) { |
touch_event_.PressPoint(params_.anchor.x(), start_y_0_); |
touch_event_.PressPoint(params_.anchor.x(), start_y_1_); |
ForwardTouchEvent(target, timestamp); |
} |
-void SyntheticPinchGesture::MoveTouchPoints(SyntheticGestureTarget* target, |
- float delta, |
- const base::TimeTicks& timestamp) { |
+void SyntheticTouchscreenPinchGesture::MoveTouchPoints( |
+ SyntheticGestureTarget* target, |
+ float delta, |
+ const base::TimeTicks& timestamp) { |
// The two pointers move in opposite directions. |
float current_y_0 = start_y_0_ + delta; |
float current_y_1 = start_y_1_ - delta; |
@@ -93,20 +98,22 @@ void SyntheticPinchGesture::MoveTouchPoints(SyntheticGestureTarget* target, |
ForwardTouchEvent(target, timestamp); |
} |
-void SyntheticPinchGesture::ReleaseTouchPoints( |
- SyntheticGestureTarget* target, const base::TimeTicks& timestamp) { |
+void SyntheticTouchscreenPinchGesture::ReleaseTouchPoints( |
+ SyntheticGestureTarget* target, |
+ const base::TimeTicks& timestamp) { |
touch_event_.ReleasePoint(0); |
touch_event_.ReleasePoint(1); |
ForwardTouchEvent(target, timestamp); |
} |
-void SyntheticPinchGesture::ForwardTouchEvent( |
- SyntheticGestureTarget* target, const base::TimeTicks& timestamp) { |
+void SyntheticTouchscreenPinchGesture::ForwardTouchEvent( |
+ SyntheticGestureTarget* target, |
+ const base::TimeTicks& timestamp) { |
touch_event_.timeStampSeconds = ConvertTimestampToSeconds(timestamp); |
target->DispatchInputEventToPlatform(touch_event_); |
} |
-void SyntheticPinchGesture::SetupCoordinatesAndStopTime( |
+void SyntheticTouchscreenPinchGesture::SetupCoordinatesAndStopTime( |
SyntheticGestureTarget* target) { |
// To achieve the specified scaling factor, the ratio of the final to the |
// initial span (distance between the pointers) has to be equal to the scaling |
@@ -118,7 +125,7 @@ void SyntheticPinchGesture::SetupCoordinatesAndStopTime( |
final_distance_to_anchor = |
(initial_distance_to_anchor + target->GetTouchSlopInDips()) * |
params_.scale_factor; |
- } else { // zooming out |
+ } else { // zooming out |
final_distance_to_anchor = target->GetMinScalingSpanInDips() / 2.0f; |
initial_distance_to_anchor = |
(final_distance_to_anchor / params_.scale_factor) + |
@@ -138,7 +145,7 @@ void SyntheticPinchGesture::SetupCoordinatesAndStopTime( |
start_time_ + base::TimeDelta::FromMicroseconds(total_duration_in_us); |
} |
-float SyntheticPinchGesture::GetDeltaForPointer0AtTime( |
+float SyntheticTouchscreenPinchGesture::GetDeltaForPointer0AtTime( |
const base::TimeTicks& timestamp) const { |
// Make sure the final delta is correct. Using the computation below can lead |
// to issues with floating point precision. |
@@ -152,13 +159,13 @@ float SyntheticPinchGesture::GetDeltaForPointer0AtTime( |
: abs_delta_pointer_0; |
} |
-base::TimeTicks SyntheticPinchGesture::ClampTimestamp( |
+base::TimeTicks SyntheticTouchscreenPinchGesture::ClampTimestamp( |
const base::TimeTicks& timestamp) const { |
return std::min(timestamp, stop_time_); |
} |
-bool SyntheticPinchGesture::HasReachedTarget(const base::TimeTicks& timestamp) |
- const { |
+bool SyntheticTouchscreenPinchGesture::HasReachedTarget( |
+ const base::TimeTicks& timestamp) const { |
return timestamp >= stop_time_; |
} |