Chromium Code Reviews| 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" |
| 11 #include "core/animation/AnimationEffectTiming.h" | 11 #include "core/animation/AnimationEffectTiming.h" |
| 12 #include "core/animation/AnimationInputHelpers.h" | |
| 12 #include "core/animation/ComputedTimingProperties.h" | 13 #include "core/animation/ComputedTimingProperties.h" |
| 13 #include "core/animation/EffectModel.h" | 14 #include "core/animation/EffectModel.h" |
| 14 #include "core/animation/ElementAnimation.h" | 15 #include "core/animation/ElementAnimation.h" |
| 15 #include "core/animation/KeyframeEffect.h" | 16 #include "core/animation/KeyframeEffect.h" |
| 16 #include "core/animation/KeyframeEffectModel.h" | 17 #include "core/animation/KeyframeEffectModel.h" |
| 17 #include "core/animation/StringKeyframe.h" | 18 #include "core/animation/StringKeyframe.h" |
| 18 #include "core/css/CSSKeyframeRule.h" | 19 #include "core/css/CSSKeyframeRule.h" |
| 19 #include "core/css/CSSKeyframesRule.h" | 20 #include "core/css/CSSKeyframesRule.h" |
| 20 #include "core/css/resolver/StyleResolver.h" | 21 #include "core/css/resolver/StyleResolver.h" |
| 21 #include "core/dom/DOMNodeIds.h" | 22 #include "core/dom/DOMNodeIds.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 CSSAnimations& cssAnimations = element->elementAnimations()->cssAnimations() ; | 146 CSSAnimations& cssAnimations = element->elementAnimations()->cssAnimations() ; |
| 146 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframeRule = nullptr; | 147 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframeRule = nullptr; |
| 147 AnimationType animationType; | 148 AnimationType animationType; |
| 148 | 149 |
| 149 if (cssAnimations.isTransitionAnimationForInspector(player)) { | 150 if (cssAnimations.isTransitionAnimationForInspector(player)) { |
| 150 // CSS Transitions | 151 // CSS Transitions |
| 151 animationType = AnimationType::CSSTransition; | 152 animationType = AnimationType::CSSTransition; |
| 152 } else { | 153 } else { |
| 153 // Keyframe based animations | 154 // Keyframe based animations |
| 154 keyframeRule = buildObjectForAnimationKeyframes(toKeyframeEffect(player. source())); | 155 keyframeRule = buildObjectForAnimationKeyframes(toKeyframeEffect(player. source())); |
| 155 animationType = cssAnimations.isAnimationForInspector(player) ? Animatio nType::WebAnimation : AnimationType::CSSAnimation; | 156 animationType = cssAnimations.isAnimationForInspector(player) ? Animatio nType::CSSAnimation : AnimationType::WebAnimation; |
| 156 } | 157 } |
| 157 | 158 |
| 158 String id = String::number(player.sequenceNumber()); | 159 String id = String::number(player.sequenceNumber()); |
| 159 m_idToAnimation.set(id, &player); | 160 m_idToAnimation.set(id, &player); |
| 160 m_idToAnimationType.set(id, animationType); | 161 m_idToAnimationType.set(id, animationType); |
| 161 | 162 |
| 162 RefPtr<TypeBuilder::Animation::AnimationNode> animationObject = buildObjectF orAnimation(toKeyframeEffect(player.source()), animationType == AnimationType::C SSTransition); | 163 RefPtr<TypeBuilder::Animation::AnimationNode> animationObject = buildObjectF orAnimation(toKeyframeEffect(player.source()), animationType == AnimationType::C SSTransition); |
| 163 if (keyframeRule) | 164 if (keyframeRule) |
| 164 animationObject->setKeyframesRule(keyframeRule); | 165 animationObject->setKeyframesRule(keyframeRule); |
| 165 | 166 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 timing->setDuration(unrestrictedDuration); | 253 timing->setDuration(unrestrictedDuration); |
| 253 } else if (type == AnimationType::WebAnimation) { | 254 } else if (type == AnimationType::WebAnimation) { |
| 254 RefPtrWillBeRawPtr<AnimationEffectTiming> timing = animation->source()-> timing(); | 255 RefPtrWillBeRawPtr<AnimationEffectTiming> timing = animation->source()-> timing(); |
| 255 UnrestrictedDoubleOrString unrestrictedDuration; | 256 UnrestrictedDoubleOrString unrestrictedDuration; |
| 256 unrestrictedDuration.setUnrestrictedDouble(duration); | 257 unrestrictedDuration.setUnrestrictedDouble(duration); |
| 257 timing->setDuration(unrestrictedDuration); | 258 timing->setDuration(unrestrictedDuration); |
| 258 timing->setDelay(delay); | 259 timing->setDelay(delay); |
| 259 } | 260 } |
| 260 } | 261 } |
| 261 | 262 |
| 263 void InspectorAnimationAgent::setEasing(ErrorString* errorString, const String& playerId, const String& easing) | |
| 264 { | |
| 265 Animation* animation = assertAnimation(errorString, playerId); | |
| 266 if (!animation) | |
| 267 return; | |
| 268 | |
| 269 AnimationType type = m_idToAnimationType.get(playerId); | |
| 270 if (type == AnimationType::CSSTransition) { | |
| 271 KeyframeEffect* effect = toKeyframeEffect(animation->source()); | |
| 272 KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect->model ()); | |
| 273 const AnimatableValueKeyframeEffectModel* oldModel = toAnimatableValueKe yframeEffectModel(model); | |
| 274 // Refer to CSSAnimations::calculateTransitionUpdateForProperty() for th e structure of transitions. | |
| 275 const KeyframeVector& frames = oldModel->getFrames(); | |
| 276 ASSERT(frames.size() == 3); | |
| 277 KeyframeVector newFrames; | |
| 278 for (int i = 0; i < 3; i++) | |
| 279 newFrames.append(toAnimatableValueKeyframe(frames[i]->clone().get()) ); | |
| 280 // Update easing of the transition, represented by the second keyframe | |
| 281 if (RefPtr<TimingFunction> timingFunction = AnimationInputHelpers::parse TimingFunction(easing)) | |
|
dgozman
2015/05/23 00:53:26
Code up to this line may be extracted into helper
samli
2015/05/25 01:55:38
Done.
| |
| 282 newFrames[1]->setEasing(timingFunction); | |
| 283 model->setFrames(newFrames); | |
| 284 } else if (type == AnimationType::WebAnimation) { | |
| 285 RefPtrWillBeRawPtr<AnimationEffectTiming> timing = animation->source()-> timing(); | |
| 286 timing->setEasing(easing); | |
| 287 } | |
| 288 } | |
| 289 | |
| 262 void InspectorAnimationAgent::didCreateAnimation(Animation* player) | 290 void InspectorAnimationAgent::didCreateAnimation(Animation* player) |
| 263 { | 291 { |
| 264 const String& playerId = String::number(player->sequenceNumber()); | 292 const String& playerId = String::number(player->sequenceNumber()); |
| 265 if (m_idToAnimation.get(playerId)) | 293 if (m_idToAnimation.get(playerId)) |
| 266 return; | 294 return; |
| 267 | 295 |
| 268 double threshold = 1000; | 296 double threshold = 1000; |
| 269 bool reset = normalizedStartTime(*player) - threshold > m_latestStartTime; | 297 bool reset = normalizedStartTime(*player) - threshold > m_latestStartTime; |
| 270 m_latestStartTime = normalizedStartTime(*player); | 298 m_latestStartTime = normalizedStartTime(*player); |
| 271 if (reset) { | 299 if (reset) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 #if ENABLE(OILPAN) | 347 #if ENABLE(OILPAN) |
| 320 visitor->trace(m_pageAgent); | 348 visitor->trace(m_pageAgent); |
| 321 visitor->trace(m_domAgent); | 349 visitor->trace(m_domAgent); |
| 322 visitor->trace(m_idToAnimation); | 350 visitor->trace(m_idToAnimation); |
| 323 visitor->trace(m_idToAnimationType); | 351 visitor->trace(m_idToAnimationType); |
| 324 #endif | 352 #endif |
| 325 InspectorBaseAgent::trace(visitor); | 353 InspectorBaseAgent::trace(visitor); |
| 326 } | 354 } |
| 327 | 355 |
| 328 } | 356 } |
| OLD | NEW |