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

Side by Side Diff: Source/core/animation/AnimationNodeTiming.cpp

Issue 929273002: Use IDL union for Timing.duration (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months 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 | « Source/core/animation/AnimationNodeTiming.h ('k') | Source/core/animation/AnimationTest.cpp » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "core/animation/AnimationNodeTiming.h" 6 #include "core/animation/AnimationNodeTiming.h"
7 7
8 #include "bindings/core/v8/UnionTypesCore.h" 8 #include "bindings/core/v8/UnionTypesCore.h"
9 #include "core/animation/Animation.h" 9 #include "core/animation/Animation.h"
10 #include "core/animation/AnimationNode.h" 10 #include "core/animation/AnimationNode.h"
(...skipping 29 matching lines...) Expand all
40 double AnimationNodeTiming::iterationStart() 40 double AnimationNodeTiming::iterationStart()
41 { 41 {
42 return m_parent->specifiedTiming().iterationStart; 42 return m_parent->specifiedTiming().iterationStart;
43 } 43 }
44 44
45 double AnimationNodeTiming::iterations() 45 double AnimationNodeTiming::iterations()
46 { 46 {
47 return m_parent->specifiedTiming().iterationCount; 47 return m_parent->specifiedTiming().iterationCount;
48 } 48 }
49 49
50 // This logic was copied from the example in bindings/tests/idls/TestInterface.i dl 50 void AnimationNodeTiming::duration(DoubleOrString& returnValue)
51 // and bindings/tests/results/V8TestInterface.cpp.
52 // FIXME: It might be possible to have 'duration' defined as an attribute in the idl.
53 // If possible, fix will be in a follow-up patch.
54 // http://crbug.com/240176
55 void AnimationNodeTiming::getDuration(String propertyName, DoubleOrString& retur nValue)
56 { 51 {
57 if (propertyName != "duration") 52 if (std::isnan(m_parent->specifiedTiming().iterationDuration))
58 return;
59
60 if (std::isnan(m_parent->specifiedTiming().iterationDuration)) {
61 returnValue.setString("auto"); 53 returnValue.setString("auto");
62 return; 54 else
63 } 55 returnValue.setDouble(m_parent->specifiedTiming().iterationDuration * 10 00);
64 returnValue.setDouble(m_parent->specifiedTiming().iterationDuration * 1000);
65 return;
66 } 56 }
67 57
68 double AnimationNodeTiming::playbackRate() 58 double AnimationNodeTiming::playbackRate()
69 { 59 {
70 return m_parent->specifiedTiming().playbackRate; 60 return m_parent->specifiedTiming().playbackRate;
71 } 61 }
72 62
73 String AnimationNodeTiming::direction() 63 String AnimationNodeTiming::direction()
74 { 64 {
75 return Timing::playbackDirectionString(m_parent->specifiedTiming().direction ); 65 return Timing::playbackDirectionString(m_parent->specifiedTiming().direction );
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 m_parent->updateSpecifiedTiming(timing); 98 m_parent->updateSpecifiedTiming(timing);
109 } 99 }
110 100
111 void AnimationNodeTiming::setIterations(double iterations) 101 void AnimationNodeTiming::setIterations(double iterations)
112 { 102 {
113 Timing timing = m_parent->specifiedTiming(); 103 Timing timing = m_parent->specifiedTiming();
114 TimingInput::setIterationCount(timing, iterations); 104 TimingInput::setIterationCount(timing, iterations);
115 m_parent->updateSpecifiedTiming(timing); 105 m_parent->updateSpecifiedTiming(timing);
116 } 106 }
117 107
118 bool AnimationNodeTiming::setDuration(String name, double duration) 108 void AnimationNodeTiming::setDuration(const DoubleOrString& durationOrAuto)
119 { 109 {
120 if (name != "duration") 110 // Any strings other than "auto" are coerced to "auto".
121 return false; 111 double duration = durationOrAuto.isString() ? std::numeric_limits<double>::q uiet_NaN() : durationOrAuto.getAsDouble();
122 Timing timing = m_parent->specifiedTiming(); 112 Timing timing = m_parent->specifiedTiming();
123 TimingInput::setIterationDuration(timing, duration); 113 TimingInput::setIterationDuration(timing, duration);
124 m_parent->updateSpecifiedTiming(timing); 114 m_parent->updateSpecifiedTiming(timing);
125 return true;
126 } 115 }
127 116
128 void AnimationNodeTiming::setPlaybackRate(double playbackRate) 117 void AnimationNodeTiming::setPlaybackRate(double playbackRate)
129 { 118 {
130 Timing timing = m_parent->specifiedTiming(); 119 Timing timing = m_parent->specifiedTiming();
131 TimingInput::setPlaybackRate(timing, playbackRate); 120 TimingInput::setPlaybackRate(timing, playbackRate);
132 m_parent->updateSpecifiedTiming(timing); 121 m_parent->updateSpecifiedTiming(timing);
133 } 122 }
134 123
135 void AnimationNodeTiming::setDirection(String direction) 124 void AnimationNodeTiming::setDirection(String direction)
136 { 125 {
137 Timing timing = m_parent->specifiedTiming(); 126 Timing timing = m_parent->specifiedTiming();
138 TimingInput::setPlaybackDirection(timing, direction); 127 TimingInput::setPlaybackDirection(timing, direction);
139 m_parent->updateSpecifiedTiming(timing); 128 m_parent->updateSpecifiedTiming(timing);
140 } 129 }
141 130
142 void AnimationNodeTiming::setEasing(String easing) 131 void AnimationNodeTiming::setEasing(String easing)
143 { 132 {
144 Timing timing = m_parent->specifiedTiming(); 133 Timing timing = m_parent->specifiedTiming();
145 TimingInput::setTimingFunction(timing, easing); 134 TimingInput::setTimingFunction(timing, easing);
146 m_parent->updateSpecifiedTiming(timing); 135 m_parent->updateSpecifiedTiming(timing);
147 } 136 }
148 137
149 void AnimationNodeTiming::trace(Visitor* visitor) 138 void AnimationNodeTiming::trace(Visitor* visitor)
150 { 139 {
151 visitor->trace(m_parent); 140 visitor->trace(m_parent);
152 } 141 }
153 142
154 } // namespace blink 143 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/animation/AnimationNodeTiming.h ('k') | Source/core/animation/AnimationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698