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/renderer/input/input_handler_proxy.h" | 5 #include "content/renderer/input/input_handler_proxy.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
493 input_handler_->ScrollEnd(); | 493 input_handler_->ScrollEnd(); |
494 if (!gesture_scroll_on_impl_thread_) | 494 if (!gesture_scroll_on_impl_thread_) |
495 return DID_NOT_HANDLE; | 495 return DID_NOT_HANDLE; |
496 gesture_scroll_on_impl_thread_ = false; | 496 gesture_scroll_on_impl_thread_ = false; |
497 return DID_HANDLE; | 497 return DID_HANDLE; |
498 } | 498 } |
499 | 499 |
500 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureFlingStart( | 500 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureFlingStart( |
501 const WebGestureEvent& gesture_event) { | 501 const WebGestureEvent& gesture_event) { |
502 cc::InputHandler::ScrollStatus scroll_status; | 502 cc::InputHandler::ScrollStatus scroll_status; |
503 | 503 switch (gesture_event.sourceDevice) { |
504 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) { | 504 case blink::WebGestureDeviceTouchpad: |
505 if (gesture_event.data.flingStart.targetViewport) { | 505 if (gesture_event.data.flingStart.targetViewport) { |
506 scroll_status = input_handler_->RootScrollBegin( | 506 scroll_status = input_handler_->RootScrollBegin( |
507 cc::InputHandler::NON_BUBBLING_GESTURE); | 507 cc::InputHandler::NON_BUBBLING_GESTURE); |
508 } else { | 508 } else { |
509 scroll_status = input_handler_->ScrollBegin( | 509 scroll_status = input_handler_->ScrollBegin( |
510 gfx::Point(gesture_event.x, gesture_event.y), | 510 gfx::Point(gesture_event.x, gesture_event.y), |
511 cc::InputHandler::NON_BUBBLING_GESTURE); | 511 cc::InputHandler::NON_BUBBLING_GESTURE); |
512 } | 512 } |
513 } else { | 513 break; |
514 case blink::WebGestureDeviceTouchscreen: | |
514 if (!gesture_scroll_on_impl_thread_) | 515 if (!gesture_scroll_on_impl_thread_) |
515 scroll_status = cc::InputHandler::SCROLL_ON_MAIN_THREAD; | 516 scroll_status = cc::InputHandler::SCROLL_ON_MAIN_THREAD; |
516 else | 517 else |
517 scroll_status = input_handler_->FlingScrollBegin(); | 518 scroll_status = input_handler_->FlingScrollBegin(); |
519 break; | |
520 case blink::WebGestureDeviceUninitialized: | |
521 NOTREACHED(); | |
522 return DID_NOT_HANDLE; | |
518 } | 523 } |
519 | 524 |
520 #ifndef NDEBUG | 525 #ifndef NDEBUG |
521 expect_scroll_update_end_ = false; | 526 expect_scroll_update_end_ = false; |
522 #endif | 527 #endif |
523 | 528 |
524 switch (scroll_status) { | 529 switch (scroll_status) { |
525 case cc::InputHandler::SCROLL_STARTED: { | 530 case cc::InputHandler::SCROLL_STARTED: { |
526 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) | 531 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) |
527 input_handler_->ScrollEnd(); | 532 input_handler_->ScrollEnd(); |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1015 case blink::WebGestureDeviceTouchpad: | 1020 case blink::WebGestureDeviceTouchpad: |
1016 did_scroll = TouchpadFlingScroll(clipped_increment); | 1021 did_scroll = TouchpadFlingScroll(clipped_increment); |
1017 break; | 1022 break; |
1018 case blink::WebGestureDeviceTouchscreen: { | 1023 case blink::WebGestureDeviceTouchscreen: { |
1019 clipped_increment = ToClientScrollIncrement(clipped_increment); | 1024 clipped_increment = ToClientScrollIncrement(clipped_increment); |
1020 cc::InputHandlerScrollResult scroll_result = input_handler_->ScrollBy( | 1025 cc::InputHandlerScrollResult scroll_result = input_handler_->ScrollBy( |
1021 fling_parameters_.point, clipped_increment); | 1026 fling_parameters_.point, clipped_increment); |
1022 HandleOverscroll(fling_parameters_.point, scroll_result); | 1027 HandleOverscroll(fling_parameters_.point, scroll_result); |
1023 did_scroll = scroll_result.did_scroll; | 1028 did_scroll = scroll_result.did_scroll; |
1024 } break; | 1029 } break; |
1030 case blink::WebGestureDeviceUninitialized: | |
1031 NOTREACHED(); | |
tdresser
2015/10/14 17:18:56
Should we have an early return here?
wjmaclean
2015/10/14 18:03:28
Done.
| |
1025 } | 1032 } |
1026 | 1033 |
1027 if (did_scroll) { | 1034 if (did_scroll) { |
1028 fling_parameters_.cumulativeScroll.width += clipped_increment.width; | 1035 fling_parameters_.cumulativeScroll.width += clipped_increment.width; |
1029 fling_parameters_.cumulativeScroll.height += clipped_increment.height; | 1036 fling_parameters_.cumulativeScroll.height += clipped_increment.height; |
1030 } | 1037 } |
1031 | 1038 |
1032 // It's possible the provided |increment| is sufficiently small as to not | 1039 // It's possible the provided |increment| is sufficiently small as to not |
1033 // trigger a scroll, e.g., with a trivial time delta between fling updates. | 1040 // trigger a scroll, e.g., with a trivial time delta between fling updates. |
1034 // Return true in this case to prevent early fling termination. | 1041 // Return true in this case to prevent early fling termination. |
1035 if (std::abs(clipped_increment.width) < kScrollEpsilon && | 1042 if (std::abs(clipped_increment.width) < kScrollEpsilon && |
1036 std::abs(clipped_increment.height) < kScrollEpsilon) | 1043 std::abs(clipped_increment.height) < kScrollEpsilon) |
1037 return true; | 1044 return true; |
1038 | 1045 |
1039 return did_scroll; | 1046 return did_scroll; |
1040 } | 1047 } |
1041 | 1048 |
1042 } // namespace content | 1049 } // namespace content |
OLD | NEW |