Chromium Code Reviews| 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 animationPlayers: 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 var callbacks = this._nodeIdToCallbackData[nodeId]; |
| 35 delete this._nodeIdToCallbackData[nodeId]; | 36 delete this._nodeIdToCallbackData[nodeId]; |
| 36 if (error) { | 37 if (error) { |
| 37 callbacks.forEach(function(callback) { | 38 for (var i = 0; i < callbacks.length; i++) |
| 38 callback(null); | 39 callbacks[i](null); |
| 39 }); | |
| 40 return; | 40 return; |
| 41 } | 41 } |
| 42 var animationPlayers = payloads.map(WebInspector.AnimationModel.Anim ationPlayer.parsePayload.bind(null, target)); | 42 var animationPlayers = payloads.map(WebInspector.AnimationModel.Anim ationPlayer.parsePayload.bind(null, target)); |
| 43 | 43 |
| 44 callbacks.forEach(function(callback) { | 44 for (var i = 0; i < callbacks.length; i++) |
| 45 callback(animationPlayers); | 45 callbacks[i](animationPlayers); |
| 46 }); | |
| 47 } | 46 } |
| 48 | 47 |
| 49 if (this._nodeIdToCallbackData[nodeId]) { | 48 if (this._nodeIdToCallbackData[nodeId]) { |
| 50 this._nodeIdToCallbackData[nodeId].push(userCallback); | 49 this._nodeIdToCallbackData[nodeId].push(userCallback); |
|
vsevik
2014/11/12 09:14:35
Now that we could have different types of such req
samli
2014/11/13 01:12:44
I've removed this behavior.
| |
| 51 return; | 50 return; |
| 52 } | 51 } |
| 53 | 52 |
| 54 var target = this.target(); | 53 var target = this.target(); |
| 55 this._nodeIdToCallbackData[nodeId] = [userCallback]; | 54 this._nodeIdToCallbackData[nodeId] = [userCallback]; |
| 56 this._agent.getAnimationPlayersForNode(nodeId, resultCallback.bind(this) ); | 55 this._agent.getAnimationPlayersForNode(nodeId, showSubtreeAnimations, re sultCallback.bind(this)); |
| 57 }, | 56 }, |
| 58 | 57 |
| 59 __proto__: WebInspector.SDKModel.prototype | 58 __proto__: WebInspector.SDKModel.prototype |
| 60 } | 59 } |
| 61 | 60 |
| 62 /** | 61 /** |
| 63 * @constructor | 62 * @constructor |
| 64 * @extends {WebInspector.SDKObject} | 63 * @extends {WebInspector.SDKObject} |
| 65 * @param {!WebInspector.Target} target | 64 * @param {!WebInspector.Target} target |
| 66 * @param {!AnimationAgent.AnimationPlayer} payload | 65 * @param {!AnimationAgent.AnimationPlayer} payload |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 getCurrentState: function(callback) | 188 getCurrentState: function(callback) |
| 190 { | 189 { |
| 191 /** | 190 /** |
| 192 * @param {?Protocol.Error} error | 191 * @param {?Protocol.Error} error |
| 193 * @param {number} currentTime | 192 * @param {number} currentTime |
| 194 * @param {boolean} isRunning | 193 * @param {boolean} isRunning |
| 195 */ | 194 */ |
| 196 function mycallback(error, currentTime, isRunning) | 195 function mycallback(error, currentTime, isRunning) |
| 197 { | 196 { |
| 198 if (error) { | 197 if (error) { |
| 199 console.error(error); | |
|
vsevik
2014/11/12 09:14:35
Why did you remove this?
You should also remove br
samli
2014/11/13 01:12:44
When the selected node changes, the list of animat
| |
| 200 return; | 198 return; |
| 201 } | 199 } |
| 202 callback(currentTime, isRunning); | 200 callback(currentTime, isRunning); |
| 203 } | 201 } |
| 204 this.target().animationModel._agent.getAnimationPlayerState(this.id(), m ycallback); | 202 this.target().animationModel._agent.getAnimationPlayerState(this.id(), m ycallback); |
| 205 }, | 203 }, |
| 206 | 204 |
| 207 __proto__: WebInspector.SDKObject.prototype | 205 __proto__: WebInspector.SDKObject.prototype |
| 208 } | 206 } |
| 209 | 207 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 | 286 |
| 289 /** | 287 /** |
| 290 * @return {string} | 288 * @return {string} |
| 291 */ | 289 */ |
| 292 name: function() | 290 name: function() |
| 293 { | 291 { |
| 294 return this._payload.name; | 292 return this._payload.name; |
| 295 }, | 293 }, |
| 296 | 294 |
| 297 /** | 295 /** |
| 296 * @param {function(?WebInspector.DOMNode)} callback | |
| 297 */ | |
| 298 node: function(callback) | |
|
vsevik
2014/11/12 09:14:35
We usually use get prefix for asynchronous getters
samli
2014/11/13 01:12:44
Done.
| |
| 299 { | |
| 300 /** | |
| 301 * @this {WebInspector.AnimationModel.AnimationNode} | |
| 302 * @param {?Array.<number>} nodeIds | |
| 303 */ | |
| 304 function nodePushedCallback(nodeIds) | |
| 305 { | |
| 306 if (nodeIds) | |
| 307 this.nodeId = nodeIds[0]; | |
| 308 callback(this.target().domModel.nodeForId(this.nodeId)); | |
| 309 } | |
| 310 | |
| 311 if (this.nodeId) | |
| 312 callback(this.target().domModel.nodeForId(this.nodeId)); | |
| 313 else | |
| 314 this._target.domModel.pushNodesByBackendIdsToFrontend([this._payload .backendNodeId], nodePushedCallback.bind(this)); | |
| 315 }, | |
| 316 | |
| 317 /** | |
| 298 * @return {?WebInspector.AnimationModel.KeyframesRule} | 318 * @return {?WebInspector.AnimationModel.KeyframesRule} |
| 299 */ | 319 */ |
| 300 keyframesRule: function() | 320 keyframesRule: function() |
| 301 { | 321 { |
| 302 return this._keyframesRule; | 322 return this._keyframesRule; |
| 303 }, | 323 }, |
| 304 | 324 |
| 305 __proto__: WebInspector.SDKObject.prototype | 325 __proto__: WebInspector.SDKObject.prototype |
| 306 } | 326 } |
| 307 | 327 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 /** | 395 /** |
| 376 * @return {!WebInspector.CSSStyleDeclaration} | 396 * @return {!WebInspector.CSSStyleDeclaration} |
| 377 */ | 397 */ |
| 378 style: function() | 398 style: function() |
| 379 { | 399 { |
| 380 return this._style; | 400 return this._style; |
| 381 }, | 401 }, |
| 382 | 402 |
| 383 __proto__: WebInspector.SDKObject.prototype | 403 __proto__: WebInspector.SDKObject.prototype |
| 384 } | 404 } |
| OLD | NEW |