| 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" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 ComputedTimingProperties computedTiming; | 77 ComputedTimingProperties computedTiming; |
| 78 effect->computedTiming(computedTiming); | 78 effect->computedTiming(computedTiming); |
| 79 double delay = computedTiming.delay(); | 79 double delay = computedTiming.delay(); |
| 80 double duration = computedTiming.duration().getAsUnrestrictedDouble(); | 80 double duration = computedTiming.duration().getAsUnrestrictedDouble(); |
| 81 String easing = effect->specifiedTiming().timingFunction->toString(); | 81 String easing = effect->specifiedTiming().timingFunction->toString(); |
| 82 | 82 |
| 83 if (isTransition) { | 83 if (isTransition) { |
| 84 // Obtain keyframes and convert keyframes back to delay | 84 // Obtain keyframes and convert keyframes back to delay |
| 85 ASSERT(effect->model()->isKeyframeEffectModel()); | 85 ASSERT(effect->model()->isKeyframeEffectModel()); |
| 86 const KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect-
>model()); | 86 const KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect-
>model()); |
| 87 WillBeHeapVector<RefPtrWillBeMember<Keyframe> > keyframes = KeyframeEffe
ctModelBase::normalizedKeyframesForInspector(model->getFrames()); | 87 HeapVector<Member<Keyframe>> keyframes = KeyframeEffectModelBase::normal
izedKeyframesForInspector(model->getFrames()); |
| 88 if (keyframes.size() == 3) { | 88 if (keyframes.size() == 3) { |
| 89 delay = keyframes.at(1)->offset() * duration; | 89 delay = keyframes.at(1)->offset() * duration; |
| 90 duration -= delay; | 90 duration -= delay; |
| 91 easing = keyframes.at(1)->easing().toString(); | 91 easing = keyframes.at(1)->easing().toString(); |
| 92 } else { | 92 } else { |
| 93 easing = keyframes.at(0)->easing().toString(); | 93 easing = keyframes.at(0)->easing().toString(); |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 RefPtr<TypeBuilder::Animation::AnimationEffect> animationObject = TypeBuilde
r::Animation::AnimationEffect::create() | 97 RefPtr<TypeBuilder::Animation::AnimationEffect> animationObject = TypeBuilde
r::Animation::AnimationEffect::create() |
| (...skipping 21 matching lines...) Expand all Loading... |
| 119 .setOffset(offset) | 119 .setOffset(offset) |
| 120 .setEasing(keyframe->easing().toString()); | 120 .setEasing(keyframe->easing().toString()); |
| 121 return keyframeObject.release(); | 121 return keyframeObject.release(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForAnimation
Keyframes(const KeyframeEffect* effect) | 124 static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForAnimation
Keyframes(const KeyframeEffect* effect) |
| 125 { | 125 { |
| 126 if (!effect || !effect->model() || !effect->model()->isKeyframeEffectModel()
) | 126 if (!effect || !effect->model() || !effect->model()->isKeyframeEffectModel()
) |
| 127 return nullptr; | 127 return nullptr; |
| 128 const KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect->mod
el()); | 128 const KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect->mod
el()); |
| 129 WillBeHeapVector<RefPtrWillBeMember<Keyframe> > normalizedKeyframes = Keyfra
meEffectModelBase::normalizedKeyframesForInspector(model->getFrames()); | 129 HeapVector<Member<Keyframe>> normalizedKeyframes = KeyframeEffectModelBase::
normalizedKeyframesForInspector(model->getFrames()); |
| 130 RefPtr<TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle> > keyframes
= TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle>::create(); | 130 RefPtr<TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle> > keyframes
= TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle>::create(); |
| 131 | 131 |
| 132 for (const auto& keyframe : normalizedKeyframes) { | 132 for (const auto& keyframe : normalizedKeyframes) { |
| 133 // Ignore CSS Transitions | 133 // Ignore CSS Transitions |
| 134 if (!keyframe.get()->isStringKeyframe()) | 134 if (!keyframe.get()->isStringKeyframe()) |
| 135 continue; | 135 continue; |
| 136 const StringKeyframe* stringKeyframe = toStringKeyframe(keyframe.get()); | 136 const StringKeyframe* stringKeyframe = toStringKeyframe(keyframe.get()); |
| 137 keyframes->addItem(buildObjectForStringKeyframe(stringKeyframe)); | 137 keyframes->addItem(buildObjectForStringKeyframe(stringKeyframe)); |
| 138 } | 138 } |
| 139 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframesObject = TypeBuilder:
:Animation::KeyframesRule::create() | 139 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframesObject = TypeBuilder:
:Animation::KeyframesRule::create() |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 AnimationType type = m_idToAnimationType.get(animationId); | 210 AnimationType type = m_idToAnimationType.get(animationId); |
| 211 if (type == AnimationType::CSSTransition) { | 211 if (type == AnimationType::CSSTransition) { |
| 212 KeyframeEffect* effect = toKeyframeEffect(animation->effect()); | 212 KeyframeEffect* effect = toKeyframeEffect(animation->effect()); |
| 213 KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect->model
()); | 213 KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect->model
()); |
| 214 const AnimatableValueKeyframeEffectModel* oldModel = toAnimatableValueKe
yframeEffectModel(model); | 214 const AnimatableValueKeyframeEffectModel* oldModel = toAnimatableValueKe
yframeEffectModel(model); |
| 215 // Refer to CSSAnimations::calculateTransitionUpdateForProperty() for th
e structure of transitions. | 215 // Refer to CSSAnimations::calculateTransitionUpdateForProperty() for th
e structure of transitions. |
| 216 const KeyframeVector& frames = oldModel->getFrames(); | 216 const KeyframeVector& frames = oldModel->getFrames(); |
| 217 ASSERT(frames.size() == 3); | 217 ASSERT(frames.size() == 3); |
| 218 KeyframeVector newFrames; | 218 KeyframeVector newFrames; |
| 219 for (int i = 0; i < 3; i++) | 219 for (int i = 0; i < 3; i++) |
| 220 newFrames.append(toAnimatableValueKeyframe(frames[i]->clone().get())
); | 220 newFrames.append(toAnimatableValueKeyframe(frames[i]->clone())); |
| 221 // Update delay, represented by the distance between the first two keyfr
ames. | 221 // Update delay, represented by the distance between the first two keyfr
ames. |
| 222 newFrames[1]->setOffset(delay / (delay + duration)); | 222 newFrames[1]->setOffset(delay / (delay + duration)); |
| 223 model->setFrames(newFrames); | 223 model->setFrames(newFrames); |
| 224 | 224 |
| 225 RefPtrWillBeRawPtr<AnimationEffectTiming> timing = animation->effect()->
timing(); | 225 AnimationEffectTiming* timing = animation->effect()->timing(); |
| 226 UnrestrictedDoubleOrString unrestrictedDuration; | 226 UnrestrictedDoubleOrString unrestrictedDuration; |
| 227 unrestrictedDuration.setUnrestrictedDouble(duration + delay); | 227 unrestrictedDuration.setUnrestrictedDouble(duration + delay); |
| 228 timing->setDuration(unrestrictedDuration); | 228 timing->setDuration(unrestrictedDuration); |
| 229 } else if (type == AnimationType::WebAnimation) { | 229 } else if (type == AnimationType::WebAnimation) { |
| 230 RefPtrWillBeRawPtr<AnimationEffectTiming> timing = animation->effect()->
timing(); | 230 AnimationEffectTiming* timing = animation->effect()->timing(); |
| 231 UnrestrictedDoubleOrString unrestrictedDuration; | 231 UnrestrictedDoubleOrString unrestrictedDuration; |
| 232 unrestrictedDuration.setUnrestrictedDouble(duration); | 232 unrestrictedDuration.setUnrestrictedDouble(duration); |
| 233 timing->setDuration(unrestrictedDuration); | 233 timing->setDuration(unrestrictedDuration); |
| 234 timing->setDelay(delay); | 234 timing->setDelay(delay); |
| 235 } | 235 } |
| 236 } | 236 } |
| 237 | 237 |
| 238 void InspectorAnimationAgent::didCreateAnimation(Animation* animation) | 238 void InspectorAnimationAgent::didCreateAnimation(Animation* animation) |
| 239 { | 239 { |
| 240 const String& animationId = String::number(animation->sequenceNumber()); | 240 const String& animationId = String::number(animation->sequenceNumber()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 #if ENABLE(OILPAN) | 295 #if ENABLE(OILPAN) |
| 296 visitor->trace(m_pageAgent); | 296 visitor->trace(m_pageAgent); |
| 297 visitor->trace(m_domAgent); | 297 visitor->trace(m_domAgent); |
| 298 visitor->trace(m_idToAnimation); | 298 visitor->trace(m_idToAnimation); |
| 299 visitor->trace(m_idToAnimationType); | 299 visitor->trace(m_idToAnimationType); |
| 300 #endif | 300 #endif |
| 301 InspectorBaseAgent::trace(visitor); | 301 InspectorBaseAgent::trace(visitor); |
| 302 } | 302 } |
| 303 | 303 |
| 304 } | 304 } |
| OLD | NEW |