| 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 251 |
| 252 bool OnTouchEvent(const MotionEvent& e, | 252 bool OnTouchEvent(const MotionEvent& e, |
| 253 bool is_scale_gesture_detection_in_progress) { | 253 bool is_scale_gesture_detection_in_progress) { |
| 254 snap_scroll_controller_.SetSnapScrollingMode( | 254 snap_scroll_controller_.SetSnapScrollingMode( |
| 255 e, is_scale_gesture_detection_in_progress); | 255 e, is_scale_gesture_detection_in_progress); |
| 256 | 256 |
| 257 if (is_scale_gesture_detection_in_progress) | 257 if (is_scale_gesture_detection_in_progress) |
| 258 SetIgnoreSingleTap(true); | 258 SetIgnoreSingleTap(true); |
| 259 | 259 |
| 260 if (e.GetAction() == MotionEvent::ACTION_DOWN) | 260 if (e.GetAction() == MotionEvent::ACTION_DOWN) |
| 261 gesture_detector_.set_is_longpress_enabled(true); | 261 gesture_detector_.set_longpress_enabled(true); |
| 262 | 262 |
| 263 return gesture_detector_.OnTouchEvent(e); | 263 return gesture_detector_.OnTouchEvent(e); |
| 264 } | 264 } |
| 265 | 265 |
| 266 // GestureDetector::GestureListener implementation. | 266 // GestureDetector::GestureListener implementation. |
| 267 virtual bool OnDown(const MotionEvent& e) OVERRIDE { | 267 virtual bool OnDown(const MotionEvent& e) OVERRIDE { |
| 268 current_down_time_ = e.GetEventTime(); | 268 current_down_time_ = e.GetEventTime(); |
| 269 ignore_single_tap_ = false; | 269 ignore_single_tap_ = false; |
| 270 seen_first_scroll_event_ = false; | 270 seen_first_scroll_event_ = false; |
| 271 | 271 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 velocity_y = 0; | 342 velocity_y = 0; |
| 343 } else { | 343 } else { |
| 344 velocity_x = 0; | 344 velocity_x = 0; |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 | 347 |
| 348 provider_->Fling(e2, velocity_x, velocity_y); | 348 provider_->Fling(e2, velocity_x, velocity_y); |
| 349 return true; | 349 return true; |
| 350 } | 350 } |
| 351 | 351 |
| 352 virtual bool OnSwipe(const MotionEvent& e1, |
| 353 const MotionEvent& e2, |
| 354 float velocity_x, |
| 355 float velocity_y) OVERRIDE { |
| 356 GestureEventDetails swipe_details( |
| 357 ET_GESTURE_MULTIFINGER_SWIPE, velocity_x, velocity_y); |
| 358 provider_->Send( |
| 359 CreateGesture(ET_GESTURE_MULTIFINGER_SWIPE, e2, swipe_details)); |
| 360 return true; |
| 361 } |
| 362 |
| 352 virtual void OnShowPress(const MotionEvent& e) OVERRIDE { | 363 virtual void OnShowPress(const MotionEvent& e) OVERRIDE { |
| 353 GestureEventDetails show_press_details(ET_GESTURE_SHOW_PRESS, 0, 0); | 364 GestureEventDetails show_press_details(ET_GESTURE_SHOW_PRESS, 0, 0); |
| 354 // TODO(jdduke): Expose minor axis length and rotation in |MotionEvent|. | 365 // TODO(jdduke): Expose minor axis length and rotation in |MotionEvent|. |
| 355 show_press_details.set_bounding_box( | 366 show_press_details.set_bounding_box( |
| 356 gfx::RectF(e.GetTouchMajor(), e.GetTouchMajor())); | 367 gfx::RectF(e.GetTouchMajor(), e.GetTouchMajor())); |
| 357 provider_->Send( | 368 provider_->Send( |
| 358 CreateGesture(ET_GESTURE_SHOW_PRESS, e, show_press_details)); | 369 CreateGesture(ET_GESTURE_SHOW_PRESS, e, show_press_details)); |
| 359 } | 370 } |
| 360 | 371 |
| 361 virtual bool OnSingleTapUp(const MotionEvent& e) OVERRIDE { | 372 virtual bool OnSingleTapUp(const MotionEvent& e) OVERRIDE { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 provider_->Send(CreateGesture( | 410 provider_->Send(CreateGesture( |
| 400 ET_GESTURE_TAP, e, CreateTapGestureDetails(ET_GESTURE_TAP, e))); | 411 ET_GESTURE_TAP, e, CreateTapGestureDetails(ET_GESTURE_TAP, e))); |
| 401 return true; | 412 return true; |
| 402 } | 413 } |
| 403 | 414 |
| 404 virtual bool OnDoubleTap(const MotionEvent& e) OVERRIDE { return false; } | 415 virtual bool OnDoubleTap(const MotionEvent& e) OVERRIDE { return false; } |
| 405 | 416 |
| 406 virtual bool OnDoubleTapEvent(const MotionEvent& e) OVERRIDE { | 417 virtual bool OnDoubleTapEvent(const MotionEvent& e) OVERRIDE { |
| 407 switch (e.GetAction()) { | 418 switch (e.GetAction()) { |
| 408 case MotionEvent::ACTION_DOWN: | 419 case MotionEvent::ACTION_DOWN: |
| 409 gesture_detector_.set_is_longpress_enabled(false); | 420 gesture_detector_.set_longpress_enabled(false); |
| 410 break; | 421 break; |
| 411 | 422 |
| 412 case MotionEvent::ACTION_UP: | 423 case MotionEvent::ACTION_UP: |
| 413 if (!provider_->IsPinchInProgress() && | 424 if (!provider_->IsPinchInProgress() && |
| 414 !provider_->IsScrollInProgress()) { | 425 !provider_->IsScrollInProgress()) { |
| 415 provider_->Send( | 426 provider_->Send( |
| 416 CreateGesture(ET_GESTURE_DOUBLE_TAP, | 427 CreateGesture(ET_GESTURE_DOUBLE_TAP, |
| 417 e, | 428 e, |
| 418 CreateTapGestureDetails(ET_GESTURE_DOUBLE_TAP, e))); | 429 CreateTapGestureDetails(ET_GESTURE_DOUBLE_TAP, e))); |
| 419 return true; | 430 return true; |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 if (current_down_event_) | 740 if (current_down_event_) |
| 730 return; | 741 return; |
| 731 | 742 |
| 732 const bool double_tap_enabled = double_tap_support_for_page_ && | 743 const bool double_tap_enabled = double_tap_support_for_page_ && |
| 733 double_tap_support_for_platform_; | 744 double_tap_support_for_platform_; |
| 734 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); | 745 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); |
| 735 scale_gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); | 746 scale_gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); |
| 736 } | 747 } |
| 737 | 748 |
| 738 } // namespace ui | 749 } // namespace ui |
| OLD | NEW |