| 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 "cc/animation/scroll_offset_animation_curve.h" | 5 #include "cc/animation/scroll_offset_animation_curve.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 #include <cmath> | 8 #include <cmath> | 
| 9 | 9 | 
| 10 #include "base/logging.h" | 10 #include "base/logging.h" | 
| 11 #include "cc/animation/timing_function.h" | 11 #include "cc/animation/timing_function.h" | 
| 12 #include "cc/base/time_util.h" | 12 #include "cc/base/time_util.h" | 
| 13 #include "ui/gfx/animation/tween.h" | 13 #include "ui/gfx/animation/tween.h" | 
| 14 | 14 | 
| 15 const double kDurationDivisor = 60.0; | 15 const double kDurationDivisor = 60.0; | 
| 16 | 16 | 
| 17 namespace cc { | 17 namespace cc { | 
| 18 | 18 | 
| 19 namespace { | 19 namespace { | 
| 20 | 20 | 
| 21 static float MaximumDimension(gfx::Vector2dF delta) { | 21 static float MaximumDimension(const gfx::Vector2dF& delta) { | 
| 22   return std::max(std::abs(delta.x()), std::abs(delta.y())); | 22   return std::max(std::abs(delta.x()), std::abs(delta.y())); | 
| 23 } | 23 } | 
| 24 | 24 | 
| 25 static base::TimeDelta DurationFromDelta(gfx::Vector2dF delta) { | 25 static base::TimeDelta DurationFromDelta(const gfx::Vector2dF& delta) { | 
| 26   // The duration of a scroll animation depends on the size of the scroll. | 26   // The duration of a scroll animation depends on the size of the scroll. | 
| 27   // The exact relationship between the size and the duration isn't specified | 27   // The exact relationship between the size and the duration isn't specified | 
| 28   // by the CSSOM View smooth scroll spec and is instead left up to user agents | 28   // by the CSSOM View smooth scroll spec and is instead left up to user agents | 
| 29   // to decide. The calculation performed here will very likely be further | 29   // to decide. The calculation performed here will very likely be further | 
| 30   // tweaked before the smooth scroll API ships. | 30   // tweaked before the smooth scroll API ships. | 
| 31   return base::TimeDelta::FromMicroseconds( | 31   return base::TimeDelta::FromMicroseconds( | 
| 32       (std::sqrt(MaximumDimension(delta)) / kDurationDivisor) * | 32       (std::sqrt(MaximumDimension(delta)) / kDurationDivisor) * | 
| 33       base::Time::kMicrosecondsPerSecond); | 33       base::Time::kMicrosecondsPerSecond); | 
| 34 } | 34 } | 
| 35 | 35 | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 127       (MaximumDimension(old_delta) / MaximumDimension(new_delta)); | 127       (MaximumDimension(old_delta) / MaximumDimension(new_delta)); | 
| 128 | 128 | 
| 129   initial_value_ = current_position; | 129   initial_value_ = current_position; | 
| 130   target_value_ = new_target; | 130   target_value_ = new_target; | 
| 131   total_animation_duration_ = base::TimeDelta::FromSecondsD(t + new_duration); | 131   total_animation_duration_ = base::TimeDelta::FromSecondsD(t + new_duration); | 
| 132   last_retarget_ = base::TimeDelta::FromSecondsD(t); | 132   last_retarget_ = base::TimeDelta::FromSecondsD(t); | 
| 133   timing_function_ = EaseOutWithInitialVelocity(new_velocity); | 133   timing_function_ = EaseOutWithInitialVelocity(new_velocity); | 
| 134 } | 134 } | 
| 135 | 135 | 
| 136 }  // namespace cc | 136 }  // namespace cc | 
| OLD | NEW | 
|---|