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

Unified Diff: Source/devtools/front_end/sdk/AnimationModel.js

Issue 1042143005: Devtools Animations: Support multiple frames in the animation timeline (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Naming changes Created 5 years, 8 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/sdk/AnimationModel.js
diff --git a/Source/devtools/front_end/sdk/AnimationModel.js b/Source/devtools/front_end/sdk/AnimationModel.js
index 573293b402253abe935d0204af9832f2782d23e9..f5e536eb416da1184c37287de997bfc2f5b33203 100644
--- a/Source/devtools/front_end/sdk/AnimationModel.js
+++ b/Source/devtools/front_end/sdk/AnimationModel.js
@@ -13,6 +13,8 @@ WebInspector.AnimationModel = function(target)
WebInspector.SDKModel.call(this, WebInspector.AnimationModel, target);
this._agent = target.animationAgent();
target.registerAnimationDispatcher(new WebInspector.AnimationDispatcher(this));
+ /** @type {!Map.<string, !WebInspector.AnimationModel.AnimationPlayer>} */
+ this._animationsMap = new Map();
}
WebInspector.AnimationModel.Events = {
@@ -52,6 +54,9 @@ WebInspector.AnimationModel.prototype = {
animationPlayerCreated: function(payload, resetTimeline)
{
var player = WebInspector.AnimationModel.AnimationPlayer.parsePayload(this.target(), payload);
+ if (resetTimeline)
+ this._animationsMap.clear();
+ this._animationsMap.set(player.id(), player);
this.dispatchEventToListeners(WebInspector.AnimationModel.Events.AnimationPlayerCreated, { "player": player, "resetTimeline": resetTimeline });
},
@@ -63,6 +68,51 @@ WebInspector.AnimationModel.prototype = {
this.dispatchEventToListeners(WebInspector.AnimationModel.Events.AnimationPlayerCanceled, { "playerId": playerId });
},
+ /**
+ * @param {function(?Array.<!AnimationAgent.AnimationStartTime>)} userCallback
+ * @param {?Protocol.Error} error
+ * @param {!Array.<!AnimationAgent.AnimationStartTime>} startTimes
+ */
+ _updateStartTimes: function(userCallback, error, startTimes)
+ {
+ if (error) {
+ userCallback(null);
+ return;
+ }
+ for (var player of startTimes) {
+ var animation = this._animationsMap.get(player.id);
+ console.assert(animation);
+ animation._updateStartTime(player.startTime);
+ }
+ userCallback(startTimes);
+ },
+
+ /**
+ * @param {number} playbackRate
+ * @param {function(?Array.<!AnimationAgent.AnimationStartTime>)} userCallback
+ */
+ setPlaybackRate: function(playbackRate, userCallback)
+ {
+ this._agent.setPlaybackRate(playbackRate, this._updateStartTimes.bind(this, userCallback));
+ },
+
+ /**
+ * @param {number} time
+ * @param {function(?Array.<!AnimationAgent.AnimationStartTime>)} userCallback
+ */
+ seekTimelineTo: function(time, userCallback)
+ {
+ this._agent.seekTimelineTo(time, this._updateStartTimes.bind(this, userCallback));
+ },
+
+ /**
+ * @param {number} timeDelta
+ */
+ seekTimelineBy: function(timeDelta)
+ {
+ this._agent.seekTimelineBy(timeDelta);
+ },
+
ensureEnabled: function()
{
if (this._enabled)
@@ -159,7 +209,15 @@ WebInspector.AnimationModel.AnimationPlayer.prototype = {
*/
startTime: function()
{
- return this._payload.startTime;
+ return this._startTime === undefined ? this._payload.startTime : this._startTime;
+ },
+
+ /**
+ * @param {number} startTime
+ */
+ _updateStartTime: function(startTime)
+ {
+ this._startTime = startTime;
},
/**

Powered by Google App Engine
This is Rietveld 408576698