PassRefPtr<TypeBuilder::Animation::Animation> InspectorAnimationAgent::buildObjectForAnimation(Animation& animation) { const Element* element = toKeyframeEffect(animation.effect())->target(); CSSAnimations& cssAnimations = element->elementAnimations()->cssAnimations(); RefPtr<TypeBuilder::Animation::KeyframesRule> keyframeRule = nullptr; AnimationType animationType; if (cssAnimations.isTransitionAnimationForInspector(animation)) { // CSS Transitions animationType = AnimationType::CSSTransition; } else { // Keyframe based animations keyframeRule = buildObjectForAnimationKeyframes(toKeyframeEffect(animation.effect())); animationType = cssAnimations.isAnimationForInspector(animation) ? AnimationType::CSSAnimation : AnimationType::WebAnimation; } String id = String::number(animation.sequenceNumber()); m_idToAnimation.set(id, &animation); m_idToAnimationType.set(id, animationType); RefPtr<TypeBuilder::Animation::AnimationEffect> animationEffectObject = buildObjectForAnimationEffect(toKeyframeEffect(animation.effect()), animationType == AnimationType::CSSTransition); if (keyframeRule) animationEffectObject->setKeyframesRule(keyframeRule); RefPtr<TypeBuilder::Animation::Animation> animationObject = TypeBuilder::Animation::Animation::create() .setId(id) .setPausedState(animation.paused()) .setPlayState(animation.playState()) .setPlaybackRate(animation.playbackRate()) .setStartTime(normalizedStartTime(animation)) .setCurrentTime(animation.currentTime()) .setSource(animationEffectObject.release()) .setType(animationType); return animationObject.release(); }
std::unique_ptr<protocol::Animation::Animation> InspectorAnimationAgent::buildObjectForAnimation(blink::Animation& animation) { const Element* element = toKeyframeEffect(animation.effect())->target(); CSSAnimations& cssAnimations = element->elementAnimations()->cssAnimations(); std::unique_ptr<protocol::Animation::KeyframesRule> keyframeRule = nullptr; String animationType; if (cssAnimations.isTransitionAnimationForInspector(animation)) { // CSS Transitions animationType = AnimationType::CSSTransition; } else { // Keyframe based animations keyframeRule = buildObjectForAnimationKeyframes(toKeyframeEffect(animation.effect())); animationType = cssAnimations.isAnimationForInspector(animation) ? AnimationType::CSSAnimation : AnimationType::WebAnimation; } String id = String::number(animation.sequenceNumber()); m_idToAnimation.set(id, &animation); m_idToAnimationType.set(id, animationType); std::unique_ptr<protocol::Animation::AnimationEffect> animationEffectObject = buildObjectForAnimationEffect( toKeyframeEffect(animation.effect()), animationType == AnimationType::CSSTransition); animationEffectObject->setKeyframesRule(std::move(keyframeRule)); std::unique_ptr<protocol::Animation::Animation> animationObject = protocol::Animation::Animation::create() .setId(id) .setName(animation.id()) .setPausedState(animation.paused()) .setPlayState(animation.playState()) .setPlaybackRate(animation.playbackRate()) .setStartTime(normalizedStartTime(animation)) .setCurrentTime(animation.currentTime()) .setSource(std::move(animationEffectObject)) .setType(animationType) .build(); if (animationType != AnimationType::WebAnimation) animationObject->setCssId(createCSSId(animation)); return animationObject; }