| 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..a056ecbc465039d277a6d52bc286570c454e9bbe 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} currentTime
|
| + * @param {function(?Array.<!AnimationAgent.AnimationStartTime>)} userCallback
|
| + */
|
| + setCurrentTime: function(currentTime, userCallback)
|
| + {
|
| + this._agent.setCurrentTime(currentTime, this._updateStartTimes.bind(this, userCallback));
|
| + },
|
| +
|
| + /**
|
| + * @param {number} timeDelta
|
| + */
|
| + seekTimeline: function(timeDelta)
|
| + {
|
| + this._agent.seekTimeline(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;
|
| },
|
|
|
| /**
|
|
|