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