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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 5
6 /** 6 /**
7 * @constructor 7 * @constructor
8 * @extends {WebInspector.SDKModel} 8 * @extends {WebInspector.SDKModel}
9 * @param {!WebInspector.Target} target 9 * @param {!WebInspector.Target} target
10 */ 10 */
11 WebInspector.AnimationModel = function(target) 11 WebInspector.AnimationModel = function(target)
12 { 12 {
13 WebInspector.SDKModel.call(this, WebInspector.AnimationModel, target); 13 WebInspector.SDKModel.call(this, WebInspector.AnimationModel, target);
14 this._agent = target.animationAgent(); 14 this._agent = target.animationAgent();
15 target.registerAnimationDispatcher(new WebInspector.AnimationDispatcher(this )); 15 target.registerAnimationDispatcher(new WebInspector.AnimationDispatcher(this ));
16 /** @type {!Map.<string, !WebInspector.AnimationModel.AnimationPlayer>} */
17 this._animationsMap = new Map();
16 } 18 }
17 19
18 WebInspector.AnimationModel.Events = { 20 WebInspector.AnimationModel.Events = {
19 AnimationPlayerCreated: "AnimationPlayerCreated", 21 AnimationPlayerCreated: "AnimationPlayerCreated",
20 AnimationPlayerCanceled: "AnimationPlayerCanceled" 22 AnimationPlayerCanceled: "AnimationPlayerCanceled"
21 } 23 }
22 24
23 WebInspector.AnimationModel.prototype = { 25 WebInspector.AnimationModel.prototype = {
24 /** 26 /**
25 * @param {!DOMAgent.NodeId} nodeId 27 * @param {!DOMAgent.NodeId} nodeId
(...skipping 19 matching lines...) Expand all
45 this._agent.getAnimationPlayersForNode(nodeId, showSubtreeAnimations, re sultCallback.bind(this)); 47 this._agent.getAnimationPlayersForNode(nodeId, showSubtreeAnimations, re sultCallback.bind(this));
46 }, 48 },
47 49
48 /** 50 /**
49 * @param {!AnimationAgent.AnimationPlayer} payload 51 * @param {!AnimationAgent.AnimationPlayer} payload
50 * @param {boolean} resetTimeline 52 * @param {boolean} resetTimeline
51 */ 53 */
52 animationPlayerCreated: function(payload, resetTimeline) 54 animationPlayerCreated: function(payload, resetTimeline)
53 { 55 {
54 var player = WebInspector.AnimationModel.AnimationPlayer.parsePayload(th is.target(), payload); 56 var player = WebInspector.AnimationModel.AnimationPlayer.parsePayload(th is.target(), payload);
57 if (resetTimeline)
58 this._animationsMap.clear();
59 this._animationsMap.set(player.id(), player);
55 this.dispatchEventToListeners(WebInspector.AnimationModel.Events.Animati onPlayerCreated, { "player": player, "resetTimeline": resetTimeline }); 60 this.dispatchEventToListeners(WebInspector.AnimationModel.Events.Animati onPlayerCreated, { "player": player, "resetTimeline": resetTimeline });
56 }, 61 },
57 62
58 /** 63 /**
59 * @param {string} playerId 64 * @param {string} playerId
60 */ 65 */
61 animationPlayerCanceled: function(playerId) 66 animationPlayerCanceled: function(playerId)
62 { 67 {
63 this.dispatchEventToListeners(WebInspector.AnimationModel.Events.Animati onPlayerCanceled, { "playerId": playerId }); 68 this.dispatchEventToListeners(WebInspector.AnimationModel.Events.Animati onPlayerCanceled, { "playerId": playerId });
64 }, 69 },
65 70
71 /**
72 * @param {function(?Array.<!AnimationAgent.AnimationStartTime>)} userCallba ck
73 * @param {?Protocol.Error} error
74 * @param {!Array.<!AnimationAgent.AnimationStartTime>} startTimes
75 */
76 _updateStartTimes: function(userCallback, error, startTimes)
77 {
78 if (error) {
79 userCallback(null);
80 return;
81 }
82 for (var player of startTimes) {
83 var animation = this._animationsMap.get(player.id);
84 console.assert(animation);
85 animation._updateStartTime(player.startTime);
86 }
87 userCallback(startTimes);
88 },
89
90 /**
91 * @param {number} playbackRate
92 * @param {function(?Array.<!AnimationAgent.AnimationStartTime>)} userCallba ck
93 */
94 setPlaybackRate: function(playbackRate, userCallback)
95 {
96 this._agent.setPlaybackRate(playbackRate, this._updateStartTimes.bind(th is, userCallback));
97 },
98
99 /**
100 * @param {number} currentTime
101 * @param {function(?Array.<!AnimationAgent.AnimationStartTime>)} userCallba ck
102 */
103 setCurrentTime: function(currentTime, userCallback)
104 {
105 this._agent.setCurrentTime(currentTime, this._updateStartTimes.bind(this , userCallback));
106 },
107
108 /**
109 * @param {number} timeDelta
110 */
111 seekTimeline: function(timeDelta)
112 {
113 this._agent.seekTimeline(timeDelta);
114 },
115
66 ensureEnabled: function() 116 ensureEnabled: function()
67 { 117 {
68 if (this._enabled) 118 if (this._enabled)
69 return; 119 return;
70 this._agent.enable(); 120 this._agent.enable();
71 this._enabled = true; 121 this._enabled = true;
72 }, 122 },
73 123
74 __proto__: WebInspector.SDKModel.prototype 124 __proto__: WebInspector.SDKModel.prototype
75 } 125 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 playbackRate: function() 202 playbackRate: function()
153 { 203 {
154 return this._payload.playbackRate; 204 return this._payload.playbackRate;
155 }, 205 },
156 206
157 /** 207 /**
158 * @return {number} 208 * @return {number}
159 */ 209 */
160 startTime: function() 210 startTime: function()
161 { 211 {
162 return this._payload.startTime; 212 return this._startTime === undefined ? this._payload.startTime : this._s tartTime;
163 }, 213 },
164 214
165 /** 215 /**
216 * @param {number} startTime
217 */
218 _updateStartTime: function(startTime)
219 {
220 this._startTime = startTime;
221 },
222
223 /**
166 * @return {number} 224 * @return {number}
167 */ 225 */
168 endTime: function() 226 endTime: function()
169 { 227 {
170 if (!this.source().iterations) 228 if (!this.source().iterations)
171 return Infinity; 229 return Infinity;
172 return this.startTime() + this.source().delay() + this.source().duration () * this.source().iterations() + this.source().endDelay(); 230 return this.startTime() + this.source().delay() + this.source().duration () * this.source().iterations() + this.source().endDelay();
173 }, 231 },
174 232
175 /** 233 /**
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 534
477 /** 535 /**
478 * @override 536 * @override
479 * @param {string} playerId 537 * @param {string} playerId
480 */ 538 */
481 animationPlayerCanceled: function(playerId) 539 animationPlayerCanceled: function(playerId)
482 { 540 {
483 this._animationModel.animationPlayerCanceled(playerId); 541 this._animationModel.animationPlayerCanceled(playerId);
484 } 542 }
485 } 543 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698