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