Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.cpp

Issue 1417173002: Devtools Animations: Pause button based on groups not global (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.cpp
diff --git a/third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.cpp
index 40660649c2c1823aab3138c0638136e69ff817b6..2c50c360141bf9d443f25922491b1cadc193506a 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.cpp
@@ -201,9 +201,40 @@ void InspectorAnimationAgent::setPlaybackRate(ErrorString*, double playbackRate)
void InspectorAnimationAgent::getCurrentTime(ErrorString* errorString, const String& id, double* currentTime)
{
Animation* animation = assertAnimation(errorString, id);
+ if (!animation)
+ return;
if (m_idToAnimationClone.get(id))
animation = m_idToAnimationClone.get(id);
- *currentTime = animation->timeline()->currentTime() - animation->startTime();
+
+ if (animation->paused()) {
+ *currentTime = animation->currentTime();
+ } else {
+ // Use startTime where possible since currentTime is limited.
+ *currentTime = animation->timeline()->currentTime() - animation->startTime();
+ }
+}
+
+void InspectorAnimationAgent::setPaused(ErrorString* errorString, const RefPtr<JSONArray>& animationIds, bool paused)
+{
+ for (const auto& id : *animationIds) {
+ String animationId;
+ if (!(id->asString(&animationId))) {
+ *errorString = "Invalid argument type";
+ return;
+ }
+ Animation* animation = assertAnimation(errorString, animationId);
+ if (!animation)
+ return;
+ Animation* clone = animationClone(animation);
+ if (paused && !clone->paused()) {
+ // Ensure we restore a current time if the animation is limited.
+ double currentTime = animation->timeline()->currentTime() - animation->startTime();
+ clone->pause();
+ animation->setCurrentTime(currentTime);
+ } else if (!paused && clone->paused()) {
+ clone->unpause();
+ }
+ }
}
Animation* InspectorAnimationAgent::animationClone(Animation* animation)
@@ -212,9 +243,20 @@ Animation* InspectorAnimationAgent::animationClone(Animation* animation)
if (!m_idToAnimationClone.get(id)) {
KeyframeEffect* oldEffect = toKeyframeEffect(animation->effect());
KeyframeEffect* newEffect = KeyframeEffect::create(oldEffect->target(), oldEffect->model(), oldEffect->specifiedTiming());
+ m_isCloning = true;
Animation* clone = Animation::create(newEffect, animation->timeline());
+ m_isCloning = false;
m_idToAnimationClone.set(id, clone);
m_idToAnimation.set(String::number(clone->sequenceNumber()), clone);
+ clone->play();
+ clone->setStartTime(animation->startTime());
+
+ // TODO(samli): This shouldn't be necessary. The clone should override completely, but isn't, perhaps becaues the keyframe model is shared.
+ if (!animation->limited()) {
+ TrackExceptionState exceptionState;
+ animation->finish(exceptionState);
+ ASSERT(!exceptionState.hadException());
+ }
}
return m_idToAnimationClone.get(id);
}
@@ -230,10 +272,9 @@ void InspectorAnimationAgent::seekAnimations(ErrorString* errorString, const Ref
Animation* animation = assertAnimation(errorString, animationId);
if (!animation)
return;
- m_isCloning = true;
Animation* clone = animationClone(animation);
- m_isCloning = false;
- clone->play();
+ if (!clone->paused())
+ clone->play();
clone->setCurrentTime(currentTime);
}
}

Powered by Google App Engine
This is Rietveld 408576698