OLD | NEW |
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 | 14 |
15 this._agent = target.animationAgent(); | 15 this._agent = target.animationAgent(); |
16 /** @type {!Object.<*, !Array.<function(?Array.<!WebInspector.AnimationModel
.AnimationPlayer>)>>} */ | 16 /** @type {!Object.<*, !Array.<function(?Array.<!WebInspector.AnimationModel
.AnimationPlayer>)>>} */ |
17 this._nodeIdToCallbackData = {}; | 17 this._nodeIdToCallbackData = {}; |
18 } | 18 } |
19 | 19 |
20 WebInspector.AnimationModel.prototype = { | 20 WebInspector.AnimationModel.prototype = { |
21 /** | 21 /** |
22 * @param {!DOMAgent.NodeId} nodeId | 22 * @param {!DOMAgent.NodeId} nodeId |
| 23 * @param {boolean} showSubtreeAnimations |
23 * @param {function(?Array.<!WebInspector.AnimationModel.AnimationPlayer>)}
userCallback | 24 * @param {function(?Array.<!WebInspector.AnimationModel.AnimationPlayer>)}
userCallback |
24 */ | 25 */ |
25 getAnimationPlayers: function(nodeId, userCallback) | 26 getAnimationPlayers: function(nodeId, showSubtreeAnimations, userCallback) |
26 { | 27 { |
27 /** | 28 /** |
28 * @param {?Protocol.Error} error | 29 * @param {?Protocol.Error} error |
29 * @param {!Array.<!AnimationAgent.AnimationPlayer>} payloads | 30 * @param {!Array.<!AnimationAgent.AnimationPlayer>} payloads |
30 * @this {WebInspector.AnimationModel} | 31 * @this {WebInspector.AnimationModel} |
31 */ | 32 */ |
32 function resultCallback(error, payloads) | 33 function resultCallback(error, payloads) |
33 { | 34 { |
34 var callbacks = this._nodeIdToCallbackData[nodeId]; | |
35 delete this._nodeIdToCallbackData[nodeId]; | |
36 if (error) { | 35 if (error) { |
37 callbacks.forEach(function(callback) { | 36 userCallback(null); |
38 callback(null); | |
39 }); | |
40 return; | 37 return; |
41 } | 38 } |
42 var animationPlayers = payloads.map(WebInspector.AnimationModel.Anim
ationPlayer.parsePayload.bind(null, target)); | 39 userCallback(payloads.map(WebInspector.AnimationModel.AnimationPlaye
r.parsePayload.bind(null, this.target()))); |
43 | |
44 callbacks.forEach(function(callback) { | |
45 callback(animationPlayers); | |
46 }); | |
47 } | 40 } |
48 | 41 |
49 if (this._nodeIdToCallbackData[nodeId]) { | 42 this._agent.getAnimationPlayersForNode(nodeId, showSubtreeAnimations, re
sultCallback.bind(this)); |
50 this._nodeIdToCallbackData[nodeId].push(userCallback); | |
51 return; | |
52 } | |
53 | |
54 var target = this.target(); | |
55 this._nodeIdToCallbackData[nodeId] = [userCallback]; | |
56 this._agent.getAnimationPlayersForNode(nodeId, resultCallback.bind(this)
); | |
57 }, | 43 }, |
58 | 44 |
59 __proto__: WebInspector.SDKModel.prototype | 45 __proto__: WebInspector.SDKModel.prototype |
60 } | 46 } |
61 | 47 |
62 /** | 48 /** |
63 * @constructor | 49 * @constructor |
64 * @extends {WebInspector.SDKObject} | 50 * @extends {WebInspector.SDKObject} |
65 * @param {!WebInspector.Target} target | 51 * @param {!WebInspector.Target} target |
66 * @param {!AnimationAgent.AnimationPlayer} payload | 52 * @param {!AnimationAgent.AnimationPlayer} payload |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 */ | 174 */ |
189 getCurrentState: function(callback) | 175 getCurrentState: function(callback) |
190 { | 176 { |
191 /** | 177 /** |
192 * @param {?Protocol.Error} error | 178 * @param {?Protocol.Error} error |
193 * @param {number} currentTime | 179 * @param {number} currentTime |
194 * @param {boolean} isRunning | 180 * @param {boolean} isRunning |
195 */ | 181 */ |
196 function mycallback(error, currentTime, isRunning) | 182 function mycallback(error, currentTime, isRunning) |
197 { | 183 { |
198 if (error) { | 184 if (error) |
199 console.error(error); | |
200 return; | 185 return; |
201 } | |
202 callback(currentTime, isRunning); | 186 callback(currentTime, isRunning); |
203 } | 187 } |
204 this.target().animationModel._agent.getAnimationPlayerState(this.id(), m
ycallback); | 188 this.target().animationModel._agent.getAnimationPlayerState(this.id(), m
ycallback); |
205 }, | 189 }, |
206 | 190 |
207 __proto__: WebInspector.SDKObject.prototype | 191 __proto__: WebInspector.SDKObject.prototype |
208 } | 192 } |
209 | 193 |
210 /** | 194 /** |
211 * @constructor | 195 * @constructor |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 272 |
289 /** | 273 /** |
290 * @return {string} | 274 * @return {string} |
291 */ | 275 */ |
292 name: function() | 276 name: function() |
293 { | 277 { |
294 return this._payload.name; | 278 return this._payload.name; |
295 }, | 279 }, |
296 | 280 |
297 /** | 281 /** |
| 282 * @param {function(?WebInspector.DOMNode)} callback |
| 283 */ |
| 284 getNode: function(callback) |
| 285 { |
| 286 /** |
| 287 * @this {WebInspector.AnimationModel.AnimationNode} |
| 288 * @param {?Array.<number>} nodeIds |
| 289 */ |
| 290 function nodePushedCallback(nodeIds) |
| 291 { |
| 292 if (nodeIds) |
| 293 this.nodeId = nodeIds[0]; |
| 294 callback(this.target().domModel.nodeForId(this.nodeId)); |
| 295 } |
| 296 |
| 297 if (this.nodeId) |
| 298 callback(this.target().domModel.nodeForId(this.nodeId)); |
| 299 else |
| 300 this._target.domModel.pushNodesByBackendIdsToFrontend([this._payload
.backendNodeId], nodePushedCallback.bind(this)); |
| 301 }, |
| 302 |
| 303 /** |
298 * @return {?WebInspector.AnimationModel.KeyframesRule} | 304 * @return {?WebInspector.AnimationModel.KeyframesRule} |
299 */ | 305 */ |
300 keyframesRule: function() | 306 keyframesRule: function() |
301 { | 307 { |
302 return this._keyframesRule; | 308 return this._keyframesRule; |
303 }, | 309 }, |
304 | 310 |
305 __proto__: WebInspector.SDKObject.prototype | 311 __proto__: WebInspector.SDKObject.prototype |
306 } | 312 } |
307 | 313 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 /** | 381 /** |
376 * @return {!WebInspector.CSSStyleDeclaration} | 382 * @return {!WebInspector.CSSStyleDeclaration} |
377 */ | 383 */ |
378 style: function() | 384 style: function() |
379 { | 385 { |
380 return this._style; | 386 return this._style; |
381 }, | 387 }, |
382 | 388 |
383 __proto__: WebInspector.SDKObject.prototype | 389 __proto__: WebInspector.SDKObject.prototype |
384 } | 390 } |
OLD | NEW |