Chromium Code Reviews| Index: Source/core/inspector/InspectorAnimationAgent.cpp |
| diff --git a/Source/core/inspector/InspectorAnimationAgent.cpp b/Source/core/inspector/InspectorAnimationAgent.cpp |
| index 593e0444e17eb2c4742d781672625fa1f5371abd..b9406f23ccba0b066bfc19011b0758d8eae8de81 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" |
| @@ -152,7 +153,7 @@ PassRefPtr<TypeBuilder::Animation::AnimationPlayer> InspectorAnimationAgent::bui |
| } else { |
| // Keyframe based animations |
| keyframeRule = buildObjectForAnimationKeyframes(toKeyframeEffect(player.source())); |
| - animationType = cssAnimations.isAnimationForInspector(player) ? AnimationType::WebAnimation : AnimationType::CSSAnimation; |
| + animationType = cssAnimations.isAnimationForInspector(player) ? AnimationType::CSSAnimation : AnimationType::WebAnimation; |
|
dgozman
2015/05/28 11:04:03
What I meant is to add tests that cover the functi
|
| } |
| String id = String::number(player.sequenceNumber()); |
| @@ -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); |
| @@ -259,6 +266,33 @@ void InspectorAnimationAgent::setTiming(ErrorString* errorString, const String& |
| } |
| } |
| +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."; |
|
dgozman
2015/05/28 11:04:03
I think, we should have similar error reporting ev
samli
2015/05/29 04:32:11
Acknowledged.
|
| + } |
| +} |
| + |
| void InspectorAnimationAgent::didCreateAnimation(Animation* player) |
| { |
| const String& playerId = String::number(player->sequenceNumber()); |