OLD | NEW |
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_pinch_gesture.h" | 5 #include "content/browser/renderer_host/input/synthetic_pinch_gesture.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "content/common/input/input_event.h" | |
11 #include "ui/events/latency_info.h" | 10 #include "ui/events/latency_info.h" |
12 | 11 |
13 namespace content { | 12 namespace content { |
14 | 13 |
15 SyntheticPinchGesture::SyntheticPinchGesture( | 14 SyntheticPinchGesture::SyntheticPinchGesture( |
16 const SyntheticPinchGestureParams& params) | 15 const SyntheticPinchGestureParams& params) |
17 : params_(params), | 16 : params_(params), |
18 start_y_0_(0.0f), | 17 start_y_0_(0.0f), |
19 start_y_1_(0.0f), | 18 start_y_1_(0.0f), |
20 gesture_source_type_(SyntheticGestureParams::DEFAULT_INPUT), | 19 gesture_source_type_(SyntheticGestureParams::DEFAULT_INPUT), |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 void SyntheticPinchGesture::ReleaseTouchPoints( | 103 void SyntheticPinchGesture::ReleaseTouchPoints( |
105 SyntheticGestureTarget* target, const base::TimeTicks& timestamp) { | 104 SyntheticGestureTarget* target, const base::TimeTicks& timestamp) { |
106 touch_event_.ReleasePoint(0); | 105 touch_event_.ReleasePoint(0); |
107 touch_event_.ReleasePoint(1); | 106 touch_event_.ReleasePoint(1); |
108 ForwardTouchEvent(target, timestamp); | 107 ForwardTouchEvent(target, timestamp); |
109 } | 108 } |
110 | 109 |
111 void SyntheticPinchGesture::ForwardTouchEvent( | 110 void SyntheticPinchGesture::ForwardTouchEvent( |
112 SyntheticGestureTarget* target, const base::TimeTicks& timestamp) { | 111 SyntheticGestureTarget* target, const base::TimeTicks& timestamp) { |
113 touch_event_.timeStampSeconds = ConvertTimestampToSeconds(timestamp); | 112 touch_event_.timeStampSeconds = ConvertTimestampToSeconds(timestamp); |
114 target->DispatchInputEventToPlatform( | 113 target->DispatchInputEventToPlatform(touch_event_); |
115 InputEvent(touch_event_, ui::LatencyInfo(), false)); | |
116 } | 114 } |
117 | 115 |
118 void SyntheticPinchGesture::SetupCoordinatesAndStopTime( | 116 void SyntheticPinchGesture::SetupCoordinatesAndStopTime( |
119 SyntheticGestureTarget* target) { | 117 SyntheticGestureTarget* target) { |
120 const int kTouchSlopInDips = target->GetTouchSlopInDips(); | 118 const int kTouchSlopInDips = target->GetTouchSlopInDips(); |
121 params_.total_num_pixels_covered += 2 * kTouchSlopInDips; | 119 params_.total_num_pixels_covered += 2 * kTouchSlopInDips; |
122 float inner_distance_to_anchor = 2 * kTouchSlopInDips; | 120 float inner_distance_to_anchor = 2 * kTouchSlopInDips; |
123 float outer_distance_to_anchor = | 121 float outer_distance_to_anchor = |
124 inner_distance_to_anchor + params_.total_num_pixels_covered / 2.0f; | 122 inner_distance_to_anchor + params_.total_num_pixels_covered / 2.0f; |
125 | 123 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 const base::TimeTicks& timestamp) const { | 159 const base::TimeTicks& timestamp) const { |
162 return std::min(timestamp, stop_time_); | 160 return std::min(timestamp, stop_time_); |
163 } | 161 } |
164 | 162 |
165 bool SyntheticPinchGesture::HasReachedTarget(const base::TimeTicks& timestamp) | 163 bool SyntheticPinchGesture::HasReachedTarget(const base::TimeTicks& timestamp) |
166 const { | 164 const { |
167 return timestamp >= stop_time_; | 165 return timestamp >= stop_time_; |
168 } | 166 } |
169 | 167 |
170 } // namespace content | 168 } // namespace content |
OLD | NEW |