Chromium Code Reviews| Index: Source/core/inspector/InspectorAnimationAgent.cpp | 
| diff --git a/Source/core/inspector/InspectorAnimationAgent.cpp b/Source/core/inspector/InspectorAnimationAgent.cpp | 
| index 4fcee8f04c0173285704de255beb964443906268..c9189bd9465141112b3d883acdd6ffd8a9aac0a7 100644 | 
| --- a/Source/core/inspector/InspectorAnimationAgent.cpp | 
| +++ b/Source/core/inspector/InspectorAnimationAgent.cpp | 
| @@ -9,7 +9,10 @@ | 
| #include "core/animation/AnimationNode.h" | 
| #include "core/animation/AnimationPlayer.h" | 
| #include "core/animation/ElementAnimation.h" | 
| +#include "core/css/CSSKeyframeRule.h" | 
| +#include "core/css/CSSKeyframesRule.h" | 
| #include "core/inspector/InspectorDOMAgent.h" | 
| +#include "core/inspector/InspectorStyleSheet.h" | 
| namespace blink { | 
| @@ -46,7 +49,14 @@ void InspectorAnimationAgent::getAnimationPlayersForNode(ErrorString* errorStrin | 
| for (WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> >::iterator it = players.begin(); it != players.end(); ++it) { | 
| AnimationPlayer& player = *(it->get()); | 
| m_idToAnimationPlayer.set(playerId(player), &player); | 
| - RefPtr<TypeBuilder::Animation::AnimationPlayer> animationPlayerObject = buildObjectForAnimationPlayer(player); | 
| + RefPtr<TypeBuilder::Animation::AnimationPlayer> animationPlayerObject; | 
| + // FIXME: Add support for web animations | 
| + if (element->activeAnimations()->cssAnimations().getAnimationNameForInspector(player)) { | 
| + RefPtr<TypeBuilder::Animation::KeyframesRule> keyframeRule = getObjectForStyleRuleKeyframes(*element, player); | 
| + animationPlayerObject = buildObjectForAnimationPlayer(player, keyframeRule); | 
| 
 
pfeldman
2014/10/23 06:37:00
keyframeRule.release()
 
samli
2014/10/24 05:06:19
Done.
 
 | 
| + } else { | 
| + animationPlayerObject = buildObjectForAnimationPlayer(player); | 
| + } | 
| animationPlayersArray->addItem(animationPlayerObject); | 
| } | 
| } | 
| @@ -104,6 +114,15 @@ String InspectorAnimationAgent::playerId(AnimationPlayer& player) | 
| PassRefPtr<TypeBuilder::Animation::AnimationPlayer> InspectorAnimationAgent::buildObjectForAnimationPlayer(AnimationPlayer& animationPlayer) | 
| { | 
| + return buildObjectForAnimationPlayer(animationPlayer, nullptr); | 
| 
 
pfeldman
2014/10/23 06:37:00
inline and simplify code above?
 
samli
2014/10/24 05:06:19
Done.
 
 | 
| +} | 
| + | 
| +PassRefPtr<TypeBuilder::Animation::AnimationPlayer> InspectorAnimationAgent::buildObjectForAnimationPlayer(AnimationPlayer& animationPlayer, PassRefPtr<TypeBuilder::Animation::KeyframesRule> keyframeRule) | 
| +{ | 
| + RefPtr<TypeBuilder::Animation::AnimationNode> animationObject = buildObjectForAnimationNode(animationPlayer.source()); | 
| + if (keyframeRule) | 
| + animationObject->setKeyframesRule(keyframeRule); | 
| + | 
| RefPtr<TypeBuilder::Animation::AnimationPlayer> playerObject = TypeBuilder::Animation::AnimationPlayer::create() | 
| .setId(playerId(animationPlayer)) | 
| .setPausedState(animationPlayer.paused()) | 
| @@ -111,25 +130,59 @@ PassRefPtr<TypeBuilder::Animation::AnimationPlayer> InspectorAnimationAgent::bui | 
| .setPlaybackRate(animationPlayer.playbackRate()) | 
| .setStartTime(animationPlayer.startTime()) | 
| .setCurrentTime(animationPlayer.currentTime()) | 
| - .setSource(buildObjectForAnimationNode(*(animationPlayer.source()))); | 
| + .setSource(animationObject.release()); | 
| return playerObject.release(); | 
| } | 
| -PassRefPtr<TypeBuilder::Animation::AnimationNode> InspectorAnimationAgent::buildObjectForAnimationNode(AnimationNode& animationNode) | 
| +PassRefPtr<TypeBuilder::Animation::AnimationNode> InspectorAnimationAgent::buildObjectForAnimationNode(AnimationNode* animationNode) | 
| { | 
| RefPtr<TypeBuilder::Animation::AnimationNode> animationObject = TypeBuilder::Animation::AnimationNode::create() | 
| - .setStartDelay(animationNode.specifiedTiming().startDelay) | 
| - .setPlaybackRate(animationNode.specifiedTiming().playbackRate) | 
| - .setIterationStart(animationNode.specifiedTiming().iterationStart) | 
| - .setIterationCount(animationNode.specifiedTiming().iterationCount) | 
| - .setDuration(animationNode.duration()) | 
| - .setDirection(animationNode.specifiedTiming().direction) | 
| - .setFillMode(animationNode.specifiedTiming().fillMode) | 
| - .setTimeFraction(animationNode.timeFraction()) | 
| - .setName(animationNode.name()); | 
| + .setStartDelay(animationNode->specifiedTiming().startDelay) | 
| + .setPlaybackRate(animationNode->specifiedTiming().playbackRate) | 
| + .setIterationStart(animationNode->specifiedTiming().iterationStart) | 
| + .setIterationCount(animationNode->specifiedTiming().iterationCount) | 
| + .setDuration(animationNode->duration()) | 
| + .setDirection(animationNode->specifiedTiming().direction) | 
| + .setFillMode(animationNode->specifiedTiming().fillMode) | 
| + .setTimeFraction(animationNode->timeFraction()) | 
| + .setName(animationNode->name()); | 
| return animationObject.release(); | 
| } | 
| +PassRefPtr<TypeBuilder::Animation::KeyframesRule> InspectorAnimationAgent::getObjectForStyleRuleKeyframes(const Element& element, const AnimationPlayer& player) | 
| +{ | 
| + StyleResolver& styleResolver = element.ownerDocument()->ensureStyleResolver(); | 
| + // FIXME: Add support for web anim | 
| + CSSAnimations& cssAnimations = element.activeAnimations()->cssAnimations(); | 
| + const AtomicString* animationName = cssAnimations.getAnimationNameForInspector(player); | 
| + ASSERT(animationName); | 
| + const StyleRuleKeyframes* keyframes = cssAnimations.matchScopedKeyframesRule(&styleResolver, &element, animationName->impl()); | 
| + | 
| + return buildObjectForStyleRuleKeyframes(keyframes); | 
| +} | 
| + | 
| +PassRefPtr<TypeBuilder::Animation::KeyframesRule> InspectorAnimationAgent::buildObjectForStyleRuleKeyframes(const StyleRuleKeyframes* keyframesRule) | 
| +{ | 
| + RefPtr<TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle> > keyframes = TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle>::create(); | 
| + const WillBeHeapVector<RefPtrWillBeMember<StyleKeyframe> >& styleKeyframes = keyframesRule->keyframes(); | 
| + for (const auto& styleKeyframe : styleKeyframes) | 
| + keyframes->addItem(buildObjectForStyleKeyframe(styleKeyframe.get())); | 
| + | 
| + RefPtr<TypeBuilder::Animation::KeyframesRule> keyframesObject = TypeBuilder::Animation::KeyframesRule::create() | 
| + .setKeyframes(keyframes); | 
| + keyframesObject->setName(keyframesRule->name()); | 
| + return keyframesObject.release(); | 
| +} | 
| + | 
| +PassRefPtr<TypeBuilder::Animation::KeyframeStyle> InspectorAnimationAgent::buildObjectForStyleKeyframe(StyleKeyframe* keyframe) | 
| +{ | 
| + RefPtrWillBeRawPtr<InspectorStyle> inspectorStyle = InspectorStyle::create(InspectorCSSId(), keyframe->mutableProperties().ensureCSSStyleDeclaration(), 0); | 
| + RefPtr<TypeBuilder::Animation::KeyframeStyle> keyframeObject = TypeBuilder::Animation::KeyframeStyle::create() | 
| + .setOffset(keyframe->keyText()) | 
| + .setStyle(inspectorStyle->buildObjectForStyle()); | 
| + return keyframeObject.release(); | 
| +} | 
| + | 
| void InspectorAnimationAgent::trace(Visitor* visitor) | 
| { | 
| #if ENABLE(OILPAN) |