| 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 #endif | 492 #endif |
| 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 cc::InputHandler::SCROLL_ON_MAIN_THREAD; |
| 504 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) { | 504 switch (gesture_event.sourceDevice) { |
| 505 case blink::WebGestureDeviceTouchpad: |
| 505 if (gesture_event.data.flingStart.targetViewport) { | 506 if (gesture_event.data.flingStart.targetViewport) { |
| 506 scroll_status = input_handler_->RootScrollBegin( | 507 scroll_status = input_handler_->RootScrollBegin( |
| 507 cc::InputHandler::NON_BUBBLING_GESTURE); | 508 cc::InputHandler::NON_BUBBLING_GESTURE); |
| 508 } else { | 509 } else { |
| 509 scroll_status = input_handler_->ScrollBegin( | 510 scroll_status = input_handler_->ScrollBegin( |
| 510 gfx::Point(gesture_event.x, gesture_event.y), | 511 gfx::Point(gesture_event.x, gesture_event.y), |
| 511 cc::InputHandler::NON_BUBBLING_GESTURE); | 512 cc::InputHandler::NON_BUBBLING_GESTURE); |
| 512 } | 513 } |
| 513 } else { | 514 break; |
| 515 case blink::WebGestureDeviceTouchscreen: |
| 514 if (!gesture_scroll_on_impl_thread_) | 516 if (!gesture_scroll_on_impl_thread_) |
| 515 scroll_status = cc::InputHandler::SCROLL_ON_MAIN_THREAD; | 517 scroll_status = cc::InputHandler::SCROLL_ON_MAIN_THREAD; |
| 516 else | 518 else |
| 517 scroll_status = input_handler_->FlingScrollBegin(); | 519 scroll_status = input_handler_->FlingScrollBegin(); |
| 520 break; |
| 521 case blink::WebGestureDeviceUninitialized: |
| 522 NOTREACHED(); |
| 523 return DID_NOT_HANDLE; |
| 518 } | 524 } |
| 519 | 525 |
| 520 #ifndef NDEBUG | 526 #ifndef NDEBUG |
| 521 expect_scroll_update_end_ = false; | 527 expect_scroll_update_end_ = false; |
| 522 #endif | 528 #endif |
| 523 | 529 |
| 524 switch (scroll_status) { | 530 switch (scroll_status) { |
| 525 case cc::InputHandler::SCROLL_STARTED: { | 531 case cc::InputHandler::SCROLL_STARTED: { |
| 526 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) | 532 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) |
| 527 input_handler_->ScrollEnd(); | 533 input_handler_->ScrollEnd(); |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 case blink::WebGestureDeviceTouchpad: | 1021 case blink::WebGestureDeviceTouchpad: |
| 1016 did_scroll = TouchpadFlingScroll(clipped_increment); | 1022 did_scroll = TouchpadFlingScroll(clipped_increment); |
| 1017 break; | 1023 break; |
| 1018 case blink::WebGestureDeviceTouchscreen: { | 1024 case blink::WebGestureDeviceTouchscreen: { |
| 1019 clipped_increment = ToClientScrollIncrement(clipped_increment); | 1025 clipped_increment = ToClientScrollIncrement(clipped_increment); |
| 1020 cc::InputHandlerScrollResult scroll_result = input_handler_->ScrollBy( | 1026 cc::InputHandlerScrollResult scroll_result = input_handler_->ScrollBy( |
| 1021 fling_parameters_.point, clipped_increment); | 1027 fling_parameters_.point, clipped_increment); |
| 1022 HandleOverscroll(fling_parameters_.point, scroll_result); | 1028 HandleOverscroll(fling_parameters_.point, scroll_result); |
| 1023 did_scroll = scroll_result.did_scroll; | 1029 did_scroll = scroll_result.did_scroll; |
| 1024 } break; | 1030 } break; |
| 1031 case blink::WebGestureDeviceUninitialized: |
| 1032 NOTREACHED(); |
| 1033 return false; |
| 1025 } | 1034 } |
| 1026 | 1035 |
| 1027 if (did_scroll) { | 1036 if (did_scroll) { |
| 1028 fling_parameters_.cumulativeScroll.width += clipped_increment.width; | 1037 fling_parameters_.cumulativeScroll.width += clipped_increment.width; |
| 1029 fling_parameters_.cumulativeScroll.height += clipped_increment.height; | 1038 fling_parameters_.cumulativeScroll.height += clipped_increment.height; |
| 1030 } | 1039 } |
| 1031 | 1040 |
| 1032 // It's possible the provided |increment| is sufficiently small as to not | 1041 // 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. | 1042 // trigger a scroll, e.g., with a trivial time delta between fling updates. |
| 1034 // Return true in this case to prevent early fling termination. | 1043 // Return true in this case to prevent early fling termination. |
| 1035 if (std::abs(clipped_increment.width) < kScrollEpsilon && | 1044 if (std::abs(clipped_increment.width) < kScrollEpsilon && |
| 1036 std::abs(clipped_increment.height) < kScrollEpsilon) | 1045 std::abs(clipped_increment.height) < kScrollEpsilon) |
| 1037 return true; | 1046 return true; |
| 1038 | 1047 |
| 1039 return did_scroll; | 1048 return did_scroll; |
| 1040 } | 1049 } |
| 1041 | 1050 |
| 1042 } // namespace content | 1051 } // namespace content |
| OLD | NEW |