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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
449 InputHandlerProxy::HandleGestureScrollUpdate( | 449 InputHandlerProxy::HandleGestureScrollUpdate( |
450 const WebGestureEvent& gesture_event) { | 450 const WebGestureEvent& gesture_event) { |
451 #ifndef NDEBUG | 451 #ifndef NDEBUG |
452 DCHECK(expect_scroll_update_end_); | 452 DCHECK(expect_scroll_update_end_); |
453 #endif | 453 #endif |
454 | 454 |
455 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) | 455 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) |
456 return DID_NOT_HANDLE; | 456 return DID_NOT_HANDLE; |
457 | 457 |
458 gfx::Point scroll_point(gesture_event.x, gesture_event.y); | 458 gfx::Point scroll_point(gesture_event.x, gesture_event.y); |
459 gfx::Vector2dF scroll_delta(-gesture_event.data.scrollUpdate.deltaX, | 459 |
460 -gesture_event.data.scrollUpdate.deltaY); | 460 // TODO(tdresser): The rail information should be pushed down into |
461 // InputHandler. | |
ccameron
2015/04/01 17:20:25
Oh, crap, I didn't do my TODO for this that I'd pr
tdresser
2015/04/01 17:22:45
Sounds good, thanks.
| |
462 const float dx = gesture_event.data.scrollUpdate.deltaX; | |
463 const float dy = gesture_event.data.scrollUpdate.deltaY; | |
464 const WebInputEvent::RailsMode railsMode = | |
465 gesture_event.data.scrollUpdate.railsMode; | |
466 | |
467 gfx::Vector2dF scroll_delta( | |
468 railsMode != WebInputEvent::RailsModeVertical ? -dx : 0, | |
469 railsMode != WebInputEvent::RailsModeHorizontal ? -dy : 0); | |
470 | |
461 cc::InputHandlerScrollResult scroll_result = input_handler_->ScrollBy( | 471 cc::InputHandlerScrollResult scroll_result = input_handler_->ScrollBy( |
462 scroll_point, scroll_delta); | 472 scroll_point, scroll_delta); |
463 HandleOverscroll(scroll_point, scroll_result); | 473 HandleOverscroll(scroll_point, scroll_result); |
464 return scroll_result.did_scroll ? DID_HANDLE : DROP_EVENT; | 474 return scroll_result.did_scroll ? DID_HANDLE : DROP_EVENT; |
465 } | 475 } |
466 | 476 |
467 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollEnd( | 477 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollEnd( |
468 const WebGestureEvent& gesture_event) { | 478 const WebGestureEvent& gesture_event) { |
469 #ifndef NDEBUG | 479 #ifndef NDEBUG |
470 DCHECK(expect_scroll_update_end_); | 480 DCHECK(expect_scroll_update_end_); |
(...skipping 23 matching lines...) Expand all Loading... | |
494 | 504 |
495 #ifndef NDEBUG | 505 #ifndef NDEBUG |
496 expect_scroll_update_end_ = false; | 506 expect_scroll_update_end_ = false; |
497 #endif | 507 #endif |
498 | 508 |
499 switch (scroll_status) { | 509 switch (scroll_status) { |
500 case cc::InputHandler::SCROLL_STARTED: { | 510 case cc::InputHandler::SCROLL_STARTED: { |
501 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) | 511 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) |
502 input_handler_->ScrollEnd(); | 512 input_handler_->ScrollEnd(); |
503 | 513 |
504 const float vx = gesture_event.data.flingStart.velocityX; | 514 // TODO(tdresser): The rail information should be pushed down into |
505 const float vy = gesture_event.data.flingStart.velocityY; | 515 // InputHandler. |
506 current_fling_velocity_ = gfx::Vector2dF(vx, vy); | 516 const WebInputEvent::RailsMode railsMode = |
517 gesture_event.data.flingStart.railsMode; | |
518 | |
519 float vx = railsMode != WebInputEvent::RailsModeVertical | |
520 ? gesture_event.data.flingStart.velocityX | |
521 : 0; | |
522 float vy = railsMode != WebInputEvent::RailsModeHorizontal | |
523 ? gesture_event.data.flingStart.velocityY | |
524 : 0; | |
525 | |
526 current_fling_velocity_.set_x(vx); | |
527 current_fling_velocity_.set_y(vy); | |
528 | |
507 DCHECK(!current_fling_velocity_.IsZero()); | 529 DCHECK(!current_fling_velocity_.IsZero()); |
508 fling_curve_.reset(client_->CreateFlingAnimationCurve( | 530 fling_curve_.reset(client_->CreateFlingAnimationCurve( |
509 gesture_event.sourceDevice, | 531 gesture_event.sourceDevice, |
510 WebFloatPoint(vx, vy), | 532 WebFloatPoint(vx, vy), |
511 blink::WebSize())); | 533 blink::WebSize())); |
512 disallow_horizontal_fling_scroll_ = !vx; | 534 disallow_horizontal_fling_scroll_ = !vx; |
513 disallow_vertical_fling_scroll_ = !vy; | 535 disallow_vertical_fling_scroll_ = !vy; |
514 TRACE_EVENT_ASYNC_BEGIN2("input", | 536 TRACE_EVENT_ASYNC_BEGIN2("input", |
515 "InputHandlerProxy::HandleGestureFling::started", | 537 "InputHandlerProxy::HandleGestureFling::started", |
516 this, | 538 this, |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
951 // trigger a scroll, e.g., with a trivial time delta between fling updates. | 973 // trigger a scroll, e.g., with a trivial time delta between fling updates. |
952 // Return true in this case to prevent early fling termination. | 974 // Return true in this case to prevent early fling termination. |
953 if (std::abs(clipped_increment.width) < kScrollEpsilon && | 975 if (std::abs(clipped_increment.width) < kScrollEpsilon && |
954 std::abs(clipped_increment.height) < kScrollEpsilon) | 976 std::abs(clipped_increment.height) < kScrollEpsilon) |
955 return true; | 977 return true; |
956 | 978 |
957 return did_scroll; | 979 return did_scroll; |
958 } | 980 } |
959 | 981 |
960 } // namespace content | 982 } // namespace content |
OLD | NEW |