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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "content/renderer/input/input_handler_proxy_client.h" | 10 #include "content/renderer/input/input_handler_proxy_client.h" |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 } else { | 345 } else { |
346 TRACE_EVENT_INSTANT0("renderer", | 346 TRACE_EVENT_INSTANT0("renderer", |
347 "InputHandlerProxy::animate::flingOver", | 347 "InputHandlerProxy::animate::flingOver", |
348 TRACE_EVENT_SCOPE_THREAD); | 348 TRACE_EVENT_SCOPE_THREAD); |
349 CancelCurrentFling(); | 349 CancelCurrentFling(); |
350 } | 350 } |
351 } | 351 } |
352 | 352 |
353 void InputHandlerProxy::MainThreadHasStoppedFlinging() { | 353 void InputHandlerProxy::MainThreadHasStoppedFlinging() { |
354 fling_may_be_active_on_main_thread_ = false; | 354 fling_may_be_active_on_main_thread_ = false; |
355 client_->DidStopFlinging(); | |
355 } | 356 } |
356 | 357 |
357 void InputHandlerProxy::DidOverscroll(const cc::DidOverscrollParams& params) { | 358 void InputHandlerProxy::DidOverscroll(const cc::DidOverscrollParams& params) { |
358 DCHECK(client_); | 359 DCHECK(client_); |
359 if (fling_curve_) { | 360 if (fling_curve_) { |
360 static const int kFlingOverscrollThreshold = 1; | 361 static const int kFlingOverscrollThreshold = 1; |
361 disallow_horizontal_fling_scroll_ |= | 362 disallow_horizontal_fling_scroll_ |= |
362 std::abs(params.accumulated_overscroll.x()) >= | 363 std::abs(params.accumulated_overscroll.x()) >= |
363 kFlingOverscrollThreshold; | 364 kFlingOverscrollThreshold; |
364 disallow_vertical_fling_scroll_ |= | 365 disallow_vertical_fling_scroll_ |= |
(...skipping 16 matching lines...) Expand all Loading... | |
381 } | 382 } |
382 | 383 |
383 TRACE_EVENT_INSTANT1("renderer", | 384 TRACE_EVENT_INSTANT1("renderer", |
384 "InputHandlerProxy::CancelCurrentFling", | 385 "InputHandlerProxy::CancelCurrentFling", |
385 TRACE_EVENT_SCOPE_THREAD, | 386 TRACE_EVENT_SCOPE_THREAD, |
386 "had_fling_animation", | 387 "had_fling_animation", |
387 had_fling_animation); | 388 had_fling_animation); |
388 fling_curve_.reset(); | 389 fling_curve_.reset(); |
389 gesture_scroll_on_impl_thread_ = false; | 390 gesture_scroll_on_impl_thread_ = false; |
390 fling_parameters_ = blink::WebActiveWheelFlingParameters(); | 391 fling_parameters_ = blink::WebActiveWheelFlingParameters(); |
392 if (had_fling_animation) | |
393 client_->DidStopFlinging(); | |
391 return had_fling_animation; | 394 return had_fling_animation; |
392 } | 395 } |
393 | 396 |
394 bool InputHandlerProxy::TouchpadFlingScroll( | 397 bool InputHandlerProxy::TouchpadFlingScroll( |
395 const WebFloatSize& increment) { | 398 const WebFloatSize& increment) { |
396 WebMouseWheelEvent synthetic_wheel; | 399 WebMouseWheelEvent synthetic_wheel; |
397 synthetic_wheel.type = WebInputEvent::MouseWheel; | 400 synthetic_wheel.type = WebInputEvent::MouseWheel; |
398 synthetic_wheel.deltaX = increment.width; | 401 synthetic_wheel.deltaX = increment.width; |
399 synthetic_wheel.deltaY = increment.height; | 402 synthetic_wheel.deltaY = increment.height; |
400 synthetic_wheel.hasPreciseScrollingDeltas = true; | 403 synthetic_wheel.hasPreciseScrollingDeltas = true; |
(...skipping 14 matching lines...) Expand all Loading... | |
415 TRACE_EVENT_INSTANT0("renderer", | 418 TRACE_EVENT_INSTANT0("renderer", |
416 "InputHandlerProxy::scrollBy::AbortFling", | 419 "InputHandlerProxy::scrollBy::AbortFling", |
417 TRACE_EVENT_SCOPE_THREAD); | 420 TRACE_EVENT_SCOPE_THREAD); |
418 // If we got a DID_NOT_HANDLE, that means we need to deliver wheels on the | 421 // If we got a DID_NOT_HANDLE, that means we need to deliver wheels on the |
419 // main thread. In this case we need to schedule a commit and transfer the | 422 // main thread. In this case we need to schedule a commit and transfer the |
420 // fling curve over to the main thread and run the rest of the wheels from | 423 // fling curve over to the main thread and run the rest of the wheels from |
421 // there. This can happen when flinging a page that contains a scrollable | 424 // there. This can happen when flinging a page that contains a scrollable |
422 // subarea that we can't scroll on the thread if the fling starts outside | 425 // subarea that we can't scroll on the thread if the fling starts outside |
423 // the subarea but then is flung "under" the pointer. | 426 // the subarea but then is flung "under" the pointer. |
424 client_->TransferActiveWheelFlingAnimation(fling_parameters_); | 427 client_->TransferActiveWheelFlingAnimation(fling_parameters_); |
425 fling_may_be_active_on_main_thread_ = true; | 428 fling_may_be_active_on_main_thread_ = true; |
jdduke (slow)
2014/01/10 23:00:03
Hmm, I think we need to be careful here. This wil
jdduke (slow)
2014/01/10 23:03:58
If you do go that route, please put a comment expl
Xianzhu
2014/01/10 23:30:45
Thanks for the nice finding!
However, this makes
| |
426 CancelCurrentFling(); | 429 CancelCurrentFling(); |
427 break; | 430 break; |
428 } | 431 } |
429 | 432 |
430 return false; | 433 return false; |
431 } | 434 } |
432 | 435 |
433 static gfx::Vector2dF ToClientScrollIncrement(const WebFloatSize& increment) { | 436 static gfx::Vector2dF ToClientScrollIncrement(const WebFloatSize& increment) { |
434 return gfx::Vector2dF(-increment.width, -increment.height); | 437 return gfx::Vector2dF(-increment.width, -increment.height); |
435 } | 438 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
475 TRACE_EVENT2("renderer", | 478 TRACE_EVENT2("renderer", |
476 "InputHandlerProxy::notifyCurrentFlingVelocity", | 479 "InputHandlerProxy::notifyCurrentFlingVelocity", |
477 "vx", | 480 "vx", |
478 velocity.width, | 481 velocity.width, |
479 "vy", | 482 "vy", |
480 velocity.height); | 483 velocity.height); |
481 input_handler_->NotifyCurrentFlingVelocity(ToClientScrollIncrement(velocity)); | 484 input_handler_->NotifyCurrentFlingVelocity(ToClientScrollIncrement(velocity)); |
482 } | 485 } |
483 | 486 |
484 } // namespace content | 487 } // namespace content |
OLD | NEW |