| Index: content/renderer/input/input_scroll_elasticity_controller.cc
|
| diff --git a/content/renderer/input/input_scroll_elasticity_controller.cc b/content/renderer/input/input_scroll_elasticity_controller.cc
|
| index 059bc9d51270ef2ea31dcb07ad392d45768ea143..cd5ab1c2089003259c8475371f761501c81b1e56 100644
|
| --- a/content/renderer/input/input_scroll_elasticity_controller.cc
|
| +++ b/content/renderer/input/input_scroll_elasticity_controller.cc
|
| @@ -6,8 +6,8 @@
|
|
|
| #include <math.h>
|
|
|
| -// ScrollElasticityController and ScrollElasticityControllerClient are based on
|
| -// WebKit/Source/platform/mac/ScrollElasticityController.mm
|
| +// InputScrollElasticityController is based on
|
| +// WebKit/Source/platform/mac/InputScrollElasticityController.mm
|
| /*
|
| * Copyright (C) 2011 Apple Inc. All rights reserved.
|
| *
|
| @@ -88,18 +88,53 @@ float ScrollWheelMultiplier() {
|
|
|
| } // namespace
|
|
|
| -ScrollElasticityController::ScrollElasticityController(
|
| - ScrollElasticityControllerClient* client)
|
| +InputScrollElasticityController::InputScrollElasticityController(
|
| + cc::ScrollElasticityControllerClient* client)
|
| : client_(client),
|
| in_scroll_gesture_(false),
|
| has_scrolled_(false),
|
| momentum_scroll_in_progress_(false),
|
| ignore_momentum_scrolls_(false),
|
| last_momentum_scroll_timestamp_(0),
|
| - snap_rubberband_timer_is_active_(false) {
|
| + snap_rubberband_timer_is_active_(false),
|
| + weak_factory_(this) {
|
| }
|
|
|
| -bool ScrollElasticityController::HandleWheelEvent(
|
| +InputScrollElasticityController::~InputScrollElasticityController() {
|
| + DCHECK(!client_);
|
| +}
|
| +
|
| +base::WeakPtr<InputScrollElasticityController>
|
| +InputScrollElasticityController::GetWeakPtr() {
|
| + if (client_)
|
| + return weak_factory_.GetWeakPtr();
|
| + return base::WeakPtr<InputScrollElasticityController>();
|
| +}
|
| +
|
| +void InputScrollElasticityController::WillShutdown() {
|
| + weak_factory_.InvalidateWeakPtrs();
|
| + client_ = NULL;
|
| +}
|
| +
|
| +void InputScrollElasticityController::Animate(base::TimeTicks time) {
|
| + if (!snap_rubberband_timer_is_active_)
|
| + return;
|
| +
|
| + // TODO(ccameron): This should send the time parameter to the snap function,
|
| + // so that animation can be based on frame time, not arbitrarily-sampled
|
| + // clock time.
|
| + SnapRubberbandTimerFired();
|
| +}
|
| +
|
| +void InputScrollElasticityController::ObserveWheelEventAndResult(
|
| + const blink::WebMouseWheelEvent& wheel_event,
|
| + const cc::InputHandlerScrollResult& scroll_result) {
|
| + // TODO(ccameron): Pull non-over-scrolling scroll logic out of
|
| + // HandleWheelEvent, and read the scroll result instead.
|
| + HandleWheelEvent(wheel_event);
|
| +}
|
| +
|
| +bool InputScrollElasticityController::HandleWheelEvent(
|
| const blink::WebMouseWheelEvent& wheel_event) {
|
| if (wheel_event.phase == blink::WebMouseWheelEvent::PhaseMayBegin)
|
| return false;
|
| @@ -335,7 +370,7 @@ float RoundToDevicePixelTowardZero(float num) {
|
|
|
| } // namespace
|
|
|
| -void ScrollElasticityController::SnapRubberbandTimerFired() {
|
| +void InputScrollElasticityController::SnapRubberbandTimerFired() {
|
| if (!momentum_scroll_in_progress_ || ignore_momentum_scrolls_) {
|
| float time_delta = (base::Time::Now() - start_time_).InSecondsF();
|
|
|
| @@ -399,7 +434,7 @@ void ScrollElasticityController::SnapRubberbandTimerFired() {
|
| }
|
| }
|
|
|
| -bool ScrollElasticityController::IsRubberbandInProgress() const {
|
| +bool InputScrollElasticityController::IsRubberbandInProgress() const {
|
| if (!in_scroll_gesture_ && !momentum_scroll_in_progress_ &&
|
| !snap_rubberband_timer_is_active_)
|
| return false;
|
| @@ -407,12 +442,12 @@ bool ScrollElasticityController::IsRubberbandInProgress() const {
|
| return !client_->StretchAmount().IsZero();
|
| }
|
|
|
| -void ScrollElasticityController::StopSnapRubberbandTimer() {
|
| +void InputScrollElasticityController::StopSnapRubberbandTimer() {
|
| client_->StopSnapRubberbandTimer();
|
| snap_rubberband_timer_is_active_ = false;
|
| }
|
|
|
| -void ScrollElasticityController::SnapRubberband() {
|
| +void InputScrollElasticityController::SnapRubberband() {
|
| double time_delta = SystemUptime() - last_momentum_scroll_timestamp_;
|
| if (last_momentum_scroll_timestamp_ &&
|
| time_delta >= kScrollVelocityZeroingTimeout)
|
| @@ -441,7 +476,7 @@ void ScrollElasticityController::SnapRubberband() {
|
| snap_rubberband_timer_is_active_ = true;
|
| }
|
|
|
| -bool ScrollElasticityController::ShouldHandleEvent(
|
| +bool InputScrollElasticityController::ShouldHandleEvent(
|
| const blink::WebMouseWheelEvent& wheel_event) {
|
| // Once any scrolling has happened, all future events should be handled.
|
| if (has_scrolled_)
|
|
|