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/AnimationNode.h" | 11 #include "core/animation/AnimationEffectTiming.h" |
12 #include "core/animation/AnimationNodeTiming.h" | |
13 #include "core/animation/AnimationPlayer.h" | |
14 #include "core/animation/ComputedTimingProperties.h" | 12 #include "core/animation/ComputedTimingProperties.h" |
| 13 #include "core/animation/EffectModel.h" |
15 #include "core/animation/ElementAnimation.h" | 14 #include "core/animation/ElementAnimation.h" |
| 15 #include "core/animation/KeyframeEffect.h" |
16 #include "core/animation/KeyframeEffectModel.h" | 16 #include "core/animation/KeyframeEffectModel.h" |
17 #include "core/animation/StringKeyframe.h" | 17 #include "core/animation/StringKeyframe.h" |
18 #include "core/css/CSSKeyframeRule.h" | 18 #include "core/css/CSSKeyframeRule.h" |
19 #include "core/css/CSSKeyframesRule.h" | 19 #include "core/css/CSSKeyframesRule.h" |
20 #include "core/css/resolver/StyleResolver.h" | 20 #include "core/css/resolver/StyleResolver.h" |
21 #include "core/dom/DOMNodeIds.h" | 21 #include "core/dom/DOMNodeIds.h" |
22 #include "core/inspector/InspectorDOMAgent.h" | 22 #include "core/inspector/InspectorDOMAgent.h" |
23 #include "core/inspector/InspectorPageAgent.h" | 23 #include "core/inspector/InspectorPageAgent.h" |
24 #include "core/inspector/InspectorState.h" | 24 #include "core/inspector/InspectorState.h" |
25 #include "core/inspector/InspectorStyleSheet.h" | 25 #include "core/inspector/InspectorStyleSheet.h" |
(...skipping 24 matching lines...) Loading... |
50 void InspectorAnimationAgent::enable(ErrorString*) | 50 void InspectorAnimationAgent::enable(ErrorString*) |
51 { | 51 { |
52 m_state->setBoolean(AnimationAgentState::animationAgentEnabled, true); | 52 m_state->setBoolean(AnimationAgentState::animationAgentEnabled, true); |
53 m_instrumentingAgents->setInspectorAnimationAgent(this); | 53 m_instrumentingAgents->setInspectorAnimationAgent(this); |
54 } | 54 } |
55 | 55 |
56 void InspectorAnimationAgent::disable(ErrorString*) | 56 void InspectorAnimationAgent::disable(ErrorString*) |
57 { | 57 { |
58 m_state->setBoolean(AnimationAgentState::animationAgentEnabled, false); | 58 m_state->setBoolean(AnimationAgentState::animationAgentEnabled, false); |
59 m_instrumentingAgents->setInspectorAnimationAgent(nullptr); | 59 m_instrumentingAgents->setInspectorAnimationAgent(nullptr); |
60 m_idToAnimationPlayer.clear(); | 60 m_idToAnimation.clear(); |
61 m_idToAnimationType.clear(); | 61 m_idToAnimationType.clear(); |
62 } | 62 } |
63 | 63 |
64 void InspectorAnimationAgent::didCommitLoadForLocalFrame(LocalFrame* frame) | 64 void InspectorAnimationAgent::didCommitLoadForLocalFrame(LocalFrame* frame) |
65 { | 65 { |
66 if (frame == m_pageAgent->inspectedFrame()) { | 66 if (frame == m_pageAgent->inspectedFrame()) { |
67 m_idToAnimationPlayer.clear(); | 67 m_idToAnimation.clear(); |
68 m_idToAnimationType.clear(); | 68 m_idToAnimationType.clear(); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 static PassRefPtr<TypeBuilder::Animation::AnimationNode> buildObjectForAnimation
(Animation* animation, bool isTransition) | 72 static PassRefPtr<TypeBuilder::Animation::AnimationNode> buildObjectForAnimation
(KeyframeEffect* animation, bool isTransition) |
73 { | 73 { |
74 ComputedTimingProperties computedTiming; | 74 ComputedTimingProperties computedTiming; |
75 animation->computedTiming(computedTiming); | 75 animation->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 = animation->specifiedTiming().timingFunction->toString(); | 78 String easing = animation->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(animation->effect()->isKeyframeEffectModel()); | 82 ASSERT(animation->effect()->isKeyframeEffectModel()); |
(...skipping 36 matching lines...) Loading... |
119 Decimal decimal = Decimal::fromDouble(keyframe->offset() * 100); | 119 Decimal decimal = Decimal::fromDouble(keyframe->offset() * 100); |
120 String offset = decimal.toString(); | 120 String offset = decimal.toString(); |
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 AnimationPlayer& 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> >& styleKeyfram
es = keyframesRule->keyframes(); |
133 for (const auto& styleKeyframe : styleKeyframes) { | 133 for (const auto& styleKeyframe : styleKeyframes) { |
134 WillBeHeapVector<RefPtrWillBeMember<Keyframe> > normalizedKeyframes = Ke
yframeEffectModelBase::normalizedKeyframesForInspector(toKeyframeEffectModelBase
(toAnimation(player.source())->effect())->getFrames()); | 134 WillBeHeapVector<RefPtrWillBeMember<Keyframe>> normalizedKeyframes = Key
frameEffectModelBase::normalizedKeyframesForInspector(toKeyframeEffectModelBase(
toKeyframeEffect(player.source())->effect())->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 Animation* animation) | 150 static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForAnimation
Keyframes(const KeyframeEffect* animation) |
151 { | 151 { |
152 if (!animation->effect()->isKeyframeEffectModel()) | 152 if (!animation->effect()->isKeyframeEffectModel()) |
153 return nullptr; | 153 return nullptr; |
154 const KeyframeEffectModelBase* effect = toKeyframeEffectModelBase(animation-
>effect()); | 154 const KeyframeEffectModelBase* effect = toKeyframeEffectModelBase(animation-
>effect()); |
155 WillBeHeapVector<RefPtrWillBeMember<Keyframe> > normalizedKeyframes = Keyfra
meEffectModelBase::normalizedKeyframesForInspector(effect->getFrames()); | 155 WillBeHeapVector<RefPtrWillBeMember<Keyframe> > normalizedKeyframes = Keyfra
meEffectModelBase::normalizedKeyframesForInspector(effect->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); |
167 return keyframesObject.release(); | 167 return keyframesObject.release(); |
168 } | 168 } |
169 | 169 |
170 PassRefPtr<TypeBuilder::Animation::AnimationPlayer> InspectorAnimationAgent::bui
ldObjectForAnimationPlayer(AnimationPlayer& player) | 170 PassRefPtr<TypeBuilder::Animation::AnimationPlayer> InspectorAnimationAgent::bui
ldObjectForAnimationPlayer(Animation& player) |
171 { | 171 { |
172 // Find type of animation | 172 // Find type of animation |
173 const Element* element = toAnimation(player.source())->target(); | 173 const Element* element = toKeyframeEffect(player.source())->target(); |
174 StyleResolver& styleResolver = element->ownerDocument()->ensureStyleResolver
(); | 174 StyleResolver& styleResolver = element->ownerDocument()->ensureStyleResolver
(); |
175 CSSAnimations& cssAnimations = element->elementAnimations()->cssAnimations()
; | 175 CSSAnimations& cssAnimations = element->elementAnimations()->cssAnimations()
; |
176 const AtomicString animationName = cssAnimations.getAnimationNameForInspecto
r(player); | 176 const AtomicString animationName = cssAnimations.getAnimationNameForInspecto
r(player); |
177 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframeRule = nullptr; | 177 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframeRule = nullptr; |
178 AnimationType animationType; | 178 AnimationType animationType; |
179 | 179 |
180 if (!animationName.isNull()) { | 180 if (!animationName.isNull()) { |
181 // CSS Animations | 181 // CSS Animations |
182 const StyleRuleKeyframes* keyframes = styleResolver.findKeyframesRule(el
ement, animationName); | 182 const StyleRuleKeyframes* keyframes = styleResolver.findKeyframesRule(el
ement, animationName); |
183 keyframeRule = buildObjectForStyleRuleKeyframes(player, keyframes); | 183 keyframeRule = buildObjectForStyleRuleKeyframes(player, keyframes); |
184 animationType = AnimationType::CSSAnimation; | 184 animationType = AnimationType::CSSAnimation; |
185 } else if (cssAnimations.isTransitionAnimationForInspector(player)) { | 185 } else if (cssAnimations.isTransitionAnimationForInspector(player)) { |
186 // CSS Transitions | 186 // CSS Transitions |
187 animationType = AnimationType::CSSTransition; | 187 animationType = AnimationType::CSSTransition; |
188 } else { | 188 } else { |
189 // Web Animations | 189 // Web Animations |
190 keyframeRule = buildObjectForAnimationKeyframes(toAnimation(player.sourc
e())); | 190 keyframeRule = buildObjectForAnimationKeyframes(toKeyframeEffect(player.
source())); |
191 animationType = AnimationType::WebAnimation; | 191 animationType = AnimationType::WebAnimation; |
192 } | 192 } |
193 | 193 |
194 String id = String::number(player.sequenceNumber()); | 194 String id = String::number(player.sequenceNumber()); |
195 m_idToAnimationPlayer.set(id, &player); | 195 m_idToAnimation.set(id, &player); |
196 m_idToAnimationType.set(id, animationType); | 196 m_idToAnimationType.set(id, animationType); |
197 | 197 |
198 RefPtr<TypeBuilder::Animation::AnimationNode> animationObject = buildObjectF
orAnimation(toAnimation(player.source()), animationType == AnimationType::CSSTra
nsition); | 198 RefPtr<TypeBuilder::Animation::AnimationNode> animationObject = buildObjectF
orAnimation(toKeyframeEffect(player.source()), animationType == AnimationType::C
SSTransition); |
199 if (keyframeRule) | 199 if (keyframeRule) |
200 animationObject->setKeyframesRule(keyframeRule); | 200 animationObject->setKeyframesRule(keyframeRule); |
201 | 201 |
202 RefPtr<TypeBuilder::Animation::AnimationPlayer> playerObject = TypeBuilder::
Animation::AnimationPlayer::create() | 202 RefPtr<TypeBuilder::Animation::AnimationPlayer> playerObject = TypeBuilder::
Animation::AnimationPlayer::create() |
203 .setId(id) | 203 .setId(id) |
204 .setPausedState(player.paused()) | 204 .setPausedState(player.paused()) |
205 .setPlayState(player.playState()) | 205 .setPlayState(player.playState()) |
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> > Inspect
orAnimationAgent::buildArrayForAnimationPlayers(Element& element, const WillBeHe
apVector<RefPtrWillBeMember<AnimationPlayer> > 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> > animati
onPlayersArray = TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer>::cr
eate(); |
217 for (const auto& it : players) { | 217 for (const auto& it : players) { |
218 AnimationPlayer& player = *(it.get()); | 218 Animation& player = *(it.get()); |
219 Animation* animation = toAnimation(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<AnimationPlayer> > players; | 232 WillBeHeapVector<RefPtrWillBeMember<Animation>> players; |
233 if (!includeSubtreeAnimations) | 233 if (!includeSubtreeAnimations) |
234 players = ElementAnimation::getAnimationPlayers(*element); | 234 players = ElementAnimation::getAnimations(*element); |
235 else | 235 else |
236 players = element->ownerDocument()->timeline().getAnimationPlayers(); | 236 players = element->ownerDocument()->timeline().getAnimations(); |
237 animationPlayersArray = buildArrayForAnimationPlayers(*element, players); | 237 animationPlayersArray = buildArrayForAnimations(*element, players); |
238 } | 238 } |
239 | 239 |
240 void InspectorAnimationAgent::getPlaybackRate(ErrorString*, double* playbackRate
) | 240 void InspectorAnimationAgent::getPlaybackRate(ErrorString*, double* playbackRate
) |
241 { | 241 { |
242 *playbackRate = referenceTimeline().playbackRate(); | 242 *playbackRate = referenceTimeline().playbackRate(); |
243 } | 243 } |
244 | 244 |
245 void InspectorAnimationAgent::setPlaybackRate(ErrorString*, double playbackRate) | 245 void InspectorAnimationAgent::setPlaybackRate(ErrorString*, double playbackRate) |
246 { | 246 { |
247 for (Frame* frame = m_pageAgent->inspectedFrame(); frame; frame = frame->tre
e().traverseNext(m_pageAgent->inspectedFrame())) { | 247 for (Frame* frame = m_pageAgent->inspectedFrame(); frame; frame = frame->tre
e().traverseNext(m_pageAgent->inspectedFrame())) { |
248 if (frame->isLocalFrame()) | 248 if (frame->isLocalFrame()) |
249 toLocalFrame(frame)->document()->timeline().setPlaybackRate(playback
Rate); | 249 toLocalFrame(frame)->document()->timeline().setPlaybackRate(playback
Rate); |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 void InspectorAnimationAgent::setCurrentTime(ErrorString*, double currentTime) | 253 void InspectorAnimationAgent::setCurrentTime(ErrorString*, double currentTime) |
254 { | 254 { |
255 double timeDelta = currentTime - referenceTimeline().currentTime(); | 255 double timeDelta = currentTime - referenceTimeline().currentTime(); |
256 for (Frame* frame = m_pageAgent->inspectedFrame(); frame; frame = frame->tre
e().traverseNext(m_pageAgent->inspectedFrame())) { | 256 for (Frame* frame = m_pageAgent->inspectedFrame(); frame; frame = frame->tre
e().traverseNext(m_pageAgent->inspectedFrame())) { |
257 if (frame->isLocalFrame()) { | 257 if (frame->isLocalFrame()) { |
258 AnimationTimeline& timeline = toLocalFrame(frame)->document()->timel
ine(); | 258 AnimationTimeline& timeline = toLocalFrame(frame)->document()->timel
ine(); |
259 timeline.setCurrentTime(timeline.currentTime() + timeDelta); | 259 timeline.setCurrentTime(timeline.currentTime() + timeDelta); |
260 } | 260 } |
261 } | 261 } |
262 } | 262 } |
263 | 263 |
264 void InspectorAnimationAgent::setTiming(ErrorString* errorString, const String&
playerId, double duration, double delay) | 264 void InspectorAnimationAgent::setTiming(ErrorString* errorString, const String&
playerId, double duration, double delay) |
265 { | 265 { |
266 AnimationPlayer* player = assertAnimationPlayer(errorString, playerId); | 266 Animation* player = assertAnimation(errorString, playerId); |
267 if (!player) | 267 if (!player) |
268 return; | 268 return; |
269 | 269 |
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 Animation* animation = toAnimation(player->source()); | 272 KeyframeEffect* animation = toKeyframeEffect(player->source()); |
273 KeyframeEffectModelBase* effect = toKeyframeEffectModelBase(animation->e
ffect()); | 273 KeyframeEffectModelBase* effect = toKeyframeEffectModelBase(animation->e
ffect()); |
274 const AnimatableValueKeyframeEffectModel* oldEffect = toAnimatableValueK
eyframeEffectModel(effect); | 274 const AnimatableValueKeyframeEffectModel* oldEffect = toAnimatableValueK
eyframeEffectModel(effect); |
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 = oldEffect->getFrames(); | 276 const KeyframeVector& frames = oldEffect->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().get())
); |
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 effect->setFrames(newFrames); | 283 effect->setFrames(newFrames); |
284 | 284 |
285 RefPtrWillBeRawPtr<AnimationNodeTiming> timing = player->source()->timin
g(); | 285 RefPtrWillBeRawPtr<AnimationEffectTiming> timing = player->source()->tim
ing(); |
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<AnimationNodeTiming> timing = player->source()->timin
g(); | 290 RefPtrWillBeRawPtr<AnimationEffectTiming> timing = player->source()->tim
ing(); |
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::didCreateAnimationPlayer(AnimationPlayer* 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()); |
301 if (m_idToAnimationPlayer.get(playerId)) | 301 if (m_idToAnimation.get(playerId)) |
302 return; | 302 return; |
303 | 303 |
304 // Check threshold | 304 // Check threshold |
305 double latestStartTime = 0; | 305 double latestStartTime = 0; |
306 for (const auto& p : m_idToAnimationPlayer.values()) | 306 for (const auto& p : m_idToAnimation.values()) |
307 latestStartTime = max(latestStartTime, normalizedStartTime(*p)); | 307 latestStartTime = max(latestStartTime, normalizedStartTime(*p)); |
308 | 308 |
309 bool reset = false; | 309 bool reset = false; |
310 const double threshold = 1000; | 310 const double threshold = 1000; |
311 if (normalizedStartTime(*player) - latestStartTime > threshold) { | 311 if (normalizedStartTime(*player) - latestStartTime > threshold) { |
312 reset = true; | 312 reset = true; |
313 m_idToAnimationPlayer.clear(); | 313 m_idToAnimation.clear(); |
314 m_idToAnimationType.clear(); | 314 m_idToAnimationType.clear(); |
315 } | 315 } |
316 | 316 |
317 frontend()->animationPlayerCreated(buildObjectForAnimationPlayer(*player), r
eset); | 317 frontend()->animationPlayerCreated(buildObjectForAnimationPlayer(*player), r
eset); |
318 } | 318 } |
319 | 319 |
320 void InspectorAnimationAgent::didCancelAnimationPlayer(AnimationPlayer* player) | 320 void InspectorAnimationAgent::didCancelAnimation(Animation* player) |
321 { | 321 { |
322 const String& playerId = String::number(player->sequenceNumber()); | 322 const String& playerId = String::number(player->sequenceNumber()); |
323 if (!m_idToAnimationPlayer.get(playerId)) | 323 if (!m_idToAnimation.get(playerId)) |
324 return; | 324 return; |
325 frontend()->animationPlayerCanceled(playerId); | 325 frontend()->animationPlayerCanceled(playerId); |
326 } | 326 } |
327 | 327 |
328 void InspectorAnimationAgent::didClearDocumentOfWindowObject(LocalFrame* frame) | 328 void InspectorAnimationAgent::didClearDocumentOfWindowObject(LocalFrame* frame) |
329 { | 329 { |
330 if (!m_state->getBoolean(AnimationAgentState::animationAgentEnabled)) | 330 if (!m_state->getBoolean(AnimationAgentState::animationAgentEnabled)) |
331 return; | 331 return; |
332 ASSERT(frame->document()); | 332 ASSERT(frame->document()); |
333 frame->document()->timeline().setPlaybackRate(referenceTimeline().playbackRa
te()); | 333 frame->document()->timeline().setPlaybackRate(referenceTimeline().playbackRa
te()); |
334 } | 334 } |
335 | 335 |
336 AnimationPlayer* InspectorAnimationAgent::assertAnimationPlayer(ErrorString* err
orString, const String& id) | 336 Animation* InspectorAnimationAgent::assertAnimation(ErrorString* errorString, co
nst String& id) |
337 { | 337 { |
338 AnimationPlayer* player = m_idToAnimationPlayer.get(id); | 338 Animation* player = m_idToAnimation.get(id); |
339 if (!player) { | 339 if (!player) { |
340 *errorString = "Could not find animation player with given id"; | 340 *errorString = "Could not find animation player with given id"; |
341 return nullptr; | 341 return nullptr; |
342 } | 342 } |
343 return player; | 343 return player; |
344 } | 344 } |
345 | 345 |
346 AnimationTimeline& InspectorAnimationAgent::referenceTimeline() | 346 AnimationTimeline& InspectorAnimationAgent::referenceTimeline() |
347 { | 347 { |
348 return m_pageAgent->inspectedFrame()->document()->timeline(); | 348 return m_pageAgent->inspectedFrame()->document()->timeline(); |
349 } | 349 } |
350 | 350 |
351 double InspectorAnimationAgent::normalizedStartTime(AnimationPlayer& player) | 351 double InspectorAnimationAgent::normalizedStartTime(Animation& player) |
352 { | 352 { |
353 if (referenceTimeline().playbackRate() == 0) | 353 if (referenceTimeline().playbackRate() == 0) |
354 return player.startTime() + referenceTimeline().currentTime() - player.t
imeline()->currentTime(); | 354 return player.startTime() + referenceTimeline().currentTime() - player.t
imeline()->currentTime(); |
355 return player.startTime() + (player.timeline()->zeroTime() - referenceTimeli
ne().zeroTime()) * 1000 * referenceTimeline().playbackRate(); | 355 return player.startTime() + (player.timeline()->zeroTime() - referenceTimeli
ne().zeroTime()) * 1000 * referenceTimeline().playbackRate(); |
356 } | 356 } |
357 | 357 |
358 DEFINE_TRACE(InspectorAnimationAgent) | 358 DEFINE_TRACE(InspectorAnimationAgent) |
359 { | 359 { |
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_idToAnimationPlayer); | 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 |