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

Unified Diff: Source/devtools/front_end/elements/AnimationTimeline.js

Issue 1042143005: Devtools Animations: Support multiple frames in the animation timeline (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Test Created 5 years, 9 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: Source/devtools/front_end/elements/AnimationTimeline.js
diff --git a/Source/devtools/front_end/elements/AnimationTimeline.js b/Source/devtools/front_end/elements/AnimationTimeline.js
index b8c496a74ba361ade64c588bb80aea30271c2c08..9b4d7fd4421d44ed859727a29aa2b79bc33e7471 100644
--- a/Source/devtools/front_end/elements/AnimationTimeline.js
+++ b/Source/devtools/front_end/elements/AnimationTimeline.js
@@ -32,6 +32,7 @@ WebInspector.AnimationTimeline = function()
this._animationsMap = new Map();
WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this);
WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspector.DOMModel.Events.NodeRemoved, this._nodeRemoved, this);
+ WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.FrameAdded, this._frameAdded, this);
}
WebInspector.AnimationTimeline.prototype = {
@@ -46,7 +47,7 @@ WebInspector.AnimationTimeline.prototype = {
this._animationsPlaybackRate = WebInspector.AnimationsSidebarPane.GlobalPlaybackRates[event.target.value];
var target = WebInspector.targetManager.mainTarget();
if (target)
- target.animationAgent().setPlaybackRate(this._animationsPlaybackRate);
+ target.animationAgent().setPlaybackRate(this._animationsPlaybackRate, this._updateStartTimes.bind(this));
pfeldman 2015/04/01 13:06:45 You should not be talking to the agents from outsi
samli 2015/04/02 09:58:00 Done.
this._playbackLabel.textContent = this._animationsPlaybackRate + "x";
WebInspector.userMetrics.AnimationsPlaybackRateChanged.record();
if (this._scrubberPlayer)
@@ -83,6 +84,25 @@ WebInspector.AnimationTimeline.prototype = {
return container;
},
+ /**
+ * @param {?Protocol.Error} error
+ * @param {!Array.<!AnimationAgent.AnimationStartTime>} startTimes
+ */
+ _updateStartTimes: function(error, startTimes)
+ {
+ if (error)
+ return;
+
+ delete this._startTime;
+ for (var player of startTimes) {
+ var animation = this._animationsMap.get(player.id);
+ console.assert(animation);
+ animation.updateStartTime(player.startTime);
+ if (!this._startTime || player.startTime < this._startTime)
+ this._startTime = player.startTime;
+ }
+ },
+
_updateAnimationsPlaybackRate: function()
{
/**
@@ -108,7 +128,7 @@ WebInspector.AnimationTimeline.prototype = {
return;
var targets = WebInspector.targetManager.targets();
for (var target of targets)
- target.animationAgent().setCurrentTime(/** @type {number} */(this.startTime()));
+ target.animationAgent().setCurrentTime(/** @type {number} */(this.startTime()), this._updateStartTimes.bind(this));
this._animateTime(0);
},
@@ -171,6 +191,16 @@ WebInspector.AnimationTimeline.prototype = {
},
/**
+ * @param {!WebInspector.Event} event
+ */
+ _frameAdded: function(event)
+ {
+ var target = WebInspector.targetManager.mainTarget();
+ if (target)
+ target.animationAgent().setPlaybackRate(this._animationsPlaybackRate, this._updateStartTimes.bind(this));
+ },
+
+ /**
* @param {!WebInspector.AnimationModel.AnimationPlayer} animation
* @param {boolean} resetTimeline
*/
@@ -381,7 +411,7 @@ WebInspector.AnimationTimeline.prototype = {
this._timelineScrubberHead.textContent = WebInspector.UIString(Number.millisToString(currentTime));
var targets = WebInspector.targetManager.targets();
for (var target of targets)
- target.animationAgent().setCurrentTime(/** @type {number} */(this.startTime() + currentTime));
+ target.animationAgent().setCurrentTime(/** @type {number} */(this.startTime() + currentTime), this._updateStartTimes.bind(this));
},
/**

Powered by Google App Engine
This is Rietveld 408576698