| 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/AnimationNode.h" |
| 12 #include "core/animation/AnimationNodeTiming.h" | 12 #include "core/animation/AnimationNodeTiming.h" |
| 13 #include "core/animation/AnimationPlayer.h" | 13 #include "core/animation/AnimationPlayer.h" |
| 14 #include "core/animation/ComputedTimingProperties.h" | 14 #include "core/animation/ComputedTimingProperties.h" |
| 15 #include "core/animation/ElementAnimation.h" | 15 #include "core/animation/ElementAnimation.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" | |
| 24 #include "core/inspector/InspectorState.h" | 23 #include "core/inspector/InspectorState.h" |
| 25 #include "core/inspector/InspectorStyleSheet.h" | 24 #include "core/inspector/InspectorStyleSheet.h" |
| 26 #include "platform/Decimal.h" | 25 #include "platform/Decimal.h" |
| 27 #include "platform/animation/TimingFunction.h" | 26 #include "platform/animation/TimingFunction.h" |
| 28 | 27 |
| 29 namespace AnimationAgentState { | 28 namespace AnimationAgentState { |
| 30 static const char animationAgentEnabled[] = "animationAgentEnabled"; | 29 static const char animationAgentEnabled[] = "animationAgentEnabled"; |
| 31 } | 30 } |
| 32 | 31 |
| 33 namespace blink { | 32 namespace blink { |
| 34 | 33 |
| 35 InspectorAnimationAgent::InspectorAnimationAgent(InspectorPageAgent* pageAgent,
InspectorDOMAgent* domAgent) | 34 InspectorAnimationAgent::InspectorAnimationAgent(LocalFrame* inspectedFrame, Ins
pectorDOMAgent* domAgent) |
| 36 : InspectorBaseAgent<InspectorAnimationAgent, InspectorFrontend::Animation>(
"Animation") | 35 : InspectorBaseAgent<InspectorAnimationAgent, InspectorFrontend::Animation>(
"Animation") |
| 37 , m_pageAgent(pageAgent) | 36 , m_inspectedFrame(inspectedFrame) |
| 38 , m_domAgent(domAgent) | 37 , m_domAgent(domAgent) |
| 39 { | 38 { |
| 40 } | 39 } |
| 41 | 40 |
| 42 void InspectorAnimationAgent::restore() | 41 void InspectorAnimationAgent::restore() |
| 43 { | 42 { |
| 44 if (m_state->getBoolean(AnimationAgentState::animationAgentEnabled)) { | 43 if (m_state->getBoolean(AnimationAgentState::animationAgentEnabled)) { |
| 45 ErrorString error; | 44 ErrorString error; |
| 46 enable(&error); | 45 enable(&error); |
| 47 } | 46 } |
| 48 } | 47 } |
| 49 | 48 |
| 50 void InspectorAnimationAgent::enable(ErrorString*) | 49 void InspectorAnimationAgent::enable(ErrorString*) |
| 51 { | 50 { |
| 52 m_state->setBoolean(AnimationAgentState::animationAgentEnabled, true); | 51 m_state->setBoolean(AnimationAgentState::animationAgentEnabled, true); |
| 53 m_instrumentingAgents->setInspectorAnimationAgent(this); | 52 m_instrumentingAgents->setInspectorAnimationAgent(this); |
| 54 } | 53 } |
| 55 | 54 |
| 56 void InspectorAnimationAgent::disable(ErrorString*) | 55 void InspectorAnimationAgent::disable(ErrorString*) |
| 57 { | 56 { |
| 58 m_state->setBoolean(AnimationAgentState::animationAgentEnabled, false); | 57 m_state->setBoolean(AnimationAgentState::animationAgentEnabled, false); |
| 59 m_instrumentingAgents->setInspectorAnimationAgent(nullptr); | 58 m_instrumentingAgents->setInspectorAnimationAgent(nullptr); |
| 60 m_idToAnimationPlayer.clear(); | 59 m_idToAnimationPlayer.clear(); |
| 61 m_idToAnimationType.clear(); | 60 m_idToAnimationType.clear(); |
| 62 } | 61 } |
| 63 | 62 |
| 64 void InspectorAnimationAgent::didCommitLoadForLocalFrame(LocalFrame* frame) | 63 void InspectorAnimationAgent::didCommitLoadForLocalFrame(LocalFrame* frame) |
| 65 { | 64 { |
| 66 if (frame == m_pageAgent->inspectedFrame()) { | 65 if (frame == m_inspectedFrame) { |
| 67 m_idToAnimationPlayer.clear(); | 66 m_idToAnimationPlayer.clear(); |
| 68 m_idToAnimationType.clear(); | 67 m_idToAnimationType.clear(); |
| 69 } | 68 } |
| 70 } | 69 } |
| 71 | 70 |
| 72 static PassRefPtr<TypeBuilder::Animation::AnimationNode> buildObjectForAnimation
(Animation* animation, bool isTransition) | 71 static PassRefPtr<TypeBuilder::Animation::AnimationNode> buildObjectForAnimation
(Animation* animation, bool isTransition) |
| 73 { | 72 { |
| 74 ComputedTimingProperties computedTiming; | 73 ComputedTimingProperties computedTiming; |
| 75 animation->computedTiming(computedTiming); | 74 animation->computedTiming(computedTiming); |
| 76 double delay = computedTiming.delay(); | 75 double delay = computedTiming.delay(); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 animationPlayersArray = buildArrayForAnimationPlayers(*element, players); | 236 animationPlayersArray = buildArrayForAnimationPlayers(*element, players); |
| 238 } | 237 } |
| 239 | 238 |
| 240 void InspectorAnimationAgent::getPlaybackRate(ErrorString*, double* playbackRate
) | 239 void InspectorAnimationAgent::getPlaybackRate(ErrorString*, double* playbackRate
) |
| 241 { | 240 { |
| 242 *playbackRate = referenceTimeline().playbackRate(); | 241 *playbackRate = referenceTimeline().playbackRate(); |
| 243 } | 242 } |
| 244 | 243 |
| 245 void InspectorAnimationAgent::setPlaybackRate(ErrorString*, double playbackRate) | 244 void InspectorAnimationAgent::setPlaybackRate(ErrorString*, double playbackRate) |
| 246 { | 245 { |
| 247 for (Frame* frame = m_pageAgent->inspectedFrame(); frame; frame = frame->tre
e().traverseNext(m_pageAgent->inspectedFrame())) { | 246 for (Frame* frame = m_inspectedFrame; frame; frame = frame->tree().traverseN
ext(m_inspectedFrame)) { |
| 248 if (frame->isLocalFrame()) | 247 if (frame->isLocalFrame()) |
| 249 toLocalFrame(frame)->document()->timeline().setPlaybackRate(playback
Rate); | 248 toLocalFrame(frame)->document()->timeline().setPlaybackRate(playback
Rate); |
| 250 } | 249 } |
| 251 } | 250 } |
| 252 | 251 |
| 253 void InspectorAnimationAgent::setCurrentTime(ErrorString*, double currentTime) | 252 void InspectorAnimationAgent::setCurrentTime(ErrorString*, double currentTime) |
| 254 { | 253 { |
| 255 double timeDelta = currentTime - referenceTimeline().currentTime(); | 254 double timeDelta = currentTime - referenceTimeline().currentTime(); |
| 256 for (Frame* frame = m_pageAgent->inspectedFrame(); frame; frame = frame->tre
e().traverseNext(m_pageAgent->inspectedFrame())) { | 255 for (Frame* frame = m_inspectedFrame; frame; frame = frame->tree().traverseN
ext(m_inspectedFrame)) { |
| 257 if (frame->isLocalFrame()) { | 256 if (frame->isLocalFrame()) { |
| 258 AnimationTimeline& timeline = toLocalFrame(frame)->document()->timel
ine(); | 257 AnimationTimeline& timeline = toLocalFrame(frame)->document()->timel
ine(); |
| 259 timeline.setCurrentTime(timeline.currentTime() + timeDelta); | 258 timeline.setCurrentTime(timeline.currentTime() + timeDelta); |
| 260 } | 259 } |
| 261 } | 260 } |
| 262 } | 261 } |
| 263 | 262 |
| 264 void InspectorAnimationAgent::setTiming(ErrorString* errorString, const String&
playerId, double duration, double delay) | 263 void InspectorAnimationAgent::setTiming(ErrorString* errorString, const String&
playerId, double duration, double delay) |
| 265 { | 264 { |
| 266 AnimationPlayer* player = assertAnimationPlayer(errorString, playerId); | 265 AnimationPlayer* player = assertAnimationPlayer(errorString, playerId); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 AnimationPlayer* player = m_idToAnimationPlayer.get(id); | 337 AnimationPlayer* player = m_idToAnimationPlayer.get(id); |
| 339 if (!player) { | 338 if (!player) { |
| 340 *errorString = "Could not find animation player with given id"; | 339 *errorString = "Could not find animation player with given id"; |
| 341 return nullptr; | 340 return nullptr; |
| 342 } | 341 } |
| 343 return player; | 342 return player; |
| 344 } | 343 } |
| 345 | 344 |
| 346 AnimationTimeline& InspectorAnimationAgent::referenceTimeline() | 345 AnimationTimeline& InspectorAnimationAgent::referenceTimeline() |
| 347 { | 346 { |
| 348 return m_pageAgent->inspectedFrame()->document()->timeline(); | 347 return m_inspectedFrame->document()->timeline(); |
| 349 } | 348 } |
| 350 | 349 |
| 351 double InspectorAnimationAgent::normalizedStartTime(AnimationPlayer& player) | 350 double InspectorAnimationAgent::normalizedStartTime(AnimationPlayer& player) |
| 352 { | 351 { |
| 353 if (referenceTimeline().playbackRate() == 0) | 352 if (referenceTimeline().playbackRate() == 0) |
| 354 return player.startTime() + referenceTimeline().currentTime() - player.t
imeline()->currentTime(); | 353 return player.startTime() + referenceTimeline().currentTime() - player.t
imeline()->currentTime(); |
| 355 return player.startTime() + (player.timeline()->zeroTime() - referenceTimeli
ne().zeroTime()) * 1000 * referenceTimeline().playbackRate(); | 354 return player.startTime() + (player.timeline()->zeroTime() - referenceTimeli
ne().zeroTime()) * 1000 * referenceTimeline().playbackRate(); |
| 356 } | 355 } |
| 357 | 356 |
| 358 DEFINE_TRACE(InspectorAnimationAgent) | 357 DEFINE_TRACE(InspectorAnimationAgent) |
| 359 { | 358 { |
| 360 #if ENABLE(OILPAN) | 359 #if ENABLE(OILPAN) |
| 361 visitor->trace(m_pageAgent); | 360 visitor->trace(m_inspectedFrame); |
| 362 visitor->trace(m_domAgent); | 361 visitor->trace(m_domAgent); |
| 363 visitor->trace(m_idToAnimationPlayer); | 362 visitor->trace(m_idToAnimationPlayer); |
| 364 visitor->trace(m_idToAnimationType); | 363 visitor->trace(m_idToAnimationType); |
| 365 #endif | 364 #endif |
| 366 InspectorBaseAgent::trace(visitor); | 365 InspectorBaseAgent::trace(visitor); |
| 367 } | 366 } |
| 368 | 367 |
| 369 } | 368 } |
| OLD | NEW |