| 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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 | 60 |
| 61 double InSecondsF(const base::TimeTicks& time) { | 61 double InSecondsF(const base::TimeTicks& time) { |
| 62 return (time - base::TimeTicks()).InSecondsF(); | 62 return (time - base::TimeTicks()).InSecondsF(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 bool ShouldSuppressScrollForFlingBoosting( | 65 bool ShouldSuppressScrollForFlingBoosting( |
| 66 const gfx::Vector2dF& current_fling_velocity, | 66 const gfx::Vector2dF& current_fling_velocity, |
| 67 const WebGestureEvent& scroll_update_event, | 67 const WebGestureEvent& scroll_update_event, |
| 68 double time_since_last_boost_event) { | 68 double time_since_last_boost_event) { |
| 69 DCHECK_EQ(WebInputEvent::GestureScrollUpdate, scroll_update_event.type); | 69 DCHECK(WebInputEvent::GestureScrollUpdate == scroll_update_event.type || |
| 70 WebInputEvent::GestureScrollUpdateWithoutPropagation == |
| 71 scroll_update_event.type); |
| 70 | 72 |
| 71 gfx::Vector2dF dx(scroll_update_event.data.scrollUpdate.deltaX, | 73 gfx::Vector2dF dx(scroll_update_event.data.scrollUpdate.deltaX, |
| 72 scroll_update_event.data.scrollUpdate.deltaY); | 74 scroll_update_event.data.scrollUpdate.deltaY); |
| 73 if (gfx::DotProduct(current_fling_velocity, dx) <= 0) | 75 if (gfx::DotProduct(current_fling_velocity, dx) <= 0) |
| 74 return false; | 76 return false; |
| 75 | 77 |
| 76 if (time_since_last_boost_event < 0.001) | 78 if (time_since_last_boost_event < 0.001) |
| 77 return true; | 79 return true; |
| 78 | 80 |
| 79 // TODO(jdduke): Use |scroll_update_event.data.scrollUpdate.velocity{X,Y}|. | 81 // TODO(jdduke): Use |scroll_update_event.data.scrollUpdate.velocity{X,Y}|. |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 return DID_HANDLE; | 282 return DID_HANDLE; |
| 281 case cc::InputHandler::ScrollUnknown: | 283 case cc::InputHandler::ScrollUnknown: |
| 282 case cc::InputHandler::ScrollOnMainThread: | 284 case cc::InputHandler::ScrollOnMainThread: |
| 283 return DID_NOT_HANDLE; | 285 return DID_NOT_HANDLE; |
| 284 case cc::InputHandler::ScrollIgnored: | 286 case cc::InputHandler::ScrollIgnored: |
| 285 return DROP_EVENT; | 287 return DROP_EVENT; |
| 286 case cc::InputHandler::ScrollStatusCount: | 288 case cc::InputHandler::ScrollStatusCount: |
| 287 NOTREACHED(); | 289 NOTREACHED(); |
| 288 break; | 290 break; |
| 289 } | 291 } |
| 290 } else if (event.type == WebInputEvent::GestureScrollUpdate) { | 292 } else if (event.type == WebInputEvent::GestureScrollUpdate || |
| 293 event.type == |
| 294 WebInputEvent::GestureScrollUpdateWithoutPropagation) { |
| 291 #ifndef NDEBUG | 295 #ifndef NDEBUG |
| 292 DCHECK(expect_scroll_update_end_); | 296 DCHECK(expect_scroll_update_end_); |
| 293 #endif | 297 #endif |
| 294 | 298 |
| 295 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) | 299 if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) |
| 296 return DID_NOT_HANDLE; | 300 return DID_NOT_HANDLE; |
| 297 | 301 |
| 298 const WebGestureEvent& gesture_event = | 302 const WebGestureEvent& gesture_event = |
| 299 *static_cast<const WebGestureEvent*>(&event); | 303 *static_cast<const WebGestureEvent*>(&event); |
| 300 bool did_scroll = input_handler_->ScrollBy( | 304 bool did_scroll = input_handler_->ScrollBy( |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 : cc::InputHandler::Gesture)) { | 507 : cc::InputHandler::Gesture)) { |
| 504 CancelCurrentFling(); | 508 CancelCurrentFling(); |
| 505 return false; | 509 return false; |
| 506 } | 510 } |
| 507 | 511 |
| 508 // TODO(jdduke): Use |gesture_event.data.scrollBegin.delta{X,Y}Hint| to | 512 // TODO(jdduke): Use |gesture_event.data.scrollBegin.delta{X,Y}Hint| to |
| 509 // determine if the ScrollBegin should immediately cancel the fling. | 513 // determine if the ScrollBegin should immediately cancel the fling. |
| 510 ExtendBoostedFlingTimeout(gesture_event); | 514 ExtendBoostedFlingTimeout(gesture_event); |
| 511 return true; | 515 return true; |
| 512 | 516 |
| 517 case WebInputEvent::GestureScrollUpdateWithoutPropagation: |
| 513 case WebInputEvent::GestureScrollUpdate: { | 518 case WebInputEvent::GestureScrollUpdate: { |
| 514 const double time_since_last_boost_event = | 519 const double time_since_last_boost_event = |
| 515 event.timeStampSeconds - last_fling_boost_event_.timeStampSeconds; | 520 event.timeStampSeconds - last_fling_boost_event_.timeStampSeconds; |
| 516 if (ShouldSuppressScrollForFlingBoosting(current_fling_velocity_, | 521 if (ShouldSuppressScrollForFlingBoosting(current_fling_velocity_, |
| 517 gesture_event, | 522 gesture_event, |
| 518 time_since_last_boost_event)) { | 523 time_since_last_boost_event)) { |
| 519 ExtendBoostedFlingTimeout(gesture_event); | 524 ExtendBoostedFlingTimeout(gesture_event); |
| 520 return true; | 525 return true; |
| 521 } | 526 } |
| 522 | 527 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 gesture_scroll_on_impl_thread_ = false; | 712 gesture_scroll_on_impl_thread_ = false; |
| 708 current_fling_velocity_ = gfx::Vector2dF(); | 713 current_fling_velocity_ = gfx::Vector2dF(); |
| 709 fling_parameters_ = blink::WebActiveWheelFlingParameters(); | 714 fling_parameters_ = blink::WebActiveWheelFlingParameters(); |
| 710 | 715 |
| 711 if (deferred_fling_cancel_time_seconds_) { | 716 if (deferred_fling_cancel_time_seconds_) { |
| 712 deferred_fling_cancel_time_seconds_ = 0; | 717 deferred_fling_cancel_time_seconds_ = 0; |
| 713 | 718 |
| 714 WebGestureEvent last_fling_boost_event = last_fling_boost_event_; | 719 WebGestureEvent last_fling_boost_event = last_fling_boost_event_; |
| 715 last_fling_boost_event_ = WebGestureEvent(); | 720 last_fling_boost_event_ = WebGestureEvent(); |
| 716 if (last_fling_boost_event.type == WebInputEvent::GestureScrollBegin || | 721 if (last_fling_boost_event.type == WebInputEvent::GestureScrollBegin || |
| 722 last_fling_boost_event.type == |
| 723 WebInputEvent::GestureScrollUpdateWithoutPropagation || |
| 717 last_fling_boost_event.type == WebInputEvent::GestureScrollUpdate) { | 724 last_fling_boost_event.type == WebInputEvent::GestureScrollUpdate) { |
| 718 // Synthesize a GestureScrollBegin, as the original was suppressed. | 725 // Synthesize a GestureScrollBegin, as the original was suppressed. |
| 719 HandleInputEvent(ObtainGestureScrollBegin(last_fling_boost_event)); | 726 HandleInputEvent(ObtainGestureScrollBegin(last_fling_boost_event)); |
| 720 } | 727 } |
| 721 } | 728 } |
| 722 | 729 |
| 723 return had_fling_animation; | 730 return had_fling_animation; |
| 724 } | 731 } |
| 725 | 732 |
| 726 bool InputHandlerProxy::TouchpadFlingScroll( | 733 bool InputHandlerProxy::TouchpadFlingScroll( |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 // trigger a scroll, e.g., with a trivial time delta between fling updates. | 818 // trigger a scroll, e.g., with a trivial time delta between fling updates. |
| 812 // Return true in this case to prevent early fling termination. | 819 // Return true in this case to prevent early fling termination. |
| 813 if (std::abs(clipped_increment.width) < kScrollEpsilon && | 820 if (std::abs(clipped_increment.width) < kScrollEpsilon && |
| 814 std::abs(clipped_increment.height) < kScrollEpsilon) | 821 std::abs(clipped_increment.height) < kScrollEpsilon) |
| 815 return true; | 822 return true; |
| 816 | 823 |
| 817 return did_scroll; | 824 return did_scroll; |
| 818 } | 825 } |
| 819 | 826 |
| 820 } // namespace content | 827 } // namespace content |
| OLD | NEW |