OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/events/gesture_detection/gesture_provider.h" | 5 #include "ui/events/gesture_detection/gesture_provider.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 tap_details.set_bounding_box( | 73 tap_details.set_bounding_box( |
74 gfx::RectF(event.GetTouchMajor(), event.GetTouchMajor())); | 74 gfx::RectF(event.GetTouchMajor(), event.GetTouchMajor())); |
75 return tap_details; | 75 return tap_details; |
76 } | 76 } |
77 | 77 |
78 } // namespace | 78 } // namespace |
79 | 79 |
80 // GestureProvider:::Config | 80 // GestureProvider:::Config |
81 | 81 |
82 GestureProvider::Config::Config() | 82 GestureProvider::Config::Config() |
83 : disable_click_delay(false), gesture_begin_end_types_enabled(false) {} | 83 : display(gfx::Display::kInvalidDisplayID, gfx::Rect(1, 1)), |
| 84 disable_click_delay(false), |
| 85 gesture_begin_end_types_enabled(false) {} |
84 | 86 |
85 GestureProvider::Config::~Config() {} | 87 GestureProvider::Config::~Config() {} |
86 | 88 |
87 // GestureProvider::ScaleGestureListener | 89 // GestureProvider::ScaleGestureListener |
88 | 90 |
89 class GestureProvider::ScaleGestureListenerImpl | 91 class GestureProvider::ScaleGestureListenerImpl |
90 : public ScaleGestureDetector::ScaleGestureListener { | 92 : public ScaleGestureDetector::ScaleGestureListener { |
91 public: | 93 public: |
92 ScaleGestureListenerImpl(const ScaleGestureDetector::Config& config, | 94 ScaleGestureListenerImpl(const ScaleGestureDetector::Config& config, |
93 float device_scale_factor, | |
94 GestureProvider* provider) | 95 GestureProvider* provider) |
95 : scale_gesture_detector_(config, this), | 96 : scale_gesture_detector_(config, this), |
96 provider_(provider), | 97 provider_(provider), |
97 px_to_dp_(1.0f / device_scale_factor), | |
98 ignore_multitouch_events_(false), | 98 ignore_multitouch_events_(false), |
99 pinch_event_sent_(false) {} | 99 pinch_event_sent_(false) {} |
100 | 100 |
101 bool OnTouchEvent(const MotionEvent& event) { | 101 bool OnTouchEvent(const MotionEvent& event) { |
102 // TODO: Need to deal with multi-touch transition. | 102 // TODO: Need to deal with multi-touch transition. |
103 const bool in_scale_gesture = IsScaleGestureDetectionInProgress(); | 103 const bool in_scale_gesture = IsScaleGestureDetectionInProgress(); |
104 bool handled = scale_gesture_detector_.OnTouchEvent(event); | 104 bool handled = scale_gesture_detector_.OnTouchEvent(event); |
105 if (!in_scale_gesture && | 105 if (!in_scale_gesture && |
106 (event.GetAction() == MotionEvent::ACTION_UP || | 106 (event.GetAction() == MotionEvent::ACTION_UP || |
107 event.GetAction() == MotionEvent::ACTION_CANCEL)) { | 107 event.GetAction() == MotionEvent::ACTION_CANCEL)) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 if (detector.InDoubleTapMode()) { | 148 if (detector.InDoubleTapMode()) { |
149 // Relative changes in the double-tap scale factor computed by |detector| | 149 // Relative changes in the double-tap scale factor computed by |detector| |
150 // diminish as the touch moves away from the original double-tap focus. | 150 // diminish as the touch moves away from the original double-tap focus. |
151 // For historical reasons, Chrome has instead adopted a scale factor | 151 // For historical reasons, Chrome has instead adopted a scale factor |
152 // computation that is invariant to the focal distance, where | 152 // computation that is invariant to the focal distance, where |
153 // the scale delta remains constant if the touch velocity is constant. | 153 // the scale delta remains constant if the touch velocity is constant. |
154 float dy = | 154 float dy = |
155 (detector.GetCurrentSpanY() - detector.GetPreviousSpanY()) * 0.5f; | 155 (detector.GetCurrentSpanY() - detector.GetPreviousSpanY()) * 0.5f; |
156 scale = std::pow(scale > 1 ? 1.0f + kDoubleTapDragZoomSpeed | 156 scale = std::pow(scale > 1 ? 1.0f + kDoubleTapDragZoomSpeed |
157 : 1.0f - kDoubleTapDragZoomSpeed, | 157 : 1.0f - kDoubleTapDragZoomSpeed, |
158 std::abs(dy * px_to_dp_)); | 158 std::abs(dy)); |
159 } | 159 } |
160 GestureEventDetails pinch_details(ET_GESTURE_PINCH_UPDATE, scale, 0); | 160 GestureEventDetails pinch_details(ET_GESTURE_PINCH_UPDATE, scale, 0); |
161 provider_->Send(CreateGesture(ET_GESTURE_PINCH_UPDATE, | 161 provider_->Send(CreateGesture(ET_GESTURE_PINCH_UPDATE, |
162 e.GetId(), | 162 e.GetId(), |
163 detector.GetEventTime(), | 163 detector.GetEventTime(), |
164 detector.GetFocusX(), | 164 detector.GetFocusX(), |
165 detector.GetFocusY(), | 165 detector.GetFocusY(), |
166 pinch_details)); | 166 pinch_details)); |
167 return true; | 167 return true; |
168 } | 168 } |
(...skipping 21 matching lines...) Expand all Loading... |
190 | 190 |
191 private: | 191 private: |
192 bool InDoubleTapMode() const { | 192 bool InDoubleTapMode() const { |
193 return scale_gesture_detector_.InDoubleTapMode(); | 193 return scale_gesture_detector_.InDoubleTapMode(); |
194 } | 194 } |
195 | 195 |
196 ScaleGestureDetector scale_gesture_detector_; | 196 ScaleGestureDetector scale_gesture_detector_; |
197 | 197 |
198 GestureProvider* const provider_; | 198 GestureProvider* const provider_; |
199 | 199 |
200 // TODO(jdduke): Remove this when all MotionEvent's use DIPs. | |
201 const float px_to_dp_; | |
202 | |
203 // Completely silence multi-touch (pinch) scaling events. Used in WebView when | 200 // Completely silence multi-touch (pinch) scaling events. Used in WebView when |
204 // zoom support is turned off. | 201 // zoom support is turned off. |
205 bool ignore_multitouch_events_; | 202 bool ignore_multitouch_events_; |
206 | 203 |
207 // Whether any pinch zoom event has been sent to native. | 204 // Whether any pinch zoom event has been sent to native. |
208 bool pinch_event_sent_; | 205 bool pinch_event_sent_; |
209 | 206 |
210 DISALLOW_COPY_AND_ASSIGN(ScaleGestureListenerImpl); | 207 DISALLOW_COPY_AND_ASSIGN(ScaleGestureListenerImpl); |
211 }; | 208 }; |
212 | 209 |
213 // GestureProvider::GestureListener | 210 // GestureProvider::GestureListener |
214 | 211 |
215 class GestureProvider::GestureListenerImpl | 212 class GestureProvider::GestureListenerImpl |
216 : public GestureDetector::GestureListener, | 213 : public GestureDetector::GestureListener, |
217 public GestureDetector::DoubleTapListener { | 214 public GestureDetector::DoubleTapListener { |
218 public: | 215 public: |
219 GestureListenerImpl( | 216 GestureListenerImpl( |
| 217 const gfx::Display& display, |
220 const GestureDetector::Config& gesture_detector_config, | 218 const GestureDetector::Config& gesture_detector_config, |
221 const SnapScrollController::Config& snap_scroll_controller_config, | |
222 bool disable_click_delay, | 219 bool disable_click_delay, |
223 GestureProvider* provider) | 220 GestureProvider* provider) |
224 : gesture_detector_(gesture_detector_config, this, this), | 221 : gesture_detector_(gesture_detector_config, this, this), |
225 snap_scroll_controller_(snap_scroll_controller_config), | 222 snap_scroll_controller_(display), |
226 provider_(provider), | 223 provider_(provider), |
227 disable_click_delay_(disable_click_delay), | 224 disable_click_delay_(disable_click_delay), |
228 scaled_touch_slop_(gesture_detector_config.scaled_touch_slop), | 225 touch_slop_(gesture_detector_config.touch_slop), |
229 scaled_touch_slop_square_(scaled_touch_slop_ * scaled_touch_slop_), | |
230 double_tap_timeout_(gesture_detector_config.double_tap_timeout), | 226 double_tap_timeout_(gesture_detector_config.double_tap_timeout), |
231 ignore_single_tap_(false), | 227 ignore_single_tap_(false), |
232 seen_first_scroll_event_(false), | 228 seen_first_scroll_event_(false) {} |
233 last_raw_x_(0), | |
234 last_raw_y_(0), | |
235 accumulated_scroll_error_x_(0), | |
236 accumulated_scroll_error_y_(0) {} | |
237 | 229 |
238 virtual ~GestureListenerImpl() {} | 230 virtual ~GestureListenerImpl() {} |
239 | 231 |
240 bool OnTouchEvent(const MotionEvent& e, | 232 bool OnTouchEvent(const MotionEvent& e, |
241 bool is_scale_gesture_detection_in_progress) { | 233 bool is_scale_gesture_detection_in_progress) { |
242 snap_scroll_controller_.SetSnapScrollingMode( | 234 snap_scroll_controller_.SetSnapScrollingMode( |
243 e, is_scale_gesture_detection_in_progress); | 235 e, is_scale_gesture_detection_in_progress); |
244 | 236 |
245 if (is_scale_gesture_detection_in_progress) | 237 if (is_scale_gesture_detection_in_progress) |
246 SetIgnoreSingleTap(true); | 238 SetIgnoreSingleTap(true); |
247 | 239 |
248 if (e.GetAction() == MotionEvent::ACTION_DOWN) | 240 if (e.GetAction() == MotionEvent::ACTION_DOWN) |
249 gesture_detector_.set_is_longpress_enabled(true); | 241 gesture_detector_.set_is_longpress_enabled(true); |
250 | 242 |
251 return gesture_detector_.OnTouchEvent(e); | 243 return gesture_detector_.OnTouchEvent(e); |
252 } | 244 } |
253 | 245 |
254 // GestureDetector::GestureListener implementation. | 246 // GestureDetector::GestureListener implementation. |
255 virtual bool OnDown(const MotionEvent& e) OVERRIDE { | 247 virtual bool OnDown(const MotionEvent& e) OVERRIDE { |
256 current_down_time_ = e.GetEventTime(); | 248 current_down_time_ = e.GetEventTime(); |
257 ignore_single_tap_ = false; | 249 ignore_single_tap_ = false; |
258 seen_first_scroll_event_ = false; | 250 seen_first_scroll_event_ = false; |
259 last_raw_x_ = e.GetRawX(); | |
260 last_raw_y_ = e.GetRawY(); | |
261 accumulated_scroll_error_x_ = 0; | |
262 accumulated_scroll_error_y_ = 0; | |
263 | 251 |
264 GestureEventDetails tap_details(ET_GESTURE_TAP_DOWN, 0, 0); | 252 GestureEventDetails tap_details(ET_GESTURE_TAP_DOWN, 0, 0); |
265 tap_details.set_bounding_box( | 253 tap_details.set_bounding_box( |
266 gfx::RectF(e.GetTouchMajor(), e.GetTouchMajor())); | 254 gfx::RectF(e.GetTouchMajor(), e.GetTouchMajor())); |
267 provider_->Send(CreateGesture(ET_GESTURE_TAP_DOWN, e, tap_details)); | 255 provider_->Send(CreateGesture(ET_GESTURE_TAP_DOWN, e, tap_details)); |
268 | 256 |
269 // Return true to indicate that we want to handle touch. | 257 // Return true to indicate that we want to handle touch. |
270 return true; | 258 return true; |
271 } | 259 } |
272 | 260 |
273 virtual bool OnScroll(const MotionEvent& e1, | 261 virtual bool OnScroll(const MotionEvent& e1, |
274 const MotionEvent& e2, | 262 const MotionEvent& e2, |
275 float raw_distance_x, | 263 float raw_distance_x, |
276 float raw_distance_y) OVERRIDE { | 264 float raw_distance_y) OVERRIDE { |
277 float distance_x = raw_distance_x; | 265 float distance_x = raw_distance_x; |
278 float distance_y = raw_distance_y; | 266 float distance_y = raw_distance_y; |
279 if (!seen_first_scroll_event_) { | 267 if (!seen_first_scroll_event_) { |
280 // Remove the touch slop region from the first scroll event to avoid a | 268 // Remove the touch slop region from the first scroll event to avoid a |
281 // jump. | 269 // jump. |
282 seen_first_scroll_event_ = true; | 270 seen_first_scroll_event_ = true; |
283 double distance = | 271 double distance = |
284 std::sqrt(distance_x * distance_x + distance_y * distance_y); | 272 std::sqrt(distance_x * distance_x + distance_y * distance_y); |
285 double epsilon = 1e-3; | 273 double epsilon = 1e-3; |
286 if (distance > epsilon) { | 274 if (distance > epsilon) { |
287 double ratio = std::max(0., distance - scaled_touch_slop_) / distance; | 275 double ratio = std::max(0., distance - touch_slop_) / distance; |
288 distance_x *= ratio; | 276 distance_x *= ratio; |
289 distance_y *= ratio; | 277 distance_y *= ratio; |
290 } | 278 } |
291 } | 279 } |
292 snap_scroll_controller_.UpdateSnapScrollMode(distance_x, distance_y); | 280 snap_scroll_controller_.UpdateSnapScrollMode(distance_x, distance_y); |
293 if (snap_scroll_controller_.IsSnappingScrolls()) { | 281 if (snap_scroll_controller_.IsSnappingScrolls()) { |
294 if (snap_scroll_controller_.IsSnapHorizontal()) { | 282 if (snap_scroll_controller_.IsSnapHorizontal()) { |
295 distance_y = 0; | 283 distance_y = 0; |
296 } else { | 284 } else { |
297 distance_x = 0; | 285 distance_x = 0; |
298 } | 286 } |
299 } | 287 } |
300 | 288 |
301 last_raw_x_ = e2.GetRawX(); | |
302 last_raw_y_ = e2.GetRawY(); | |
303 if (!provider_->IsScrollInProgress()) { | 289 if (!provider_->IsScrollInProgress()) { |
304 // Note that scroll start hints are in distance traveled, where | 290 // Note that scroll start hints are in distance traveled, where |
305 // scroll deltas are in the opposite direction. | 291 // scroll deltas are in the opposite direction. |
306 GestureEventDetails scroll_details( | 292 GestureEventDetails scroll_details( |
307 ET_GESTURE_SCROLL_BEGIN, -raw_distance_x, -raw_distance_y); | 293 ET_GESTURE_SCROLL_BEGIN, -raw_distance_x, -raw_distance_y); |
308 provider_->Send(CreateGesture(ET_GESTURE_SCROLL_BEGIN, | 294 provider_->Send(CreateGesture(ET_GESTURE_SCROLL_BEGIN, |
309 e2.GetId(), | 295 e2.GetId(), |
310 e2.GetEventTime(), | 296 e2.GetEventTime(), |
311 e1.GetX(), | 297 e1.GetX(), |
312 e1.GetY(), | 298 e1.GetY(), |
313 scroll_details)); | 299 scroll_details)); |
314 } | 300 } |
315 | 301 |
316 // distance_x and distance_y is the scrolling offset since last OnScroll. | 302 if (distance_x || distance_y) { |
317 // Because we are passing integers to Blink, this could introduce | 303 GestureEventDetails scroll_details( |
318 // rounding errors. The rounding errors will accumulate overtime. | 304 ET_GESTURE_SCROLL_UPDATE, -distance_x, -distance_y); |
319 // To solve this, we should be adding back the rounding errors each time | |
320 // when we calculate the new offset. | |
321 // TODO(jdduke): Determine if we can simpy use floating point deltas, as | |
322 // WebGestureEvent also takes floating point deltas for GestureScrollUpdate. | |
323 int dx = (int)(distance_x + accumulated_scroll_error_x_); | |
324 int dy = (int)(distance_y + accumulated_scroll_error_y_); | |
325 accumulated_scroll_error_x_ += (distance_x - dx); | |
326 accumulated_scroll_error_y_ += (distance_y - dy); | |
327 | |
328 if (dx || dy) { | |
329 GestureEventDetails scroll_details(ET_GESTURE_SCROLL_UPDATE, -dx, -dy); | |
330 provider_->Send( | 305 provider_->Send( |
331 CreateGesture(ET_GESTURE_SCROLL_UPDATE, e2, scroll_details)); | 306 CreateGesture(ET_GESTURE_SCROLL_UPDATE, e2, scroll_details)); |
332 } | 307 } |
333 | 308 |
334 return true; | 309 return true; |
335 } | 310 } |
336 | 311 |
337 virtual bool OnFling(const MotionEvent& e1, | 312 virtual bool OnFling(const MotionEvent& e1, |
338 const MotionEvent& e2, | 313 const MotionEvent& e2, |
339 float velocity_x, | 314 float velocity_x, |
(...skipping 13 matching lines...) Expand all Loading... |
353 virtual void OnShowPress(const MotionEvent& e) OVERRIDE { | 328 virtual void OnShowPress(const MotionEvent& e) OVERRIDE { |
354 GestureEventDetails show_press_details(ET_GESTURE_SHOW_PRESS, 0, 0); | 329 GestureEventDetails show_press_details(ET_GESTURE_SHOW_PRESS, 0, 0); |
355 // TODO(jdduke): Expose minor axis length and rotation in |MotionEvent|. | 330 // TODO(jdduke): Expose minor axis length and rotation in |MotionEvent|. |
356 show_press_details.set_bounding_box( | 331 show_press_details.set_bounding_box( |
357 gfx::RectF(e.GetTouchMajor(), e.GetTouchMajor())); | 332 gfx::RectF(e.GetTouchMajor(), e.GetTouchMajor())); |
358 provider_->Send( | 333 provider_->Send( |
359 CreateGesture(ET_GESTURE_SHOW_PRESS, e, show_press_details)); | 334 CreateGesture(ET_GESTURE_SHOW_PRESS, e, show_press_details)); |
360 } | 335 } |
361 | 336 |
362 virtual bool OnSingleTapUp(const MotionEvent& e) OVERRIDE { | 337 virtual bool OnSingleTapUp(const MotionEvent& e) OVERRIDE { |
363 if (IsPointOutsideCurrentSlopRegion(e.GetRawX(), e.GetRawY())) { | |
364 provider_->SendTapCancelIfNecessary(e); | |
365 ignore_single_tap_ = true; | |
366 return true; | |
367 } | |
368 // This is a hack to address the issue where user hovers | 338 // This is a hack to address the issue where user hovers |
369 // over a link for longer than double_tap_timeout_, then | 339 // over a link for longer than double_tap_timeout_, then |
370 // OnSingleTapConfirmed() is not triggered. But we still | 340 // OnSingleTapConfirmed() is not triggered. But we still |
371 // want to trigger the tap event at UP. So we override | 341 // want to trigger the tap event at UP. So we override |
372 // OnSingleTapUp() in this case. This assumes singleTapUp | 342 // OnSingleTapUp() in this case. This assumes singleTapUp |
373 // gets always called before singleTapConfirmed. | 343 // gets always called before singleTapConfirmed. |
374 if (!ignore_single_tap_) { | 344 if (!ignore_single_tap_) { |
375 if (e.GetEventTime() - current_down_time_ > double_tap_timeout_) { | 345 if (e.GetEventTime() - current_down_time_ > double_tap_timeout_) { |
376 return OnSingleTapConfirmed(e); | 346 return OnSingleTapConfirmed(e); |
377 } else if (!IsDoubleTapEnabled() || disable_click_delay_) { | 347 } else if (!IsDoubleTapEnabled() || disable_click_delay_) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 } | 427 } |
458 } | 428 } |
459 | 429 |
460 bool IsClickDelayDisabled() const { return disable_click_delay_; } | 430 bool IsClickDelayDisabled() const { return disable_click_delay_; } |
461 | 431 |
462 bool IsDoubleTapInProgress() const { | 432 bool IsDoubleTapInProgress() const { |
463 return gesture_detector_.is_double_tapping(); | 433 return gesture_detector_.is_double_tapping(); |
464 } | 434 } |
465 | 435 |
466 private: | 436 private: |
467 bool IsPointOutsideCurrentSlopRegion(float x, float y) const { | |
468 return IsDistanceGreaterThanTouchSlop(last_raw_x_ - x, last_raw_y_ - y); | |
469 } | |
470 | |
471 bool IsDistanceGreaterThanTouchSlop(float distance_x, | |
472 float distance_y) const { | |
473 return distance_x * distance_x + distance_y * distance_y > | |
474 scaled_touch_slop_square_; | |
475 } | |
476 | |
477 void SetIgnoreSingleTap(bool value) { ignore_single_tap_ = value; } | 437 void SetIgnoreSingleTap(bool value) { ignore_single_tap_ = value; } |
478 | 438 |
479 bool IsDoubleTapEnabled() const { | 439 bool IsDoubleTapEnabled() const { |
480 return gesture_detector_.has_doubletap_listener(); | 440 return gesture_detector_.has_doubletap_listener(); |
481 } | 441 } |
482 | 442 |
483 GestureDetector gesture_detector_; | 443 GestureDetector gesture_detector_; |
484 SnapScrollController snap_scroll_controller_; | 444 SnapScrollController snap_scroll_controller_; |
485 | 445 |
486 GestureProvider* const provider_; | 446 GestureProvider* const provider_; |
487 | 447 |
488 // Whether the click delay should always be disabled by sending clicks for | 448 // Whether the click delay should always be disabled by sending clicks for |
489 // double-tap gestures. | 449 // double-tap gestures. |
490 const bool disable_click_delay_; | 450 const bool disable_click_delay_; |
491 | 451 |
492 const int scaled_touch_slop_; | 452 const float touch_slop_; |
493 | |
494 // Cache of square of the scaled touch slop so we don't have to calculate it | |
495 // on every touch. | |
496 const int scaled_touch_slop_square_; | |
497 | 453 |
498 const base::TimeDelta double_tap_timeout_; | 454 const base::TimeDelta double_tap_timeout_; |
499 | 455 |
500 base::TimeTicks current_down_time_; | 456 base::TimeTicks current_down_time_; |
501 | 457 |
502 // TODO(klobag): This is to avoid a bug in GestureDetector. With multi-touch, | 458 // TODO(klobag): This is to avoid a bug in GestureDetector. With multi-touch, |
503 // always_in_tap_region_ is not reset. So when the last finger is up, | 459 // always_in_tap_region_ is not reset. So when the last finger is up, |
504 // OnSingleTapUp() will be mistakenly fired. | 460 // OnSingleTapUp() will be mistakenly fired. |
505 bool ignore_single_tap_; | 461 bool ignore_single_tap_; |
506 | 462 |
507 // Used to remove the touch slop from the initial scroll event in a scroll | 463 // Used to remove the touch slop from the initial scroll event in a scroll |
508 // gesture. | 464 // gesture. |
509 bool seen_first_scroll_event_; | 465 bool seen_first_scroll_event_; |
510 | 466 |
511 // Used to track the last rawX/Y coordinates for moves. This gives absolute | |
512 // scroll distance. | |
513 // Useful for full screen tracking. | |
514 float last_raw_x_; | |
515 float last_raw_y_; | |
516 | |
517 // Used to track the accumulated scroll error over time. This is used to | |
518 // remove the | |
519 // rounding error we introduced by passing integers to webkit. | |
520 float accumulated_scroll_error_x_; | |
521 float accumulated_scroll_error_y_; | |
522 | |
523 DISALLOW_COPY_AND_ASSIGN(GestureListenerImpl); | 467 DISALLOW_COPY_AND_ASSIGN(GestureListenerImpl); |
524 }; | 468 }; |
525 | 469 |
526 // GestureProvider | 470 // GestureProvider |
527 | 471 |
528 GestureProvider::GestureProvider(const Config& config, | 472 GestureProvider::GestureProvider(const Config& config, |
529 GestureProviderClient* client) | 473 GestureProviderClient* client) |
530 : client_(client), | 474 : client_(client), |
531 needs_show_press_event_(false), | 475 needs_show_press_event_(false), |
532 needs_tap_ending_event_(false), | 476 needs_tap_ending_event_(false), |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 return double_tap_support_for_page_ && double_tap_support_for_platform_; | 540 return double_tap_support_for_page_ && double_tap_support_for_platform_; |
597 } | 541 } |
598 | 542 |
599 bool GestureProvider::IsClickDelayDisabled() const { | 543 bool GestureProvider::IsClickDelayDisabled() const { |
600 return gesture_listener_->IsClickDelayDisabled(); | 544 return gesture_listener_->IsClickDelayDisabled(); |
601 } | 545 } |
602 | 546 |
603 void GestureProvider::InitGestureDetectors(const Config& config) { | 547 void GestureProvider::InitGestureDetectors(const Config& config) { |
604 TRACE_EVENT0("input", "GestureProvider::InitGestureDetectors"); | 548 TRACE_EVENT0("input", "GestureProvider::InitGestureDetectors"); |
605 gesture_listener_.reset( | 549 gesture_listener_.reset( |
606 new GestureListenerImpl(config.gesture_detector_config, | 550 new GestureListenerImpl(config.display, |
607 config.snap_scroll_controller_config, | 551 config.gesture_detector_config, |
608 config.disable_click_delay, | 552 config.disable_click_delay, |
609 this)); | 553 this)); |
610 | 554 |
611 scale_gesture_listener_.reset(new ScaleGestureListenerImpl( | 555 scale_gesture_listener_.reset( |
612 config.scale_gesture_detector_config, | 556 new ScaleGestureListenerImpl(config.scale_gesture_detector_config, this)); |
613 config.snap_scroll_controller_config.device_scale_factor, | |
614 this)); | |
615 | 557 |
616 UpdateDoubleTapDetectionSupport(); | 558 UpdateDoubleTapDetectionSupport(); |
617 } | 559 } |
618 | 560 |
619 bool GestureProvider::CanHandle(const MotionEvent& event) const { | 561 bool GestureProvider::CanHandle(const MotionEvent& event) const { |
620 return event.GetAction() == MotionEvent::ACTION_DOWN || current_down_event_; | 562 return event.GetAction() == MotionEvent::ACTION_DOWN || current_down_event_; |
621 } | 563 } |
622 | 564 |
623 void GestureProvider::Fling(const MotionEvent& event, | 565 void GestureProvider::Fling(const MotionEvent& event, |
624 float velocity_x, | 566 float velocity_x, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 Send(CreateGesture(ET_GESTURE_END, event)); | 756 Send(CreateGesture(ET_GESTURE_END, event)); |
815 break; | 757 break; |
816 case MotionEvent::ACTION_DOWN: | 758 case MotionEvent::ACTION_DOWN: |
817 case MotionEvent::ACTION_POINTER_DOWN: | 759 case MotionEvent::ACTION_POINTER_DOWN: |
818 case MotionEvent::ACTION_MOVE: | 760 case MotionEvent::ACTION_MOVE: |
819 break; | 761 break; |
820 } | 762 } |
821 } | 763 } |
822 | 764 |
823 } // namespace ui | 765 } // namespace ui |
OLD | NEW |