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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 ComputedTimingProperties computedTiming; | 74 ComputedTimingProperties computedTiming; |
75 effect->computedTiming(computedTiming); | 75 effect->computedTiming(computedTiming); |
76 double delay = computedTiming.delay(); | 76 double delay = computedTiming.delay(); |
77 double duration = computedTiming.duration().getAsUnrestrictedDouble(); | 77 double duration = computedTiming.duration().getAsUnrestrictedDouble(); |
78 String easing = effect->specifiedTiming().timingFunction->toString(); | 78 String easing = effect->specifiedTiming().timingFunction->toString(); |
79 | 79 |
80 if (isTransition) { | 80 if (isTransition) { |
81 // Obtain keyframes and convert keyframes back to delay | 81 // Obtain keyframes and convert keyframes back to delay |
82 ASSERT(effect->model()->isKeyframeEffectModel()); | 82 ASSERT(effect->model()->isKeyframeEffectModel()); |
83 const KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect-
>model()); | 83 const KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect-
>model()); |
84 WillBeHeapVector<RefPtrWillBeMember<Keyframe> > keyframes = KeyframeEffe
ctModelBase::normalizedKeyframesForInspector(model->getFrames()); | 84 HeapVector<Member<Keyframe>> keyframes = KeyframeEffectModelBase::normal
izedKeyframesForInspector(model->getFrames()); |
85 if (keyframes.size() == 3) { | 85 if (keyframes.size() == 3) { |
86 delay = keyframes.at(1)->offset() * duration; | 86 delay = keyframes.at(1)->offset() * duration; |
87 duration -= delay; | 87 duration -= delay; |
88 easing = keyframes.at(1)->easing().toString(); | 88 easing = keyframes.at(1)->easing().toString(); |
89 } else { | 89 } else { |
90 easing = keyframes.at(0)->easing().toString(); | 90 easing = keyframes.at(0)->easing().toString(); |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 RefPtr<TypeBuilder::Animation::AnimationNode> animationObject = TypeBuilder:
:Animation::AnimationNode::create() | 94 RefPtr<TypeBuilder::Animation::AnimationNode> animationObject = TypeBuilder:
:Animation::AnimationNode::create() |
(...skipping 26 matching lines...) Expand all Loading... |
121 offset.append("%"); | 121 offset.append("%"); |
122 | 122 |
123 RefPtr<TypeBuilder::Animation::KeyframeStyle> keyframeObject = TypeBuilder::
Animation::KeyframeStyle::create() | 123 RefPtr<TypeBuilder::Animation::KeyframeStyle> keyframeObject = TypeBuilder::
Animation::KeyframeStyle::create() |
124 .setOffset(offset) | 124 .setOffset(offset) |
125 .setEasing(keyframe->easing().toString()); | 125 .setEasing(keyframe->easing().toString()); |
126 return keyframeObject.release(); | 126 return keyframeObject.release(); |
127 } | 127 } |
128 | 128 |
129 static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForStyleRule
Keyframes(const Animation& player, const StyleRuleKeyframes* keyframesRule) | 129 static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForStyleRule
Keyframes(const Animation& player, const StyleRuleKeyframes* keyframesRule) |
130 { | 130 { |
131 RefPtr<TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle> > keyframes
= TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle>::create(); | 131 RefPtr<TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle>> keyframes
= TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle>::create(); |
132 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleKeyframe> >& styleKeyfram
es = keyframesRule->keyframes(); | 132 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleKeyframe>>& styleKeyframe
s = keyframesRule->keyframes(); |
133 for (const auto& styleKeyframe : styleKeyframes) { | 133 for (const auto& styleKeyframe : styleKeyframes) { |
134 WillBeHeapVector<RefPtrWillBeMember<Keyframe>> normalizedKeyframes = Key
frameEffectModelBase::normalizedKeyframesForInspector(toKeyframeEffectModelBase(
toKeyframeEffect(player.source())->model())->getFrames()); | 134 HeapVector<Member<Keyframe>> normalizedKeyframes = KeyframeEffectModelBa
se::normalizedKeyframesForInspector(toKeyframeEffectModelBase(toKeyframeEffect(p
layer.source())->model())->getFrames()); |
135 TimingFunction* easing = nullptr; | 135 TimingFunction* easing = nullptr; |
136 for (const auto& keyframe : normalizedKeyframes) { | 136 for (const auto& keyframe : normalizedKeyframes) { |
137 if (styleKeyframe->keys().contains(keyframe->offset())) | 137 if (styleKeyframe->keys().contains(keyframe->offset())) |
138 easing = &keyframe->easing(); | 138 easing = &keyframe->easing(); |
139 } | 139 } |
140 ASSERT(easing); | 140 ASSERT(easing); |
141 keyframes->addItem(buildObjectForStyleRuleKeyframe(styleKeyframe.get(),
*easing)); | 141 keyframes->addItem(buildObjectForStyleRuleKeyframe(styleKeyframe.get(),
*easing)); |
142 } | 142 } |
143 | 143 |
144 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframesObject = TypeBuilder:
:Animation::KeyframesRule::create() | 144 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframesObject = TypeBuilder:
:Animation::KeyframesRule::create() |
145 .setKeyframes(keyframes); | 145 .setKeyframes(keyframes); |
146 keyframesObject->setName(keyframesRule->name()); | 146 keyframesObject->setName(keyframesRule->name()); |
147 return keyframesObject.release(); | 147 return keyframesObject.release(); |
148 } | 148 } |
149 | 149 |
150 static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForAnimation
Keyframes(const KeyframeEffect* animation) | 150 static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForAnimation
Keyframes(const KeyframeEffect* animation) |
151 { | 151 { |
152 if (!animation->model()->isKeyframeEffectModel()) | 152 if (!animation->model()->isKeyframeEffectModel()) |
153 return nullptr; | 153 return nullptr; |
154 const KeyframeEffectModelBase* model = toKeyframeEffectModelBase(animation->
model()); | 154 const KeyframeEffectModelBase* model = toKeyframeEffectModelBase(animation->
model()); |
155 WillBeHeapVector<RefPtrWillBeMember<Keyframe> > normalizedKeyframes = Keyfra
meEffectModelBase::normalizedKeyframesForInspector(model->getFrames()); | 155 HeapVector<Member<Keyframe>> normalizedKeyframes = KeyframeEffectModelBase::
normalizedKeyframesForInspector(model->getFrames()); |
156 RefPtr<TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle> > keyframes
= TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle>::create(); | 156 RefPtr<TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle>> keyframes
= TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle>::create(); |
157 | 157 |
158 for (const auto& keyframe : normalizedKeyframes) { | 158 for (const auto& keyframe : normalizedKeyframes) { |
159 // Ignore CSS Transitions | 159 // Ignore CSS Transitions |
160 if (!keyframe.get()->isStringKeyframe()) | 160 if (!keyframe.get()->isStringKeyframe()) |
161 continue; | 161 continue; |
162 const StringKeyframe* stringKeyframe = toStringKeyframe(keyframe.get()); | 162 const StringKeyframe* stringKeyframe = toStringKeyframe(keyframe.get()); |
163 keyframes->addItem(buildObjectForStringKeyframe(stringKeyframe)); | 163 keyframes->addItem(buildObjectForStringKeyframe(stringKeyframe)); |
164 } | 164 } |
165 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframesObject = TypeBuilder:
:Animation::KeyframesRule::create() | 165 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframesObject = TypeBuilder:
:Animation::KeyframesRule::create() |
166 .setKeyframes(keyframes); | 166 .setKeyframes(keyframes); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 .setPlaybackRate(player.playbackRate()) | 206 .setPlaybackRate(player.playbackRate()) |
207 .setStartTime(normalizedStartTime(player)) | 207 .setStartTime(normalizedStartTime(player)) |
208 .setCurrentTime(player.currentTime()) | 208 .setCurrentTime(player.currentTime()) |
209 .setSource(animationObject.release()) | 209 .setSource(animationObject.release()) |
210 .setType(animationType); | 210 .setType(animationType); |
211 return playerObject.release(); | 211 return playerObject.release(); |
212 } | 212 } |
213 | 213 |
214 PassRefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer>> Inspecto
rAnimationAgent::buildArrayForAnimations(Element& element, const WillBeHeapVecto
r<RefPtrWillBeMember<Animation>> players) | 214 PassRefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer>> Inspecto
rAnimationAgent::buildArrayForAnimations(Element& element, const WillBeHeapVecto
r<RefPtrWillBeMember<Animation>> players) |
215 { | 215 { |
216 RefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer> > animati
onPlayersArray = TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer>::cr
eate(); | 216 RefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer>> animatio
nPlayersArray = TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer>::cre
ate(); |
217 for (const auto& it : players) { | 217 for (const auto& it : players) { |
218 Animation& player = *(it.get()); | 218 Animation& player = *(it.get()); |
219 KeyframeEffect* animation = toKeyframeEffect(player.source()); | 219 KeyframeEffect* animation = toKeyframeEffect(player.source()); |
220 if (!element.contains(animation->target())) | 220 if (!element.contains(animation->target())) |
221 continue; | 221 continue; |
222 animationPlayersArray->addItem(buildObjectForAnimationPlayer(player)); | 222 animationPlayersArray->addItem(buildObjectForAnimationPlayer(player)); |
223 } | 223 } |
224 return animationPlayersArray.release(); | 224 return animationPlayersArray.release(); |
225 } | 225 } |
226 | 226 |
227 void InspectorAnimationAgent::getAnimationPlayersForNode(ErrorString* errorStrin
g, int nodeId, bool includeSubtreeAnimations, RefPtr<TypeBuilder::Array<TypeBuil
der::Animation::AnimationPlayer> >& animationPlayersArray) | 227 void InspectorAnimationAgent::getAnimationPlayersForNode(ErrorString* errorStrin
g, int nodeId, bool includeSubtreeAnimations, RefPtr<TypeBuilder::Array<TypeBuil
der::Animation::AnimationPlayer>>& animationPlayersArray) |
228 { | 228 { |
229 Element* element = m_domAgent->assertElement(errorString, nodeId); | 229 Element* element = m_domAgent->assertElement(errorString, nodeId); |
230 if (!element) | 230 if (!element) |
231 return; | 231 return; |
232 WillBeHeapVector<RefPtrWillBeMember<Animation>> players; | 232 WillBeHeapVector<RefPtrWillBeMember<Animation>> players; |
233 if (!includeSubtreeAnimations) | 233 if (!includeSubtreeAnimations) |
234 players = ElementAnimation::getAnimations(*element); | 234 players = ElementAnimation::getAnimations(*element); |
235 else | 235 else |
236 players = element->ownerDocument()->timeline().getAnimations(); | 236 players = element->ownerDocument()->timeline().getAnimations(); |
237 animationPlayersArray = buildArrayForAnimations(*element, players); | 237 animationPlayersArray = buildArrayForAnimations(*element, players); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 AnimationType type = m_idToAnimationType.get(playerId); | 270 AnimationType type = m_idToAnimationType.get(playerId); |
271 if (type == AnimationType::CSSTransition) { | 271 if (type == AnimationType::CSSTransition) { |
272 KeyframeEffect* effect = toKeyframeEffect(animation->source()); | 272 KeyframeEffect* effect = toKeyframeEffect(animation->source()); |
273 KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect->model
()); | 273 KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect->model
()); |
274 const AnimatableValueKeyframeEffectModel* oldModel = toAnimatableValueKe
yframeEffectModel(model); | 274 const AnimatableValueKeyframeEffectModel* oldModel = toAnimatableValueKe
yframeEffectModel(model); |
275 // Refer to CSSAnimations::calculateTransitionUpdateForProperty() for th
e structure of transitions. | 275 // Refer to CSSAnimations::calculateTransitionUpdateForProperty() for th
e structure of transitions. |
276 const KeyframeVector& frames = oldModel->getFrames(); | 276 const KeyframeVector& frames = oldModel->getFrames(); |
277 ASSERT(frames.size() == 3); | 277 ASSERT(frames.size() == 3); |
278 KeyframeVector newFrames; | 278 KeyframeVector newFrames; |
279 for (int i = 0; i < 3; i++) | 279 for (int i = 0; i < 3; i++) |
280 newFrames.append(toAnimatableValueKeyframe(frames[i]->clone().get())
); | 280 newFrames.append(toAnimatableValueKeyframe(frames[i]->clone())); |
281 // Update delay, represented by the distance between the first two keyfr
ames. | 281 // Update delay, represented by the distance between the first two keyfr
ames. |
282 newFrames[1]->setOffset(delay / (delay + duration)); | 282 newFrames[1]->setOffset(delay / (delay + duration)); |
283 model->setFrames(newFrames); | 283 model->setFrames(newFrames); |
284 | 284 |
285 RefPtrWillBeRawPtr<AnimationEffectTiming> timing = animation->source()->
timing(); | 285 AnimationEffectTiming* timing = animation->source()->timing(); |
286 UnrestrictedDoubleOrString unrestrictedDuration; | 286 UnrestrictedDoubleOrString unrestrictedDuration; |
287 unrestrictedDuration.setUnrestrictedDouble(duration + delay); | 287 unrestrictedDuration.setUnrestrictedDouble(duration + delay); |
288 timing->setDuration(unrestrictedDuration); | 288 timing->setDuration(unrestrictedDuration); |
289 } else if (type == AnimationType::WebAnimation) { | 289 } else if (type == AnimationType::WebAnimation) { |
290 RefPtrWillBeRawPtr<AnimationEffectTiming> timing = animation->source()->
timing(); | 290 AnimationEffectTiming* timing = animation->source()->timing(); |
291 UnrestrictedDoubleOrString unrestrictedDuration; | 291 UnrestrictedDoubleOrString unrestrictedDuration; |
292 unrestrictedDuration.setUnrestrictedDouble(duration); | 292 unrestrictedDuration.setUnrestrictedDouble(duration); |
293 timing->setDuration(unrestrictedDuration); | 293 timing->setDuration(unrestrictedDuration); |
294 timing->setDelay(delay); | 294 timing->setDelay(delay); |
295 } | 295 } |
296 } | 296 } |
297 | 297 |
298 void InspectorAnimationAgent::didCreateAnimation(Animation* player) | 298 void InspectorAnimationAgent::didCreateAnimation(Animation* player) |
299 { | 299 { |
300 const String& playerId = String::number(player->sequenceNumber()); | 300 const String& playerId = String::number(player->sequenceNumber()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 #if ENABLE(OILPAN) | 360 #if ENABLE(OILPAN) |
361 visitor->trace(m_pageAgent); | 361 visitor->trace(m_pageAgent); |
362 visitor->trace(m_domAgent); | 362 visitor->trace(m_domAgent); |
363 visitor->trace(m_idToAnimation); | 363 visitor->trace(m_idToAnimation); |
364 visitor->trace(m_idToAnimationType); | 364 visitor->trace(m_idToAnimationType); |
365 #endif | 365 #endif |
366 InspectorBaseAgent::trace(visitor); | 366 InspectorBaseAgent::trace(visitor); |
367 } | 367 } |
368 | 368 |
369 } | 369 } |
OLD | NEW |