Chromium Code Reviews| Index: chrome/browser/ui/autofill/loading_animation.cc |
| diff --git a/chrome/browser/ui/autofill/loading_animation.cc b/chrome/browser/ui/autofill/loading_animation.cc |
| index 800ff3de8240b80c74c0aa492435724ead5a5c78..f11109adb58d75797169ff52101e8d668333c7a2 100644 |
| --- a/chrome/browser/ui/autofill/loading_animation.cc |
| +++ b/chrome/browser/ui/autofill/loading_animation.cc |
| @@ -30,7 +30,7 @@ void LoadingAnimation::Step(base::TimeTicks time_now) { |
| } |
| } |
| -double LoadingAnimation::GetCurrentValueForDot(size_t dot_i) { |
| +double LoadingAnimation::GetCurrentValueForDot(size_t dot_i) const { |
| double base_value = gfx::LinearAnimation::GetCurrentValue(); |
| const double kSecondDotDelayMs = 100.0; |
| @@ -45,7 +45,7 @@ double LoadingAnimation::GetCurrentValueForDot(size_t dot_i) { |
| double value = gfx::Tween::CalculateValue(gfx::Tween::EASE_OUT, base_value); |
| - static AnimationFrame animation_frames[] = { |
| + static AnimationFrame kAnimationFrames[] = { |
| { 0.0, 0.0 }, |
| { 0.55, 0.0 }, |
| { 0.6, -1.0 }, |
| @@ -54,17 +54,24 @@ double LoadingAnimation::GetCurrentValueForDot(size_t dot_i) { |
| { 0.95, 0.1 }, |
| { 1.0, 0.0 }, |
| }; |
| + static double kScale = 10.0; |
|
Evan Stade
2013/11/15 21:58:46
nit: I don't really see the benefit in doing this
groby-ooo-7-16
2013/11/15 23:03:38
+1 on the ctor doing htis.
Ilya Sherman
2013/11/16 00:31:13
Done.
|
| - for (size_t i = 0; i < arraysize(animation_frames); ++i) { |
| - if (value > animation_frames[i].value) |
| + for (size_t i = 0; i < arraysize(kAnimationFrames); ++i) { |
| + if (value > kAnimationFrames[i].value) |
| continue; |
| - else if (i == 0) |
| - return animation_frames[i].position; |
| - return animation_frames[i - 1].position + |
| - (animation_frames[i].position - animation_frames[i - 1].position) * |
| - (value - animation_frames[i - 1].value) / |
| - (animation_frames[i].value - animation_frames[i - 1].value); |
| + double position; |
| + if (i == 0) { |
| + position = kAnimationFrames[i].position; |
| + } else { |
| + double distance = |
|
Evan Stade
2013/11/15 21:58:46
nit: IMO, the distance and progress variable names
Ilya Sherman
2013/11/16 00:31:13
Done.
|
| + kAnimationFrames[i].position - kAnimationFrames[i - 1].position; |
| + double progress = |
| + (value - kAnimationFrames[i - 1].value) / |
| + (kAnimationFrames[i].value - kAnimationFrames[i - 1].value); |
| + position = kAnimationFrames[i - 1].position + distance * progress; |
|
groby-ooo-7-16
2013/11/15 23:03:38
I kind of like clearing up the computation, becaus
Ilya Sherman
2013/11/16 00:31:13
Done. Good call on using Tween::FloatValueBetween
|
| + } |
| + return position * kScale; |
| } |
| NOTREACHED(); |