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 "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/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 "LatencyInfo.Flow", | 222 "LatencyInfo.Flow", |
| 223 TRACE_ID_DONT_MANGLE(latency_info->trace_id), | 223 TRACE_ID_DONT_MANGLE(latency_info->trace_id), |
| 224 "HandleInputEventImpl"); | 224 "HandleInputEventImpl"); |
| 225 | 225 |
| 226 scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor = | 226 scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor = |
| 227 input_handler_->CreateLatencyInfoSwapPromiseMonitor(latency_info); | 227 input_handler_->CreateLatencyInfoSwapPromiseMonitor(latency_info); |
| 228 InputHandlerProxy::EventDisposition disposition = HandleInputEvent(event); | 228 InputHandlerProxy::EventDisposition disposition = HandleInputEvent(event); |
| 229 return disposition; | 229 return disposition; |
| 230 } | 230 } |
| 231 | 231 |
| 232 blink::WebGestureCurve* InputHandlerProxy::CreateAnimationCurve( | |
| 233 const blink::WebGestureEvent& gesture_event) { | |
| 234 blink::WebGestureCurve* fling_curve; | |
| 235 if (gesture_event.data.flingStart.isSmoothScroll) { | |
| 236 const float start_x = gesture_event.x; | |
| 237 const float start_y = gesture_event.y; | |
| 238 const float dx = gesture_event.data.flingStart.dx; | |
| 239 const float dy = gesture_event.data.flingStart.dy; | |
| 240 const long duration_ms = gesture_event.data.flingStart.durationMs; | |
| 241 fling_curve = client_->CreateSmoothScrollAnimationCurve( | |
| 242 gesture_event.sourceDevice, start_x, start_y, dx, dy, duration_ms); | |
| 243 } else { | |
| 244 const float vx = gesture_event.data.flingStart.velocityX; | |
| 245 const float vy = gesture_event.data.flingStart.velocityY; | |
| 246 fling_curve = client_->CreateFlingAnimationCurve( | |
| 247 gesture_event.sourceDevice, WebFloatPoint(vx, vy), blink::WebSize()); | |
| 248 } | |
| 249 | |
| 250 return fling_curve; | |
| 251 } | |
| 252 | |
| 232 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent( | 253 InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent( |
| 233 const WebInputEvent& event) { | 254 const WebInputEvent& event) { |
| 234 DCHECK(input_handler_); | 255 DCHECK(input_handler_); |
| 235 TRACE_EVENT1("input,benchmark", "InputHandlerProxy::HandleInputEvent", | 256 TRACE_EVENT1("input,benchmark", "InputHandlerProxy::HandleInputEvent", |
| 236 "type", WebInputEventTraits::GetName(event.type)); | 257 "type", WebInputEventTraits::GetName(event.type)); |
| 237 | 258 |
| 238 if (FilterInputEventForFlingBoosting(event)) | 259 if (FilterInputEventForFlingBoosting(event)) |
| 239 return DID_HANDLE; | 260 return DID_HANDLE; |
| 240 | 261 |
| 241 switch (event.type) { | 262 switch (event.type) { |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 | 535 |
| 515 switch (scroll_status) { | 536 switch (scroll_status) { |
| 516 case cc::InputHandler::SCROLL_STARTED: { | 537 case cc::InputHandler::SCROLL_STARTED: { |
| 517 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) | 538 if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) |
| 518 input_handler_->ScrollEnd(); | 539 input_handler_->ScrollEnd(); |
| 519 | 540 |
| 520 const float vx = gesture_event.data.flingStart.velocityX; | 541 const float vx = gesture_event.data.flingStart.velocityX; |
| 521 const float vy = gesture_event.data.flingStart.velocityY; | 542 const float vy = gesture_event.data.flingStart.velocityY; |
| 522 current_fling_velocity_ = gfx::Vector2dF(vx, vy); | 543 current_fling_velocity_ = gfx::Vector2dF(vx, vy); |
| 523 DCHECK(!current_fling_velocity_.IsZero()); | 544 DCHECK(!current_fling_velocity_.IsZero()); |
| 524 fling_curve_.reset(client_->CreateFlingAnimationCurve( | 545 |
| 525 gesture_event.sourceDevice, | 546 fling_curve_.reset(CreateAnimationCurve(gesture_event)); |
| 526 WebFloatPoint(vx, vy), | 547 |
| 527 blink::WebSize())); | |
| 528 disallow_horizontal_fling_scroll_ = !vx; | 548 disallow_horizontal_fling_scroll_ = !vx; |
| 529 disallow_vertical_fling_scroll_ = !vy; | 549 disallow_vertical_fling_scroll_ = !vy; |
| 530 TRACE_EVENT_ASYNC_BEGIN2("input", | 550 TRACE_EVENT_ASYNC_BEGIN2("input", |
| 531 "InputHandlerProxy::HandleGestureFling::started", | 551 "InputHandlerProxy::HandleGestureFling::started", |
| 532 this, | 552 this, |
| 533 "vx", | 553 "vx", |
| 534 vx, | 554 vx, |
| 535 "vy", | 555 "vy", |
| 536 vy); | 556 vy); |
| 537 // Note that the timestamp will only be used to kickstart the animation if | 557 // Note that the timestamp will only be used to kickstart the animation if |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 671 // preventing insertion of a synthetic GestureScrollBegin. | 691 // preventing insertion of a synthetic GestureScrollBegin. |
| 672 last_fling_boost_event_ = WebGestureEvent(); | 692 last_fling_boost_event_ = WebGestureEvent(); |
| 673 CancelCurrentFling(); | 693 CancelCurrentFling(); |
| 674 return true; | 694 return true; |
| 675 | 695 |
| 676 case WebInputEvent::GestureFlingStart: { | 696 case WebInputEvent::GestureFlingStart: { |
| 677 DCHECK_EQ(fling_parameters_.sourceDevice, gesture_event.sourceDevice); | 697 DCHECK_EQ(fling_parameters_.sourceDevice, gesture_event.sourceDevice); |
| 678 | 698 |
| 679 bool fling_boosted = | 699 bool fling_boosted = |
| 680 fling_parameters_.modifiers == gesture_event.modifiers && | 700 fling_parameters_.modifiers == gesture_event.modifiers && |
| 681 ShouldBoostFling(current_fling_velocity_, gesture_event); | 701 ShouldBoostFling(current_fling_velocity_, gesture_event); |
|
jdduke (slow)
2015/07/23 15:32:50
We should make sure smooth scroll flings don't boo
| |
| 682 | 702 |
| 683 gfx::Vector2dF new_fling_velocity( | 703 gfx::Vector2dF new_fling_velocity( |
| 684 gesture_event.data.flingStart.velocityX, | 704 gesture_event.data.flingStart.velocityX, |
| 685 gesture_event.data.flingStart.velocityY); | 705 gesture_event.data.flingStart.velocityY); |
| 686 DCHECK(!new_fling_velocity.IsZero()); | 706 DCHECK(!new_fling_velocity.IsZero()); |
| 687 | 707 |
| 688 if (fling_boosted) | 708 if (fling_boosted) |
| 689 current_fling_velocity_ += new_fling_velocity; | 709 current_fling_velocity_ += new_fling_velocity; |
| 690 else | 710 else |
| 691 current_fling_velocity_ = new_fling_velocity; | 711 current_fling_velocity_ = new_fling_velocity; |
| 692 | 712 |
| 693 WebFloatPoint velocity(current_fling_velocity_.x(), | 713 WebFloatPoint velocity(current_fling_velocity_.x(), |
| 694 current_fling_velocity_.y()); | 714 current_fling_velocity_.y()); |
| 695 deferred_fling_cancel_time_seconds_ = 0; | 715 deferred_fling_cancel_time_seconds_ = 0; |
| 696 disallow_horizontal_fling_scroll_ = !velocity.x; | 716 disallow_horizontal_fling_scroll_ = !velocity.x; |
| 697 disallow_vertical_fling_scroll_ = !velocity.y; | 717 disallow_vertical_fling_scroll_ = !velocity.y; |
| 698 last_fling_boost_event_ = WebGestureEvent(); | 718 last_fling_boost_event_ = WebGestureEvent(); |
| 699 fling_curve_.reset(client_->CreateFlingAnimationCurve( | 719 fling_curve_.reset(CreateAnimationCurve(gesture_event)); |
| 700 gesture_event.sourceDevice, | |
| 701 velocity, | |
| 702 blink::WebSize())); | |
| 703 fling_parameters_.startTime = gesture_event.timeStampSeconds; | 720 fling_parameters_.startTime = gesture_event.timeStampSeconds; |
| 704 fling_parameters_.delta = velocity; | 721 fling_parameters_.delta = velocity; |
| 705 fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y); | 722 fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y); |
| 706 fling_parameters_.globalPoint = | 723 fling_parameters_.globalPoint = |
| 707 WebPoint(gesture_event.globalX, gesture_event.globalY); | 724 WebPoint(gesture_event.globalX, gesture_event.globalY); |
| 708 | 725 |
| 709 TRACE_EVENT_INSTANT2("input", | 726 TRACE_EVENT_INSTANT2("input", |
| 710 fling_boosted ? "InputHandlerProxy::FlingBoosted" | 727 fling_boosted ? "InputHandlerProxy::FlingBoosted" |
| 711 : "InputHandlerProxy::FlingReplaced", | 728 : "InputHandlerProxy::FlingReplaced", |
| 712 TRACE_EVENT_SCOPE_THREAD, | 729 TRACE_EVENT_SCOPE_THREAD, |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 967 // trigger a scroll, e.g., with a trivial time delta between fling updates. | 984 // trigger a scroll, e.g., with a trivial time delta between fling updates. |
| 968 // Return true in this case to prevent early fling termination. | 985 // Return true in this case to prevent early fling termination. |
| 969 if (std::abs(clipped_increment.width) < kScrollEpsilon && | 986 if (std::abs(clipped_increment.width) < kScrollEpsilon && |
| 970 std::abs(clipped_increment.height) < kScrollEpsilon) | 987 std::abs(clipped_increment.height) < kScrollEpsilon) |
| 971 return true; | 988 return true; |
| 972 | 989 |
| 973 return did_scroll; | 990 return did_scroll; |
| 974 } | 991 } |
| 975 | 992 |
| 976 } // namespace content | 993 } // namespace content |
| OLD | NEW |