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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 ComputedTimingProperties computedTiming; | 75 ComputedTimingProperties computedTiming; |
76 effect->computedTiming(computedTiming); | 76 effect->computedTiming(computedTiming); |
77 double delay = computedTiming.delay(); | 77 double delay = computedTiming.delay(); |
78 double duration = computedTiming.duration().getAsUnrestrictedDouble(); | 78 double duration = computedTiming.duration().getAsUnrestrictedDouble(); |
79 String easing = effect->specifiedTiming().timingFunction->toString(); | 79 String easing = effect->specifiedTiming().timingFunction->toString(); |
80 | 80 |
81 if (isTransition) { | 81 if (isTransition) { |
82 // Obtain keyframes and convert keyframes back to delay | 82 // Obtain keyframes and convert keyframes back to delay |
83 ASSERT(effect->model()->isKeyframeEffectModel()); | 83 ASSERT(effect->model()->isKeyframeEffectModel()); |
84 const KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect-
>model()); | 84 const KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect-
>model()); |
85 WillBeHeapVector<RefPtrWillBeMember<Keyframe> > keyframes = KeyframeEffe
ctModelBase::normalizedKeyframesForInspector(model->getFrames()); | 85 HeapVector<Member<Keyframe>> keyframes = KeyframeEffectModelBase::normal
izedKeyframesForInspector(model->getFrames()); |
86 if (keyframes.size() == 3) { | 86 if (keyframes.size() == 3) { |
87 delay = keyframes.at(1)->offset() * duration; | 87 delay = keyframes.at(1)->offset() * duration; |
88 duration -= delay; | 88 duration -= delay; |
89 easing = keyframes.at(1)->easing().toString(); | 89 easing = keyframes.at(1)->easing().toString(); |
90 } else { | 90 } else { |
91 easing = keyframes.at(0)->easing().toString(); | 91 easing = keyframes.at(0)->easing().toString(); |
92 } | 92 } |
93 } | 93 } |
94 | 94 |
95 RefPtr<TypeBuilder::Animation::AnimationNode> animationObject = TypeBuilder:
:Animation::AnimationNode::create() | 95 RefPtr<TypeBuilder::Animation::AnimationNode> animationObject = TypeBuilder:
:Animation::AnimationNode::create() |
(...skipping 21 matching lines...) Expand all Loading... |
117 .setOffset(offset) | 117 .setOffset(offset) |
118 .setEasing(keyframe->easing().toString()); | 118 .setEasing(keyframe->easing().toString()); |
119 return keyframeObject.release(); | 119 return keyframeObject.release(); |
120 } | 120 } |
121 | 121 |
122 static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForAnimation
Keyframes(const KeyframeEffect* animation) | 122 static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForAnimation
Keyframes(const KeyframeEffect* animation) |
123 { | 123 { |
124 if (!animation->model()->isKeyframeEffectModel()) | 124 if (!animation->model()->isKeyframeEffectModel()) |
125 return nullptr; | 125 return nullptr; |
126 const KeyframeEffectModelBase* model = toKeyframeEffectModelBase(animation->
model()); | 126 const KeyframeEffectModelBase* model = toKeyframeEffectModelBase(animation->
model()); |
127 WillBeHeapVector<RefPtrWillBeMember<Keyframe> > normalizedKeyframes = Keyfra
meEffectModelBase::normalizedKeyframesForInspector(model->getFrames()); | 127 HeapVector<Member<Keyframe>> normalizedKeyframes = KeyframeEffectModelBase::
normalizedKeyframesForInspector(model->getFrames()); |
128 RefPtr<TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle> > keyframes
= TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle>::create(); | 128 RefPtr<TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle>> keyframes
= TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle>::create(); |
129 | 129 |
130 for (const auto& keyframe : normalizedKeyframes) { | 130 for (const auto& keyframe : normalizedKeyframes) { |
131 // Ignore CSS Transitions | 131 // Ignore CSS Transitions |
132 if (!keyframe.get()->isStringKeyframe()) | 132 if (!keyframe.get()->isStringKeyframe()) |
133 continue; | 133 continue; |
134 const StringKeyframe* stringKeyframe = toStringKeyframe(keyframe.get()); | 134 const StringKeyframe* stringKeyframe = toStringKeyframe(keyframe.get()); |
135 keyframes->addItem(buildObjectForStringKeyframe(stringKeyframe)); | 135 keyframes->addItem(buildObjectForStringKeyframe(stringKeyframe)); |
136 } | 136 } |
137 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframesObject = TypeBuilder:
:Animation::KeyframesRule::create() | 137 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframesObject = TypeBuilder:
:Animation::KeyframesRule::create() |
138 .setKeyframes(keyframes); | 138 .setKeyframes(keyframes); |
(...skipping 29 matching lines...) Expand all Loading... |
168 .setPausedState(player.paused()) | 168 .setPausedState(player.paused()) |
169 .setPlayState(player.playState()) | 169 .setPlayState(player.playState()) |
170 .setPlaybackRate(player.playbackRate()) | 170 .setPlaybackRate(player.playbackRate()) |
171 .setStartTime(normalizedStartTime(player)) | 171 .setStartTime(normalizedStartTime(player)) |
172 .setCurrentTime(player.currentTime()) | 172 .setCurrentTime(player.currentTime()) |
173 .setSource(animationObject.release()) | 173 .setSource(animationObject.release()) |
174 .setType(animationType); | 174 .setType(animationType); |
175 return playerObject.release(); | 175 return playerObject.release(); |
176 } | 176 } |
177 | 177 |
178 PassRefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer>> Inspecto
rAnimationAgent::buildArrayForAnimations(Element& element, const WillBeHeapVecto
r<RefPtrWillBeMember<Animation>> players) | 178 PassRefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer>> Inspecto
rAnimationAgent::buildArrayForAnimations(Element& element, const HeapVector<Memb
er<Animation>> players) |
179 { | 179 { |
180 RefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer> > animati
onPlayersArray = TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer>::cr
eate(); | 180 RefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer>> animatio
nPlayersArray = TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer>::cre
ate(); |
181 for (const auto& it : players) { | 181 for (const auto& it : players) { |
182 Animation& player = *(it.get()); | 182 Animation& player = *(it.get()); |
183 KeyframeEffect* animation = toKeyframeEffect(player.source()); | 183 KeyframeEffect* animation = toKeyframeEffect(player.source()); |
184 if (!element.contains(animation->target())) | 184 if (!element.contains(animation->target())) |
185 continue; | 185 continue; |
186 animationPlayersArray->addItem(buildObjectForAnimationPlayer(player)); | 186 animationPlayersArray->addItem(buildObjectForAnimationPlayer(player)); |
187 } | 187 } |
188 return animationPlayersArray.release(); | 188 return animationPlayersArray.release(); |
189 } | 189 } |
190 | 190 |
191 void InspectorAnimationAgent::getAnimationPlayersForNode(ErrorString* errorStrin
g, int nodeId, bool includeSubtreeAnimations, RefPtr<TypeBuilder::Array<TypeBuil
der::Animation::AnimationPlayer> >& animationPlayersArray) | 191 void InspectorAnimationAgent::getAnimationPlayersForNode(ErrorString* errorStrin
g, int nodeId, bool includeSubtreeAnimations, RefPtr<TypeBuilder::Array<TypeBuil
der::Animation::AnimationPlayer>>& animationPlayersArray) |
192 { | 192 { |
193 Element* element = m_domAgent->assertElement(errorString, nodeId); | 193 Element* element = m_domAgent->assertElement(errorString, nodeId); |
194 if (!element) | 194 if (!element) |
195 return; | 195 return; |
196 WillBeHeapVector<RefPtrWillBeMember<Animation>> players; | 196 HeapVector<Member<Animation>> players; |
197 if (!includeSubtreeAnimations) | 197 if (!includeSubtreeAnimations) |
198 players = ElementAnimation::getAnimations(*element); | 198 players = ElementAnimation::getAnimations(*element); |
199 else | 199 else |
200 players = element->ownerDocument()->timeline().getAnimations(); | 200 players = element->ownerDocument()->timeline().getAnimations(); |
201 animationPlayersArray = buildArrayForAnimations(*element, players); | 201 animationPlayersArray = buildArrayForAnimations(*element, players); |
202 } | 202 } |
203 | 203 |
204 void InspectorAnimationAgent::getPlaybackRate(ErrorString*, double* playbackRate
) | 204 void InspectorAnimationAgent::getPlaybackRate(ErrorString*, double* playbackRate
) |
205 { | 205 { |
206 *playbackRate = referenceTimeline().playbackRate(); | 206 *playbackRate = referenceTimeline().playbackRate(); |
(...skipping 27 matching lines...) Expand all Loading... |
234 AnimationType type = m_idToAnimationType.get(playerId); | 234 AnimationType type = m_idToAnimationType.get(playerId); |
235 if (type == AnimationType::CSSTransition) { | 235 if (type == AnimationType::CSSTransition) { |
236 KeyframeEffect* effect = toKeyframeEffect(animation->source()); | 236 KeyframeEffect* effect = toKeyframeEffect(animation->source()); |
237 KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect->model
()); | 237 KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect->model
()); |
238 const AnimatableValueKeyframeEffectModel* oldModel = toAnimatableValueKe
yframeEffectModel(model); | 238 const AnimatableValueKeyframeEffectModel* oldModel = toAnimatableValueKe
yframeEffectModel(model); |
239 // Refer to CSSAnimations::calculateTransitionUpdateForProperty() for th
e structure of transitions. | 239 // Refer to CSSAnimations::calculateTransitionUpdateForProperty() for th
e structure of transitions. |
240 const KeyframeVector& frames = oldModel->getFrames(); | 240 const KeyframeVector& frames = oldModel->getFrames(); |
241 ASSERT(frames.size() == 3); | 241 ASSERT(frames.size() == 3); |
242 KeyframeVector newFrames; | 242 KeyframeVector newFrames; |
243 for (int i = 0; i < 3; i++) | 243 for (int i = 0; i < 3; i++) |
244 newFrames.append(toAnimatableValueKeyframe(frames[i]->clone().get())
); | 244 newFrames.append(toAnimatableValueKeyframe(frames[i]->clone())); |
245 // Update delay, represented by the distance between the first two keyfr
ames. | 245 // Update delay, represented by the distance between the first two keyfr
ames. |
246 newFrames[1]->setOffset(delay / (delay + duration)); | 246 newFrames[1]->setOffset(delay / (delay + duration)); |
247 model->setFrames(newFrames); | 247 model->setFrames(newFrames); |
248 | 248 |
249 RefPtrWillBeRawPtr<AnimationEffectTiming> timing = animation->source()->
timing(); | 249 AnimationEffectTiming* timing = animation->source()->timing(); |
250 UnrestrictedDoubleOrString unrestrictedDuration; | 250 UnrestrictedDoubleOrString unrestrictedDuration; |
251 unrestrictedDuration.setUnrestrictedDouble(duration + delay); | 251 unrestrictedDuration.setUnrestrictedDouble(duration + delay); |
252 timing->setDuration(unrestrictedDuration); | 252 timing->setDuration(unrestrictedDuration); |
253 } else if (type == AnimationType::WebAnimation) { | 253 } else if (type == AnimationType::WebAnimation) { |
254 RefPtrWillBeRawPtr<AnimationEffectTiming> timing = animation->source()->
timing(); | 254 AnimationEffectTiming* timing = animation->source()->timing(); |
255 UnrestrictedDoubleOrString unrestrictedDuration; | 255 UnrestrictedDoubleOrString unrestrictedDuration; |
256 unrestrictedDuration.setUnrestrictedDouble(duration); | 256 unrestrictedDuration.setUnrestrictedDouble(duration); |
257 timing->setDuration(unrestrictedDuration); | 257 timing->setDuration(unrestrictedDuration); |
258 timing->setDelay(delay); | 258 timing->setDelay(delay); |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 void InspectorAnimationAgent::didCreateAnimation(Animation* player) | 262 void InspectorAnimationAgent::didCreateAnimation(Animation* player) |
263 { | 263 { |
264 const String& playerId = String::number(player->sequenceNumber()); | 264 const String& playerId = String::number(player->sequenceNumber()); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 #if ENABLE(OILPAN) | 319 #if ENABLE(OILPAN) |
320 visitor->trace(m_pageAgent); | 320 visitor->trace(m_pageAgent); |
321 visitor->trace(m_domAgent); | 321 visitor->trace(m_domAgent); |
322 visitor->trace(m_idToAnimation); | 322 visitor->trace(m_idToAnimation); |
323 visitor->trace(m_idToAnimationType); | 323 visitor->trace(m_idToAnimationType); |
324 #endif | 324 #endif |
325 InspectorBaseAgent::trace(visitor); | 325 InspectorBaseAgent::trace(visitor); |
326 } | 326 } |
327 | 327 |
328 } | 328 } |
OLD | NEW |