| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 | 10 |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 // The new deltas are calculated for each pointer individually, | 669 // The new deltas are calculated for each pointer individually, |
| 670 // and the final scroll delta is the average over all delta values. | 670 // and the final scroll delta is the average over all delta values. |
| 671 gfx::Vector2dF ComputeFirstScrollDelta( | 671 gfx::Vector2dF ComputeFirstScrollDelta( |
| 672 const MotionEvent& ev1, | 672 const MotionEvent& ev1, |
| 673 const MotionEvent& ev2, | 673 const MotionEvent& ev2, |
| 674 const MotionEvent& secondary_pointer_down) { | 674 const MotionEvent& secondary_pointer_down) { |
| 675 // If there are more than two down pointers, tapping is not possible, | 675 // If there are more than two down pointers, tapping is not possible, |
| 676 // so Slop region is not deducted. | 676 // so Slop region is not deducted. |
| 677 DCHECK(ev2.GetPointerCount() < 3); | 677 DCHECK(ev2.GetPointerCount() < 3); |
| 678 | 678 |
| 679 const int id0 = ev1.GetPointerId(0); | 679 gfx::Vector2dF delta(0, 0); |
| 680 const int ev_idx0 = ev2.GetPointerId(0) == id0 ? 0 : 1; | 680 for (size_t i = 0; i < ev2.GetPointerCount(); i++) { |
| 681 | 681 const int pointer_id = ev2.GetPointerId(i); |
| 682 // Subtract the slop region from the first pointer move. | 682 const MotionEvent* source_pointer_down_event = |
| 683 float dx0 = ev1.GetX() - ev2.GetX(ev_idx0); | 683 gesture_detector_.GetSourcePointerDownEvent( |
| 684 float dy0 = ev1.GetY() - ev2.GetY(ev_idx0); | 684 ev1, secondary_pointer_down, pointer_id); |
| 685 gfx::Vector2dF first_pointer_delta = SubtractSlopRegion(dx0, dy0); | 685 DCHECK(source_pointer_down_event); |
| 686 | 686 if (!source_pointer_down_event) |
| 687 gfx::Vector2dF second_pointer_delta(0, 0); | 687 continue; |
| 688 // Subtract the slop region from the second pointer move. | 688 int source_index = |
| 689 if (ev2.GetPointerCount() == 2) { | 689 source_pointer_down_event->FindPointerIndexOfId(pointer_id); |
| 690 const int ev_idx1 = ev_idx0 == 0 ? 1 : 0; | 690 DCHECK_GE(source_index, 0); |
| 691 const int idx1 = secondary_pointer_down.GetActionIndex(); | 691 if (source_index < 0) |
| 692 float dx1 = secondary_pointer_down.GetX(idx1) - ev2.GetX(ev_idx1); | 692 continue; |
| 693 float dy1 = secondary_pointer_down.GetY(idx1) - ev2.GetY(ev_idx1); | 693 float dx = source_pointer_down_event->GetX(source_index) - ev2.GetX(i); |
| 694 second_pointer_delta = SubtractSlopRegion(dx1, dy1); | 694 float dy = source_pointer_down_event->GetY(source_index) - ev2.GetY(i); |
| 695 delta += SubtractSlopRegion(dx, dy); |
| 695 } | 696 } |
| 696 | |
| 697 gfx::Vector2dF delta = first_pointer_delta + second_pointer_delta; | |
| 698 delta.Scale(1.0 / ev2.GetPointerCount()); | 697 delta.Scale(1.0 / ev2.GetPointerCount()); |
| 699 return delta; | 698 return delta; |
| 700 } | 699 } |
| 701 | 700 |
| 702 const GestureProvider::Config config_; | 701 const GestureProvider::Config config_; |
| 703 GestureProviderClient* const client_; | 702 GestureProviderClient* const client_; |
| 704 | 703 |
| 705 GestureDetector gesture_detector_; | 704 GestureDetector gesture_detector_; |
| 706 ScaleGestureDetector scale_gesture_detector_; | 705 ScaleGestureDetector scale_gesture_detector_; |
| 707 SnapScrollController snap_scroll_controller_; | 706 SnapScrollController snap_scroll_controller_; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 // null'ing of the listener until the sequence has ended. | 891 // null'ing of the listener until the sequence has ended. |
| 893 if (current_down_event_) | 892 if (current_down_event_) |
| 894 return; | 893 return; |
| 895 | 894 |
| 896 const bool double_tap_enabled = | 895 const bool double_tap_enabled = |
| 897 double_tap_support_for_page_ && double_tap_support_for_platform_; | 896 double_tap_support_for_page_ && double_tap_support_for_platform_; |
| 898 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); | 897 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); |
| 899 } | 898 } |
| 900 | 899 |
| 901 } // namespace ui | 900 } // namespace ui |
| OLD | NEW |