OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |