| Index: Source/core/inspector/InspectorAnimationAgent.cpp
|
| diff --git a/Source/core/inspector/InspectorAnimationAgent.cpp b/Source/core/inspector/InspectorAnimationAgent.cpp
|
| index 04e20c6640ab6649fd95445f158d532025763a93..e4c68874b2baa4eef4d20ab1201a393bfc6b59c4 100644
|
| --- a/Source/core/inspector/InspectorAnimationAgent.cpp
|
| +++ b/Source/core/inspector/InspectorAnimationAgent.cpp
|
| @@ -9,6 +9,7 @@
|
| #include "core/animation/Animation.h"
|
| #include "core/animation/AnimationEffect.h"
|
| #include "core/animation/AnimationEffectTiming.h"
|
| +#include "core/animation/AnimationInputHelpers.h"
|
| #include "core/animation/ComputedTimingProperties.h"
|
| #include "core/animation/EffectModel.h"
|
| #include "core/animation/ElementAnimation.h"
|
| @@ -225,6 +226,18 @@ void InspectorAnimationAgent::setCurrentTime(ErrorString*, double currentTime)
|
| }
|
| }
|
|
|
| +static KeyframeVector cloneTransitionFrames(KeyframeEffectModelBase* model)
|
| +{
|
| + const AnimatableValueKeyframeEffectModel* oldModel = toAnimatableValueKeyframeEffectModel(model);
|
| + // Refer to CSSAnimations::calculateTransitionUpdateForProperty() for the structure of transitions.
|
| + const KeyframeVector& frames = oldModel->getFrames();
|
| + ASSERT(frames.size() == 3);
|
| + KeyframeVector newFrames;
|
| + for (int i = 0; i < 3; i++)
|
| + newFrames.append(toAnimatableValueKeyframe(frames[i]->clone().get()));
|
| + return newFrames;
|
| +}
|
| +
|
| void InspectorAnimationAgent::setTiming(ErrorString* errorString, const String& playerId, double duration, double delay)
|
| {
|
| Animation* animation = assertAnimation(errorString, playerId);
|
| @@ -235,13 +248,7 @@ void InspectorAnimationAgent::setTiming(ErrorString* errorString, const String&
|
| if (type == AnimationType::CSSTransition) {
|
| KeyframeEffect* effect = toKeyframeEffect(animation->source());
|
| KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect->model());
|
| - const AnimatableValueKeyframeEffectModel* oldModel = toAnimatableValueKeyframeEffectModel(model);
|
| - // Refer to CSSAnimations::calculateTransitionUpdateForProperty() for the structure of transitions.
|
| - const KeyframeVector& frames = oldModel->getFrames();
|
| - ASSERT(frames.size() == 3);
|
| - KeyframeVector newFrames;
|
| - for (int i = 0; i < 3; i++)
|
| - newFrames.append(toAnimatableValueKeyframe(frames[i]->clone().get()));
|
| + KeyframeVector newFrames = cloneTransitionFrames(model);
|
| // Update delay, represented by the distance between the first two keyframes.
|
| newFrames[1]->setOffset(delay / (delay + duration));
|
| model->setFrames(newFrames);
|
| @@ -256,6 +263,35 @@ void InspectorAnimationAgent::setTiming(ErrorString* errorString, const String&
|
| unrestrictedDuration.setUnrestrictedDouble(duration);
|
| timing->setDuration(unrestrictedDuration);
|
| timing->setDelay(delay);
|
| + } else {
|
| + *errorString = "Given animation is not a transition or web animation.";
|
| + }
|
| +}
|
| +
|
| +void InspectorAnimationAgent::setEasing(ErrorString* errorString, const String& playerId, const String& easing)
|
| +{
|
| + Animation* animation = assertAnimation(errorString, playerId);
|
| + if (!animation)
|
| + return;
|
| +
|
| + AnimationType type = m_idToAnimationType.get(playerId);
|
| + if (type == AnimationType::CSSTransition) {
|
| + KeyframeEffect* effect = toKeyframeEffect(animation->source());
|
| + KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect->model());
|
| + KeyframeVector newFrames = cloneTransitionFrames(model);
|
| + // Update easing of the transition, represented by the second keyframe.
|
| + if (RefPtr<TimingFunction> timingFunction = AnimationInputHelpers::parseTimingFunction(easing)) {
|
| + newFrames[1]->setEasing(timingFunction);
|
| + } else {
|
| + *errorString = "Could not parse timing function.";
|
| + return;
|
| + }
|
| + model->setFrames(newFrames);
|
| + } else if (type == AnimationType::WebAnimation) {
|
| + RefPtrWillBeRawPtr<AnimationEffectTiming> timing = animation->source()->timing();
|
| + timing->setEasing(easing);
|
| + } else {
|
| + *errorString = "Given animation is not a transition or web animation.";
|
| }
|
| }
|
|
|
|
|