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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 gesture_scroll_on_impl_thread_ = false; | 710 gesture_scroll_on_impl_thread_ = false; |
706 current_fling_velocity_ = gfx::Vector2dF(); | 711 current_fling_velocity_ = gfx::Vector2dF(); |
707 fling_parameters_ = blink::WebActiveWheelFlingParameters(); | 712 fling_parameters_ = blink::WebActiveWheelFlingParameters(); |
708 | 713 |
709 if (deferred_fling_cancel_time_seconds_) { | 714 if (deferred_fling_cancel_time_seconds_) { |
710 deferred_fling_cancel_time_seconds_ = 0; | 715 deferred_fling_cancel_time_seconds_ = 0; |
711 | 716 |
712 WebGestureEvent last_fling_boost_event = last_fling_boost_event_; | 717 WebGestureEvent last_fling_boost_event = last_fling_boost_event_; |
713 last_fling_boost_event_ = WebGestureEvent(); | 718 last_fling_boost_event_ = WebGestureEvent(); |
714 if (last_fling_boost_event.type == WebInputEvent::GestureScrollBegin || | 719 if (last_fling_boost_event.type == WebInputEvent::GestureScrollBegin || |
| 720 last_fling_boost_event.type == |
| 721 WebInputEvent::GestureScrollUpdateWithoutPropagation || |
715 last_fling_boost_event.type == WebInputEvent::GestureScrollUpdate) { | 722 last_fling_boost_event.type == WebInputEvent::GestureScrollUpdate) { |
716 // Synthesize a GestureScrollBegin, as the original was suppressed. | 723 // Synthesize a GestureScrollBegin, as the original was suppressed. |
717 HandleInputEvent(ObtainGestureScrollBegin(last_fling_boost_event)); | 724 HandleInputEvent(ObtainGestureScrollBegin(last_fling_boost_event)); |
718 } | 725 } |
719 } | 726 } |
720 | 727 |
721 return had_fling_animation; | 728 return had_fling_animation; |
722 } | 729 } |
723 | 730 |
724 bool InputHandlerProxy::TouchpadFlingScroll( | 731 bool InputHandlerProxy::TouchpadFlingScroll( |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 // trigger a scroll, e.g., with a trivial time delta between fling updates. | 816 // trigger a scroll, e.g., with a trivial time delta between fling updates. |
810 // Return true in this case to prevent early fling termination. | 817 // Return true in this case to prevent early fling termination. |
811 if (std::abs(clipped_increment.width) < kScrollEpsilon && | 818 if (std::abs(clipped_increment.width) < kScrollEpsilon && |
812 std::abs(clipped_increment.height) < kScrollEpsilon) | 819 std::abs(clipped_increment.height) < kScrollEpsilon) |
813 return true; | 820 return true; |
814 | 821 |
815 return did_scroll; | 822 return did_scroll; |
816 } | 823 } |
817 | 824 |
818 } // namespace content | 825 } // namespace content |
OLD | NEW |