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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 274 |
275 bool OnTouchEvent(const MotionEvent& e, | 275 bool OnTouchEvent(const MotionEvent& e, |
276 bool is_scale_gesture_detection_in_progress) { | 276 bool is_scale_gesture_detection_in_progress) { |
277 snap_scroll_controller_.SetSnapScrollingMode( | 277 snap_scroll_controller_.SetSnapScrollingMode( |
278 e, is_scale_gesture_detection_in_progress); | 278 e, is_scale_gesture_detection_in_progress); |
279 | 279 |
280 if (is_scale_gesture_detection_in_progress) | 280 if (is_scale_gesture_detection_in_progress) |
281 SetIgnoreSingleTap(true); | 281 SetIgnoreSingleTap(true); |
282 | 282 |
283 if (e.GetAction() == MotionEvent::ACTION_DOWN) | 283 if (e.GetAction() == MotionEvent::ACTION_DOWN) |
284 gesture_detector_.set_is_longpress_enabled(true); | 284 gesture_detector_.set_longpress_enabled(true); |
285 | 285 |
286 return gesture_detector_.OnTouchEvent(e); | 286 return gesture_detector_.OnTouchEvent(e); |
287 } | 287 } |
288 | 288 |
289 // GestureDetector::GestureListener implementation. | 289 // GestureDetector::GestureListener implementation. |
290 virtual bool OnDown(const MotionEvent& e) OVERRIDE { | 290 virtual bool OnDown(const MotionEvent& e) OVERRIDE { |
291 current_down_time_ = e.GetEventTime(); | 291 current_down_time_ = e.GetEventTime(); |
292 ignore_single_tap_ = false; | 292 ignore_single_tap_ = false; |
293 seen_first_scroll_event_ = false; | 293 seen_first_scroll_event_ = false; |
294 | 294 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 velocity_y = 0; | 364 velocity_y = 0; |
365 } else { | 365 } else { |
366 velocity_x = 0; | 366 velocity_x = 0; |
367 } | 367 } |
368 } | 368 } |
369 | 369 |
370 provider_->Fling(e2, velocity_x, velocity_y); | 370 provider_->Fling(e2, velocity_x, velocity_y); |
371 return true; | 371 return true; |
372 } | 372 } |
373 | 373 |
| 374 virtual bool OnSwipe(const MotionEvent& e1, |
| 375 const MotionEvent& e2, |
| 376 float velocity_x, |
| 377 float velocity_y) OVERRIDE { |
| 378 GestureEventDetails swipe_details( |
| 379 ET_GESTURE_MULTIFINGER_SWIPE, velocity_x, velocity_y); |
| 380 provider_->Send( |
| 381 CreateGesture(ET_GESTURE_MULTIFINGER_SWIPE, e2, swipe_details)); |
| 382 return true; |
| 383 } |
| 384 |
374 virtual void OnShowPress(const MotionEvent& e) OVERRIDE { | 385 virtual void OnShowPress(const MotionEvent& e) OVERRIDE { |
375 GestureEventDetails show_press_details(ET_GESTURE_SHOW_PRESS, 0, 0); | 386 GestureEventDetails show_press_details(ET_GESTURE_SHOW_PRESS, 0, 0); |
376 provider_->Send( | 387 provider_->Send( |
377 CreateGesture(ET_GESTURE_SHOW_PRESS, e, show_press_details)); | 388 CreateGesture(ET_GESTURE_SHOW_PRESS, e, show_press_details)); |
378 } | 389 } |
379 | 390 |
380 virtual bool OnSingleTapUp(const MotionEvent& e) OVERRIDE { | 391 virtual bool OnSingleTapUp(const MotionEvent& e) OVERRIDE { |
381 // This is a hack to address the issue where user hovers | 392 // This is a hack to address the issue where user hovers |
382 // over a link for longer than double_tap_timeout_, then | 393 // over a link for longer than double_tap_timeout_, then |
383 // OnSingleTapConfirmed() is not triggered. But we still | 394 // OnSingleTapConfirmed() is not triggered. But we still |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 provider_->Send(CreateGesture( | 429 provider_->Send(CreateGesture( |
419 ET_GESTURE_TAP, e, CreateTapGestureDetails(ET_GESTURE_TAP, e))); | 430 ET_GESTURE_TAP, e, CreateTapGestureDetails(ET_GESTURE_TAP, e))); |
420 return true; | 431 return true; |
421 } | 432 } |
422 | 433 |
423 virtual bool OnDoubleTap(const MotionEvent& e) OVERRIDE { return false; } | 434 virtual bool OnDoubleTap(const MotionEvent& e) OVERRIDE { return false; } |
424 | 435 |
425 virtual bool OnDoubleTapEvent(const MotionEvent& e) OVERRIDE { | 436 virtual bool OnDoubleTapEvent(const MotionEvent& e) OVERRIDE { |
426 switch (e.GetAction()) { | 437 switch (e.GetAction()) { |
427 case MotionEvent::ACTION_DOWN: | 438 case MotionEvent::ACTION_DOWN: |
428 gesture_detector_.set_is_longpress_enabled(false); | 439 gesture_detector_.set_longpress_enabled(false); |
429 break; | 440 break; |
430 | 441 |
431 case MotionEvent::ACTION_UP: | 442 case MotionEvent::ACTION_UP: |
432 if (!provider_->IsPinchInProgress() && | 443 if (!provider_->IsPinchInProgress() && |
433 !provider_->IsScrollInProgress()) { | 444 !provider_->IsScrollInProgress()) { |
434 provider_->Send( | 445 provider_->Send( |
435 CreateGesture(ET_GESTURE_DOUBLE_TAP, | 446 CreateGesture(ET_GESTURE_DOUBLE_TAP, |
436 e, | 447 e, |
437 CreateTapGestureDetails(ET_GESTURE_DOUBLE_TAP, e))); | 448 CreateTapGestureDetails(ET_GESTURE_DOUBLE_TAP, e))); |
438 return true; | 449 return true; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 if (current_down_event_) | 757 if (current_down_event_) |
747 return; | 758 return; |
748 | 759 |
749 const bool double_tap_enabled = double_tap_support_for_page_ && | 760 const bool double_tap_enabled = double_tap_support_for_page_ && |
750 double_tap_support_for_platform_; | 761 double_tap_support_for_platform_; |
751 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); | 762 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); |
752 scale_gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); | 763 scale_gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); |
753 } | 764 } |
754 | 765 |
755 } // namespace ui | 766 } // namespace ui |
OLD | NEW |