| Index: ui/events/android/scroller.cc
|
| diff --git a/ui/events/android/scroller.cc b/ui/events/android/scroller.cc
|
| index 1375f3f02f520de6267abd84ffdebed26422d939..bb82624b2206b2a484a6bc5928e03c0f6671c071 100644
|
| --- a/ui/events/android/scroller.cc
|
| +++ b/ui/events/android/scroller.cc
|
| @@ -208,6 +208,25 @@ bool Scroller::ComputeScrollOffset(base::TimeTicks time,
|
| return true;
|
| }
|
|
|
| +void Scroller::ComputeTotalScrollOffset(gfx::Vector2dF& offset) {
|
| + offset.set_x(final_x_);
|
| + offset.set_y(final_y_);
|
| +}
|
| +
|
| +bool Scroller::ResetCurveBySnappedOffset(const gfx::Vector2dF& offset) {
|
| + final_x_ = offset.x();
|
| + final_y_ = offset.y();
|
| + distance_ = std::sqrt(final_x_ * final_x_ + final_y_ * final_y_);
|
| +
|
| + velocity_ = GetSplineVelocityFromDistance(distance_);
|
| + duration_ = GetSplineFlingDuration(velocity_);
|
| + if (duration_.ToInternalValue() <= 0)
|
| + return false;
|
| + duration_seconds_reciprocal_ = 1.0 / duration_.InSecondsF();
|
| + RecomputeDeltas();
|
| + return true;
|
| +}
|
| +
|
| void Scroller::StartScroll(float start_x,
|
| float start_y,
|
| float dx,
|
| @@ -294,6 +313,8 @@ void Scroller::Fling(float start_x,
|
| final_y_ = start_y + total_distance * coeff_y;
|
| final_y_ = Clamped(final_y_, min_y_, max_y_);
|
|
|
| + // LOG(ERROR) << final_x_ << ".." << final_y_;
|
| +
|
| RecomputeDeltas();
|
| }
|
|
|
| @@ -474,4 +495,16 @@ double Scroller::GetSplineFlingDistance(float velocity) const {
|
| std::exp(kDecelerationRate / decel_minus_one * l);
|
| }
|
|
|
| +double Scroller::GetSplineVelocityFromDeceleration(float deceleration) const {
|
| + return std::exp(deceleration) * (fling_friction_ * tuning_coeff_) /
|
| + kInflexion;
|
| +}
|
| +
|
| +double Scroller::GetSplineVelocityFromDistance(float distance) const {
|
| + double decel_minus_one = kDecelerationRate - 1.0;
|
| + double deceleration = std::log(distance / (fling_friction_ * tuning_coeff_)) /
|
| + (kDecelerationRate / decel_minus_one);
|
| + return GetSplineVelocityFromDeceleration(deceleration);
|
| +}
|
| +
|
| } // namespace ui
|
|
|