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 | 6 |
7 #include "core/inspector/InspectorAnimationAgent.h" | 7 #include "core/inspector/InspectorAnimationAgent.h" |
8 | 8 |
9 #include "core/animation/Animation.h" | 9 #include "core/animation/Animation.h" |
10 #include "core/animation/AnimationEffect.h" | 10 #include "core/animation/AnimationEffect.h" |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 { | 258 { |
259 m_pageAgent->inspectedFrame()->document()->timeline().setCurrentTime(current
Time); | 259 m_pageAgent->inspectedFrame()->document()->timeline().setCurrentTime(current
Time); |
260 } | 260 } |
261 | 261 |
262 void InspectorAnimationAgent::setTiming(ErrorString* errorString, const String&
playerId, double duration, double delay) | 262 void InspectorAnimationAgent::setTiming(ErrorString* errorString, const String&
playerId, double duration, double delay) |
263 { | 263 { |
264 AnimationPlayer* player = assertAnimationPlayer(errorString, playerId); | 264 AnimationPlayer* player = assertAnimationPlayer(errorString, playerId); |
265 if (!player) | 265 if (!player) |
266 return; | 266 return; |
267 | 267 |
268 RefPtrWillBeRawPtr<AnimationNodeTiming> timing = player->source()->timing(); | 268 AnimationType type = m_idToAnimationType.get(playerId); |
269 UnrestrictedDoubleOrString unrestrictedDuration; | 269 if (type == AnimationType::CSSTransition) { |
270 unrestrictedDuration.setUnrestrictedDouble(duration); | 270 Animation* animation = toAnimation(player->source()); |
271 timing->setDuration(unrestrictedDuration); | 271 KeyframeEffectModelBase* effect = toKeyframeEffectModelBase(animation->e
ffect()); |
272 timing->setDelay(delay); | 272 const AnimatableValueKeyframeEffectModel* oldEffect = toAnimatableValueK
eyframeEffectModel(effect); |
| 273 // Refer to CSSAnimations::calculateTransitionUpdateForProperty() for th
e structure of transitions. |
| 274 const KeyframeVector& frames = oldEffect->getFrames(); |
| 275 ASSERT(frames.size() == 3); |
| 276 KeyframeVector newFrames; |
| 277 for (int i = 0; i < 3; i++) |
| 278 newFrames.append(toAnimatableValueKeyframe(frames[i]->clone().get())
); |
| 279 // Update delay, represented by the distance between the first two keyfr
ames. |
| 280 newFrames[1]->setOffset(delay / (delay + duration)); |
| 281 effect->setFrames(newFrames); |
| 282 |
| 283 RefPtrWillBeRawPtr<AnimationNodeTiming> timing = player->source()->timin
g(); |
| 284 UnrestrictedDoubleOrString unrestrictedDuration; |
| 285 unrestrictedDuration.setUnrestrictedDouble(duration + delay); |
| 286 timing->setDuration(unrestrictedDuration); |
| 287 } else if (type == AnimationType::WebAnimation) { |
| 288 RefPtrWillBeRawPtr<AnimationNodeTiming> timing = player->source()->timin
g(); |
| 289 UnrestrictedDoubleOrString unrestrictedDuration; |
| 290 unrestrictedDuration.setUnrestrictedDouble(duration); |
| 291 timing->setDuration(unrestrictedDuration); |
| 292 timing->setDelay(delay); |
| 293 } |
273 } | 294 } |
274 | 295 |
275 void InspectorAnimationAgent::didCreateAnimationPlayer(AnimationPlayer* player) | 296 void InspectorAnimationAgent::didCreateAnimationPlayer(AnimationPlayer* player) |
276 { | 297 { |
277 const String& playerId = String::number(player->sequenceNumber()); | 298 const String& playerId = String::number(player->sequenceNumber()); |
278 if (m_idToAnimationPlayer.get(playerId)) | 299 if (m_idToAnimationPlayer.get(playerId)) |
279 return; | 300 return; |
280 | 301 |
281 // Check threshold | 302 // Check threshold |
282 double latestStartTime = 0; | 303 double latestStartTime = 0; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 #if ENABLE(OILPAN) | 337 #if ENABLE(OILPAN) |
317 visitor->trace(m_pageAgent); | 338 visitor->trace(m_pageAgent); |
318 visitor->trace(m_domAgent); | 339 visitor->trace(m_domAgent); |
319 visitor->trace(m_idToAnimationPlayer); | 340 visitor->trace(m_idToAnimationPlayer); |
320 visitor->trace(m_idToAnimationType); | 341 visitor->trace(m_idToAnimationType); |
321 #endif | 342 #endif |
322 InspectorBaseAgent::trace(visitor); | 343 InspectorBaseAgent::trace(visitor); |
323 } | 344 } |
324 | 345 |
325 } | 346 } |
OLD | NEW |