| 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 25 matching lines...) Expand all Loading... |
| 36 void InspectorAnimationAgent::clearFrontend() | 36 void InspectorAnimationAgent::clearFrontend() |
| 37 { | 37 { |
| 38 m_frontend = nullptr; | 38 m_frontend = nullptr; |
| 39 } | 39 } |
| 40 | 40 |
| 41 void InspectorAnimationAgent::reset() | 41 void InspectorAnimationAgent::reset() |
| 42 { | 42 { |
| 43 m_idToAnimationPlayer.clear(); | 43 m_idToAnimationPlayer.clear(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 static PassRefPtr<TypeBuilder::Animation::AnimationNode> buildObjectForAnimation
Node(AnimationNode* animationNode) | 46 PassRefPtr<TypeBuilder::Animation::AnimationNode> InspectorAnimationAgent::build
ObjectForAnimationNode(AnimationNode* animationNode) |
| 47 { | 47 { |
| 48 RefPtr<TypeBuilder::Animation::AnimationNode> animationObject = TypeBuilder:
:Animation::AnimationNode::create() | 48 RefPtr<TypeBuilder::Animation::AnimationNode> animationObject = TypeBuilder:
:Animation::AnimationNode::create() |
| 49 .setStartDelay(animationNode->specifiedTiming().startDelay) | 49 .setStartDelay(animationNode->specifiedTiming().startDelay) |
| 50 .setPlaybackRate(animationNode->specifiedTiming().playbackRate) | 50 .setPlaybackRate(animationNode->specifiedTiming().playbackRate) |
| 51 .setIterationStart(animationNode->specifiedTiming().iterationStart) | 51 .setIterationStart(animationNode->specifiedTiming().iterationStart) |
| 52 .setIterationCount(animationNode->specifiedTiming().iterationCount) | 52 .setIterationCount(animationNode->specifiedTiming().iterationCount) |
| 53 .setDuration(animationNode->duration()) | 53 .setDuration(animationNode->duration()) |
| 54 .setDirection(animationNode->specifiedTiming().direction) | 54 .setDirection(animationNode->specifiedTiming().direction) |
| 55 .setFillMode(animationNode->specifiedTiming().fillMode) | 55 .setFillMode(animationNode->specifiedTiming().fillMode) |
| 56 .setTimeFraction(animationNode->timeFraction()) | 56 .setTimeFraction(animationNode->timeFraction()) |
| 57 .setName(animationNode->name()); | 57 .setName(animationNode->name()) |
| 58 .setNode(m_domAgent->pushNodePathToFrontend(toAnimation(animationNode)->
target())); |
| 58 return animationObject.release(); | 59 return animationObject.release(); |
| 59 } | 60 } |
| 60 | 61 |
| 61 static String playerId(AnimationPlayer& player) | 62 static String playerId(AnimationPlayer& player) |
| 62 { | 63 { |
| 63 return String::number(player.sequenceNumber()); | 64 return String::number(player.sequenceNumber()); |
| 64 } | 65 } |
| 65 | 66 |
| 66 static PassRefPtr<TypeBuilder::Animation::AnimationPlayer> buildObjectForAnimati
onPlayer(AnimationPlayer& animationPlayer, PassRefPtr<TypeBuilder::Animation::Ke
yframesRule> keyframeRule = nullptr) | 67 PassRefPtr<TypeBuilder::Animation::AnimationPlayer> InspectorAnimationAgent::bui
ldObjectForAnimationPlayer(AnimationPlayer& animationPlayer, PassRefPtr<TypeBuil
der::Animation::KeyframesRule> keyframeRule) |
| 67 { | 68 { |
| 68 RefPtr<TypeBuilder::Animation::AnimationNode> animationObject = buildObjectF
orAnimationNode(animationPlayer.source()); | 69 RefPtr<TypeBuilder::Animation::AnimationNode> animationObject = buildObjectF
orAnimationNode(animationPlayer.source()); |
| 69 if (keyframeRule) | 70 if (keyframeRule) |
| 70 animationObject->setKeyframesRule(keyframeRule); | 71 animationObject->setKeyframesRule(keyframeRule); |
| 71 | 72 |
| 72 RefPtr<TypeBuilder::Animation::AnimationPlayer> playerObject = TypeBuilder::
Animation::AnimationPlayer::create() | 73 RefPtr<TypeBuilder::Animation::AnimationPlayer> playerObject = TypeBuilder::
Animation::AnimationPlayer::create() |
| 73 .setId(playerId(animationPlayer)) | 74 .setId(playerId(animationPlayer)) |
| 74 .setPausedState(animationPlayer.paused()) | 75 .setPausedState(animationPlayer.paused()) |
| 75 .setPlayState(animationPlayer.playState()) | 76 .setPlayState(animationPlayer.playState()) |
| 76 .setPlaybackRate(animationPlayer.playbackRate()) | 77 .setPlaybackRate(animationPlayer.playbackRate()) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 if (!keyframe.get()->isStringKeyframe()) | 129 if (!keyframe.get()->isStringKeyframe()) |
| 129 continue; | 130 continue; |
| 130 const StringKeyframe* stringKeyframe = toStringKeyframe(keyframe.get()); | 131 const StringKeyframe* stringKeyframe = toStringKeyframe(keyframe.get()); |
| 131 keyframes->addItem(buildObjectForStringKeyframe(stringKeyframe)); | 132 keyframes->addItem(buildObjectForStringKeyframe(stringKeyframe)); |
| 132 } | 133 } |
| 133 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframesObject = TypeBuilder:
:Animation::KeyframesRule::create() | 134 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframesObject = TypeBuilder:
:Animation::KeyframesRule::create() |
| 134 .setKeyframes(keyframes); | 135 .setKeyframes(keyframes); |
| 135 return keyframesObject.release(); | 136 return keyframesObject.release(); |
| 136 } | 137 } |
| 137 | 138 |
| 138 static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForKeyframes
Rule(const Element& element, const AnimationPlayer& player) | 139 static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForKeyframes
Rule(const AnimationPlayer& player) |
| 139 { | 140 { |
| 140 StyleResolver& styleResolver = element.ownerDocument()->ensureStyleResolver(
); | 141 const Element* element = toAnimation(player.source())->target(); |
| 141 CSSAnimations& cssAnimations = element.activeAnimations()->cssAnimations(); | 142 StyleResolver& styleResolver = element->ownerDocument()->ensureStyleResolver
(); |
| 143 CSSAnimations& cssAnimations = element->activeAnimations()->cssAnimations(); |
| 142 const AtomicString animationName = cssAnimations.getAnimationNameForInspecto
r(player); | 144 const AtomicString animationName = cssAnimations.getAnimationNameForInspecto
r(player); |
| 143 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframeRule; | 145 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframeRule; |
| 144 | 146 |
| 145 if (!animationName.isNull()) { | 147 if (!animationName.isNull()) { |
| 146 // CSS Animations | 148 // CSS Animations |
| 147 const StyleRuleKeyframes* keyframes = cssAnimations.matchScopedKeyframes
Rule(&styleResolver, &element, animationName.impl()); | 149 const StyleRuleKeyframes* keyframes = cssAnimations.matchScopedKeyframes
Rule(&styleResolver, element, animationName.impl()); |
| 148 keyframeRule = buildObjectForStyleRuleKeyframes(keyframes); | 150 keyframeRule = buildObjectForStyleRuleKeyframes(keyframes); |
| 149 } else { | 151 } else { |
| 150 // Web Animations | 152 // Web Animations |
| 151 keyframeRule = buildObjectForAnimationKeyframes(toAnimation(player.sourc
e())); | 153 keyframeRule = buildObjectForAnimationKeyframes(toAnimation(player.sourc
e())); |
| 152 } | 154 } |
| 153 | 155 |
| 154 return keyframeRule; | 156 return keyframeRule; |
| 155 } | 157 } |
| 156 | 158 |
| 157 void InspectorAnimationAgent::getAnimationPlayersForNode(ErrorString* errorStrin
g, int nodeId, RefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer
> >& animationPlayersArray) | 159 PassRefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer> > Inspect
orAnimationAgent::buildArrayForAnimationPlayers(Element& element, const WillBeHe
apVector<RefPtrWillBeMember<AnimationPlayer> > players, bool includeSubtreeAnima
tions) |
| 158 { | 160 { |
| 159 animationPlayersArray = TypeBuilder::Array<TypeBuilder::Animation::Animation
Player>::create(); | 161 RefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer> > animati
onPlayersArray = TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer>::cr
eate(); |
| 162 for (const auto& it : players) { |
| 163 AnimationPlayer& player = *(it.get()); |
| 164 Animation* animation = toAnimation(player.source()); |
| 165 if (includeSubtreeAnimations && !element.contains(animation->target())) |
| 166 continue; |
| 167 m_idToAnimationPlayer.set(playerId(player), &player); |
| 168 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframeRule = buildObject
ForKeyframesRule(player); |
| 169 animationPlayersArray->addItem(buildObjectForAnimationPlayer(player, key
frameRule)); |
| 170 } |
| 171 return animationPlayersArray.release(); |
| 172 } |
| 173 |
| 174 void InspectorAnimationAgent::getAnimationPlayersForNode(ErrorString* errorStrin
g, int nodeId, bool includeSubtreeAnimations, RefPtr<TypeBuilder::Array<TypeBuil
der::Animation::AnimationPlayer> >& animationPlayersArray) |
| 175 { |
| 160 Element* element = m_domAgent->assertElement(errorString, nodeId); | 176 Element* element = m_domAgent->assertElement(errorString, nodeId); |
| 161 if (!element) | 177 if (!element) |
| 162 return; | 178 return; |
| 163 m_idToAnimationPlayer.clear(); | 179 m_idToAnimationPlayer.clear(); |
| 164 WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> > players = ElementAnim
ation::getAnimationPlayers(*element); | 180 WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer>> players; |
| 165 for (WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> >::iterator it = p
layers.begin(); it != players.end(); ++it) { | 181 if (!includeSubtreeAnimations) |
| 166 AnimationPlayer& player = *(it->get()); | 182 players = ElementAnimation::getAnimationPlayers(*element); |
| 167 m_idToAnimationPlayer.set(playerId(player), &player); | 183 else |
| 168 RefPtr<TypeBuilder::Animation::KeyframesRule> keyframeRule = buildObject
ForKeyframesRule(*element, player); | 184 players = element->ownerDocument()->timeline().getAnimationPlayers(); |
| 169 animationPlayersArray->addItem(buildObjectForAnimationPlayer(player, key
frameRule)); | 185 animationPlayersArray = buildArrayForAnimationPlayers(*element, players, inc
ludeSubtreeAnimations); |
| 170 } | |
| 171 } | 186 } |
| 172 | 187 |
| 173 void InspectorAnimationAgent::pauseAnimationPlayer(ErrorString* errorString, con
st String& id, RefPtr<TypeBuilder::Animation::AnimationPlayer>& animationPlayer) | 188 void InspectorAnimationAgent::pauseAnimationPlayer(ErrorString* errorString, con
st String& id, RefPtr<TypeBuilder::Animation::AnimationPlayer>& animationPlayer) |
| 174 { | 189 { |
| 175 AnimationPlayer* player = assertAnimationPlayer(errorString, id); | 190 AnimationPlayer* player = assertAnimationPlayer(errorString, id); |
| 176 if (!player) | 191 if (!player) |
| 177 return; | 192 return; |
| 178 player->pause(); | 193 player->pause(); |
| 179 animationPlayer = buildObjectForAnimationPlayer(*player); | 194 animationPlayer = buildObjectForAnimationPlayer(*player); |
| 180 } | 195 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 void InspectorAnimationAgent::trace(Visitor* visitor) | 234 void InspectorAnimationAgent::trace(Visitor* visitor) |
| 220 { | 235 { |
| 221 #if ENABLE(OILPAN) | 236 #if ENABLE(OILPAN) |
| 222 visitor->trace(m_idToAnimationPlayer); | 237 visitor->trace(m_idToAnimationPlayer); |
| 223 visitor->trace(m_domAgent); | 238 visitor->trace(m_domAgent); |
| 224 #endif | 239 #endif |
| 225 InspectorBaseAgent::trace(visitor); | 240 InspectorBaseAgent::trace(visitor); |
| 226 } | 241 } |
| 227 | 242 |
| 228 } | 243 } |
| OLD | NEW |