OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 return nullptr; | 95 return nullptr; |
96 | 96 |
97 return createUnsafe(element, keyframeDictionaryVector); | 97 return createUnsafe(element, keyframeDictionaryVector); |
98 } | 98 } |
99 | 99 |
100 void Animation::setStartDelay(Timing& timing, double startDelay) | 100 void Animation::setStartDelay(Timing& timing, double startDelay) |
101 { | 101 { |
102 if (std::isfinite(startDelay)) | 102 if (std::isfinite(startDelay)) |
103 timing.startDelay = startDelay; | 103 timing.startDelay = startDelay; |
104 else | 104 else |
105 timing.startDelay = 0; | 105 timing.startDelay = Timing::defaults().startDelay; |
106 } | 106 } |
107 | 107 |
108 void Animation::setEndDelay(Timing& timing, double endDelay) | 108 void Animation::setEndDelay(Timing& timing, double endDelay) |
109 { | 109 { |
110 if (std::isfinite(endDelay)) | 110 if (std::isfinite(endDelay)) |
111 timing.endDelay = endDelay; | 111 timing.endDelay = endDelay; |
112 else | 112 else |
113 timing.endDelay = 0; | 113 timing.endDelay = Timing::defaults().endDelay; |
114 } | 114 } |
115 | 115 |
116 void Animation::setFillMode(Timing& timing, String fillMode) | 116 void Animation::setFillMode(Timing& timing, String fillMode) |
117 { | 117 { |
118 if (fillMode == "none") { | 118 if (fillMode == "none") { |
119 timing.fillMode = Timing::FillModeNone; | 119 timing.fillMode = Timing::FillModeNone; |
120 } else if (fillMode == "backwards") { | 120 } else if (fillMode == "backwards") { |
121 timing.fillMode = Timing::FillModeBackwards; | 121 timing.fillMode = Timing::FillModeBackwards; |
122 } else if (fillMode == "both") { | 122 } else if (fillMode == "both") { |
123 timing.fillMode = Timing::FillModeBoth; | 123 timing.fillMode = Timing::FillModeBoth; |
124 } else if (fillMode == "forwards") { | 124 } else if (fillMode == "forwards") { |
125 timing.fillMode = Timing::FillModeForwards; | 125 timing.fillMode = Timing::FillModeForwards; |
126 } else { | 126 } else { |
127 timing.fillMode = Timing::FillModeAuto; | 127 timing.fillMode = Timing::defaults().fillMode; |
128 } | 128 } |
129 } | 129 } |
130 | 130 |
131 void Animation::setIterationStart(Timing& timing, double iterationStart) | 131 void Animation::setIterationStart(Timing& timing, double iterationStart) |
132 { | 132 { |
133 if (!std::isnan(iterationStart) && !std::isinf(iterationStart)) | 133 if (!std::isnan(iterationStart) && !std::isinf(iterationStart)) |
134 timing.iterationStart = std::max<double>(iterationStart, 0); | 134 timing.iterationStart = std::max<double>(iterationStart, 0); |
135 else | 135 else |
136 timing.iterationStart = 0; | 136 timing.iterationStart = Timing::defaults().iterationStart; |
137 } | 137 } |
138 | 138 |
139 void Animation::setIterationCount(Timing& timing, double iterationCount) | 139 void Animation::setIterationCount(Timing& timing, double iterationCount) |
140 { | 140 { |
141 if (!std::isnan(iterationCount)) | 141 if (!std::isnan(iterationCount)) |
142 timing.iterationCount = std::max<double>(iterationCount, 0); | 142 timing.iterationCount = std::max<double>(iterationCount, 0); |
143 else | 143 else |
144 timing.iterationCount = 1; | 144 timing.iterationCount = Timing::defaults().iterationCount; |
145 } | 145 } |
146 | 146 |
147 void Animation::setIterationDuration(Timing& timing, double iterationDuration) | 147 void Animation::setIterationDuration(Timing& timing, double iterationDuration) |
148 { | 148 { |
149 if (!std::isnan(iterationDuration) && iterationDuration >= 0) | 149 if (!std::isnan(iterationDuration) && iterationDuration >= 0) |
150 timing.iterationDuration = iterationDuration; | 150 timing.iterationDuration = iterationDuration; |
151 else | 151 else |
152 timing.iterationDuration = std::numeric_limits<double>::quiet_NaN(); | 152 timing.iterationDuration = Timing::defaults().iterationDuration; |
153 } | 153 } |
154 | 154 |
155 void Animation::setPlaybackRate(Timing& timing, double playbackRate) | 155 void Animation::setPlaybackRate(Timing& timing, double playbackRate) |
156 { | 156 { |
157 if (!std::isnan(playbackRate) && !std::isinf(playbackRate)) | 157 if (!std::isnan(playbackRate) && !std::isinf(playbackRate)) |
158 timing.playbackRate = playbackRate; | 158 timing.playbackRate = playbackRate; |
159 else | 159 else |
160 timing.playbackRate = 1; | 160 timing.playbackRate = Timing::defaults().playbackRate; |
161 } | 161 } |
162 | 162 |
163 void Animation::setPlaybackDirection(Timing& timing, String direction) | 163 void Animation::setPlaybackDirection(Timing& timing, String direction) |
164 { | 164 { |
165 if (direction == "reverse") { | 165 if (direction == "reverse") { |
166 timing.direction = Timing::PlaybackDirectionReverse; | 166 timing.direction = Timing::PlaybackDirectionReverse; |
167 } else if (direction == "alternate") { | 167 } else if (direction == "alternate") { |
168 timing.direction = Timing::PlaybackDirectionAlternate; | 168 timing.direction = Timing::PlaybackDirectionAlternate; |
169 } else if (direction == "alternate-reverse") { | 169 } else if (direction == "alternate-reverse") { |
170 timing.direction = Timing::PlaybackDirectionAlternateReverse; | 170 timing.direction = Timing::PlaybackDirectionAlternateReverse; |
171 } else { | 171 } else { |
172 timing.direction = Timing::PlaybackDirectionNormal; | 172 timing.direction = Timing::defaults().direction; |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 void Animation::setTimingFunction(Timing& timing, String timingFunctionString) | 176 void Animation::setTimingFunction(Timing& timing, String timingFunctionString) |
177 { | 177 { |
178 RefPtrWillBeRawPtr<CSSValue> timingFunctionValue = BisonCSSParser::parseAnim
ationTimingFunctionValue(timingFunctionString); | 178 RefPtrWillBeRawPtr<CSSValue> timingFunctionValue = BisonCSSParser::parseAnim
ationTimingFunctionValue(timingFunctionString); |
179 if (timingFunctionValue) { | 179 if (timingFunctionValue) { |
180 RefPtr<TimingFunction> timingFunction = CSSToStyleMap::animationTimingFu
nction(timingFunctionValue.get(), false); | 180 RefPtr<TimingFunction> timingFunction = CSSToStyleMap::animationTimingFu
nction(timingFunctionValue.get(), false); |
181 if (timingFunction) { | 181 if (timingFunction) { |
182 timing.timingFunction = timingFunction; | 182 timing.timingFunction = timingFunction; |
183 return; | 183 return; |
184 } | 184 } |
185 } | 185 } |
186 timing.timingFunction = LinearTimingFunction::create(); | 186 timing.timingFunction = Timing::defaults().timingFunction; |
187 } | 187 } |
188 | 188 |
189 void Animation::populateTiming(Timing& timing, Dictionary timingInputDictionary) | 189 void Animation::populateTiming(Timing& timing, Dictionary timingInputDictionary) |
190 { | 190 { |
191 // FIXME: This method needs to be refactored to handle invalid | 191 // FIXME: This method needs to be refactored to handle invalid |
192 // null, NaN, Infinity values better. | 192 // null, NaN, Infinity values better. |
193 // See: http://www.w3.org/TR/WebIDL/#es-double | 193 // See: http://www.w3.org/TR/WebIDL/#es-double |
194 double startDelay = 0; | 194 double startDelay = 0; |
195 timingInputDictionary.get("delay", startDelay); | 195 timingInputDictionary.get("delay", startDelay); |
196 setStartDelay(timing, startDelay); | 196 setStartDelay(timing, startDelay); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 void Animation::pauseAnimationForTestingOnCompositor(double pauseTime) | 478 void Animation::pauseAnimationForTestingOnCompositor(double pauseTime) |
479 { | 479 { |
480 ASSERT(hasActiveAnimationsOnCompositor()); | 480 ASSERT(hasActiveAnimationsOnCompositor()); |
481 if (!m_target || !m_target->renderer()) | 481 if (!m_target || !m_target->renderer()) |
482 return; | 482 return; |
483 for (size_t i = 0; i < m_compositorAnimationIds.size(); ++i) | 483 for (size_t i = 0; i < m_compositorAnimationIds.size(); ++i) |
484 CompositorAnimations::instance()->pauseAnimationForTestingOnCompositor(*
m_target.get(), m_compositorAnimationIds[i], pauseTime); | 484 CompositorAnimations::instance()->pauseAnimationForTestingOnCompositor(*
m_target.get(), m_compositorAnimationIds[i], pauseTime); |
485 } | 485 } |
486 | 486 |
487 } // namespace WebCore | 487 } // namespace WebCore |
OLD | NEW |