Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: ui/base/animation/multi_animation.cc

Issue 11312029: Revert 165230 - Merge 164399 - Make MultiAnimation take time param and slow down tab highlight (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1271/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/animation/multi_animation.h ('k') | ui/base/animation/multi_animation_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/base/animation/multi_animation.h" 5 #include "ui/base/animation/multi_animation.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/base/animation/animation_delegate.h" 8 #include "ui/base/animation/animation_delegate.h"
9 9
10 namespace ui { 10 namespace ui {
11 11
12 // Default interval, in ms. 12 // Default interval, in ms.
13 static const int kDefaultTimerInterval = 20; 13 static const int kDefaultInterval = 20;
14 14
15 static int TotalTime(const MultiAnimation::Parts& parts) { 15 static int TotalTime(const MultiAnimation::Parts& parts) {
16 int time_ms = 0; 16 int time_ms = 0;
17 for (size_t i = 0; i < parts.size(); ++i) { 17 for (size_t i = 0; i < parts.size(); ++i) {
18 DCHECK(parts[i].end_time_ms - parts[i].start_time_ms >= parts[i].time_ms); 18 DCHECK(parts[i].end_time_ms - parts[i].start_time_ms >= parts[i].time_ms);
19 time_ms += parts[i].time_ms; 19 time_ms += parts[i].time_ms;
20 } 20 }
21 return time_ms; 21 return time_ms;
22 } 22 }
23 23
24 MultiAnimation::MultiAnimation(const Parts& parts, 24 MultiAnimation::MultiAnimation(const Parts& parts)
25 base::TimeDelta timer_interval) 25 : Animation(base::TimeDelta::FromMilliseconds(kDefaultInterval)),
26 : Animation(timer_interval),
27 parts_(parts), 26 parts_(parts),
28 cycle_time_ms_(TotalTime(parts)), 27 cycle_time_ms_(TotalTime(parts)),
29 current_value_(0), 28 current_value_(0),
30 current_part_index_(0), 29 current_part_index_(0),
31 continuous_(true) { 30 continuous_(true) {
32 DCHECK(!parts_.empty()); 31 DCHECK(!parts_.empty());
33 } 32 }
34 33
35 MultiAnimation::~MultiAnimation() {} 34 MultiAnimation::~MultiAnimation() {}
36 35
37 // static.
38 base::TimeDelta MultiAnimation::GetDefaultTimerInterval() {
39 return base::TimeDelta::FromMilliseconds(kDefaultTimerInterval);
40 }
41
42 double MultiAnimation::GetCurrentValue() const { 36 double MultiAnimation::GetCurrentValue() const {
43 return current_value_; 37 return current_value_;
44 } 38 }
45 39
46 void MultiAnimation::Step(base::TimeTicks time_now) { 40 void MultiAnimation::Step(base::TimeTicks time_now) {
47 double last_value = current_value_; 41 double last_value = current_value_;
48 size_t last_index = current_part_index_; 42 size_t last_index = current_part_index_;
49 43
50 int delta = static_cast<int>((time_now - start_time()).InMilliseconds()); 44 int delta = static_cast<int>((time_now - start_time()).InMilliseconds());
51 if (delta >= cycle_time_ms_ && !continuous_) { 45 if (delta >= cycle_time_ms_ && !continuous_) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 79
86 *time_ms -= parts_[i].time_ms; 80 *time_ms -= parts_[i].time_ms;
87 } 81 }
88 NOTREACHED(); 82 NOTREACHED();
89 *time_ms = 0; 83 *time_ms = 0;
90 *part_index = 0; 84 *part_index = 0;
91 return parts_[0]; 85 return parts_[0];
92 } 86 }
93 87
94 } // namespace ui 88 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/animation/multi_animation.h ('k') | ui/base/animation/multi_animation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698