Chromium Code Reviews| 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 | |
| 504 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) { | 503 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) { |
|
tdresser
2015/10/14 15:14:20
This might read a bit better as a switch statement
wjmaclean
2015/10/14 15:55:09
Done.
| |
| 505 if (gesture_event.data.flingStart.targetViewport) { | 504 if (gesture_event.data.flingStart.targetViewport) { |
| 506 scroll_status = input_handler_->RootScrollBegin( | 505 scroll_status = input_handler_->RootScrollBegin( |
| 507 cc::InputHandler::NON_BUBBLING_GESTURE); | 506 cc::InputHandler::NON_BUBBLING_GESTURE); |
| 508 } else { | 507 } else { |
| 509 scroll_status = input_handler_->ScrollBegin( | 508 scroll_status = input_handler_->ScrollBegin( |
| 510 gfx::Point(gesture_event.x, gesture_event.y), | 509 gfx::Point(gesture_event.x, gesture_event.y), |
| 511 cc::InputHandler::NON_BUBBLING_GESTURE); | 510 cc::InputHandler::NON_BUBBLING_GESTURE); |
| 512 } | 511 } |
| 513 } else { | 512 } else if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchscreen) { |
| 514 if (!gesture_scroll_on_impl_thread_) | 513 if (!gesture_scroll_on_impl_thread_) |
| 515 scroll_status = cc::InputHandler::SCROLL_ON_MAIN_THREAD; | 514 scroll_status = cc::InputHandler::SCROLL_ON_MAIN_THREAD; |
| 516 else | 515 else |
| 517 scroll_status = input_handler_->FlingScrollBegin(); | 516 scroll_status = input_handler_->FlingScrollBegin(); |
| 517 } else { // sourceDevice == blink::WebGestureDeviceUninitialazed. | |
| 518 NOTREACHED(); | |
| 519 return DID_NOT_HANDLE; | |
| 518 } | 520 } |
| 519 | 521 |
| 520 #ifndef NDEBUG | 522 #ifndef NDEBUG |
| 521 expect_scroll_update_end_ = false; | 523 expect_scroll_update_end_ = false; |
| 522 #endif | 524 #endif |
| 523 | 525 |
| 524 switch (scroll_status) { | 526 switch (scroll_status) { |
| 525 case cc::InputHandler::SCROLL_STARTED: { | 527 case cc::InputHandler::SCROLL_STARTED: { |
| 526 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) | 528 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) |
| 527 input_handler_->ScrollEnd(); | 529 input_handler_->ScrollEnd(); |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1005 TRACE_EVENT2("input", | 1007 TRACE_EVENT2("input", |
| 1006 "InputHandlerProxy::scrollBy", | 1008 "InputHandlerProxy::scrollBy", |
| 1007 "x", | 1009 "x", |
| 1008 clipped_increment.width, | 1010 clipped_increment.width, |
| 1009 "y", | 1011 "y", |
| 1010 clipped_increment.height); | 1012 clipped_increment.height); |
| 1011 | 1013 |
| 1012 bool did_scroll = false; | 1014 bool did_scroll = false; |
| 1013 | 1015 |
| 1014 switch (fling_parameters_.sourceDevice) { | 1016 switch (fling_parameters_.sourceDevice) { |
| 1017 case blink::WebGestureDeviceUninitialized: | |
| 1018 NOTREACHED(); | |
| 1019 break; | |
|
tdresser
2015/10/14 15:14:20
We generally put exceptional cases at the end of s
wjmaclean
2015/10/14 15:55:09
Done.
| |
| 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; |
| 1025 } | 1030 } |
| 1026 | 1031 |
| 1027 if (did_scroll) { | 1032 if (did_scroll) { |
| 1028 fling_parameters_.cumulativeScroll.width += clipped_increment.width; | 1033 fling_parameters_.cumulativeScroll.width += clipped_increment.width; |
| 1029 fling_parameters_.cumulativeScroll.height += clipped_increment.height; | 1034 fling_parameters_.cumulativeScroll.height += clipped_increment.height; |
| 1030 } | 1035 } |
| 1031 | 1036 |
| 1032 // It's possible the provided |increment| is sufficiently small as to not | 1037 // 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. | 1038 // trigger a scroll, e.g., with a trivial time delta between fling updates. |
| 1034 // Return true in this case to prevent early fling termination. | 1039 // Return true in this case to prevent early fling termination. |
| 1035 if (std::abs(clipped_increment.width) < kScrollEpsilon && | 1040 if (std::abs(clipped_increment.width) < kScrollEpsilon && |
| 1036 std::abs(clipped_increment.height) < kScrollEpsilon) | 1041 std::abs(clipped_increment.height) < kScrollEpsilon) |
| 1037 return true; | 1042 return true; |
| 1038 | 1043 |
| 1039 return did_scroll; | 1044 return did_scroll; |
| 1040 } | 1045 } |
| 1041 | 1046 |
| 1042 } // namespace content | 1047 } // namespace content |
| OLD | NEW |