Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 | |
| 6 /** | |
| 7 * @constructor | |
| 8 * @extends {WebInspector.SDKModel} | |
| 9 * @param {!WebInspector.Target} target | |
| 10 */ | |
| 11 WebInspector.AnimationModel = function(target) { | |
| 12 WebInspector.SDKModel.call(this, WebInspector.AnimationModel, target); | |
| 13 | |
| 14 this._agent = target.animationAgent(); | |
| 15 } | |
| 16 | |
| 17 WebInspector.AnimationModel.prototype = { | |
| 18 /** | |
| 19 * @param {!DOMAgent.NodeId} nodeId | |
| 20 * @param {function(?Array.<!WebInspector.AnimationModel.AnimationPlayer>)} callback | |
| 21 */ | |
| 22 animationPlayers: function(nodeId, callback) | |
| 23 { | |
| 24 var target = this.target(); | |
| 25 /** | |
| 26 * @param {?Protocol.Error} error | |
| 27 * @param {!Array.<!AnimationAgent.AnimationPlayer>} payloads | |
| 28 */ | |
| 29 function mycallback(error, payloads) | |
| 30 { | |
| 31 if (error) { | |
| 32 callback(null); | |
| 33 return; | |
| 34 } | |
| 35 callback(payloads.map(function(payload) { | |
| 36 return new WebInspector.AnimationModel.AnimationPlayer(target, p ayload); | |
| 37 })); | |
| 38 } | |
|
vsevik
2014/10/16 08:13:52
Please add an empty line before and after function
samli
2014/10/16 22:59:30
Done.
| |
| 39 this._agent.getAnimationPlayersForNode(nodeId, mycallback); | |
| 40 }, | |
| 41 | |
| 42 __proto__: WebInspector.SDKModel.prototype | |
| 43 } | |
| 44 | |
| 45 /** | |
| 46 * @constructor | |
| 47 * @extends {WebInspector.SDKObject} | |
| 48 * @param {!WebInspector.Target} target | |
| 49 * @param {!AnimationAgent.AnimationPlayer} payload | |
| 50 */ | |
| 51 WebInspector.AnimationModel.AnimationPlayer = function(target, payload) | |
| 52 { | |
| 53 WebInspector.SDKObject.call(this, target); | |
| 54 this._payload = payload; | |
| 55 this._source = new WebInspector.AnimationModel.AnimationNode(this.target(), this._payload.source); | |
| 56 } | |
| 57 | |
| 58 WebInspector.AnimationModel.AnimationPlayer.prototype = { | |
| 59 /** | |
| 60 * @return {!AnimationAgent.AnimationPlayer} | |
| 61 */ | |
| 62 payload: function() | |
| 63 { | |
| 64 return this._payload; | |
| 65 }, | |
| 66 | |
| 67 /** | |
| 68 * @return {string} | |
| 69 */ | |
| 70 id: function() | |
| 71 { | |
| 72 return this._payload.id; | |
| 73 }, | |
| 74 | |
| 75 /** | |
| 76 * @return {boolean} | |
| 77 */ | |
| 78 paused: function () | |
| 79 { | |
| 80 return this._payload.pausedState; | |
| 81 }, | |
| 82 | |
| 83 /** | |
| 84 * @return {string} | |
| 85 */ | |
| 86 playState: function() | |
| 87 { | |
| 88 return this._payload.playState; | |
| 89 }, | |
| 90 | |
| 91 /** | |
| 92 * @return {number} | |
| 93 */ | |
| 94 playbackRate: function() | |
| 95 { | |
| 96 return this._payload.playbackRate; | |
| 97 }, | |
| 98 | |
| 99 /** | |
| 100 * @return {number} | |
| 101 */ | |
| 102 startTime: function() | |
| 103 { | |
| 104 return this._payload.startTime; | |
| 105 }, | |
| 106 | |
| 107 /** | |
| 108 * @return {number} | |
| 109 */ | |
| 110 currentTime: function() | |
| 111 { | |
| 112 return this._payload.currentTime; | |
| 113 }, | |
| 114 | |
| 115 /** | |
| 116 * @return {!WebInspector.AnimationModel.AnimationNode} | |
| 117 */ | |
| 118 source: function() | |
| 119 { | |
| 120 return this._source; | |
| 121 }, | |
| 122 | |
| 123 /** | |
| 124 * @param {function(?WebInspector.AnimationModel.AnimationPlayer)} callback | |
| 125 */ | |
| 126 pause: function(callback) | |
| 127 { | |
| 128 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Ani mationAgent.pauseAnimationPlayer(): ", WebInspector.AnimationModel.AnimationPlay er.bind(null, this._target)); | |
| 129 this.target().animationModel._agent.pauseAnimationPlayer(this.id(), wrap pedCallback); | |
| 130 }, | |
| 131 | |
| 132 /** | |
| 133 * @param {function(?WebInspector.AnimationModel.AnimationPlayer)} callback | |
| 134 */ | |
| 135 play: function(callback) | |
| 136 { | |
| 137 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Ani mationAgent.playAnimationPlayer(): ", WebInspector.AnimationModel.AnimationPlaye r.bind(null, this._target)); | |
| 138 this.target().animationModel._agent.playAnimationPlayer(this.id(), wrapp edCallback); | |
| 139 }, | |
| 140 | |
| 141 /** | |
| 142 * @param {number} currentTime | |
| 143 * @param {function(?WebInspector.AnimationModel.AnimationPlayer)} callback | |
| 144 */ | |
| 145 setCurrentTime: function(currentTime, callback) | |
| 146 { | |
| 147 var wrappedCallback = InspectorBackend.wrapClientCallback(callback, "Ani mationAgent.setAnimationPlayerCurrentTime(): ", WebInspector.AnimationModel.Anim ationPlayer.bind(null, this._target)); | |
| 148 this.target().animationModel._agent.setAnimationPlayerCurrentTime(this.i d(), currentTime, wrappedCallback); | |
| 149 }, | |
| 150 | |
| 151 /** | |
| 152 * @param {function(number, boolean)} callback | |
| 153 */ | |
| 154 getCurrentState: function(callback) | |
| 155 { | |
| 156 /** | |
| 157 * @param {?Protocol.Error} error | |
| 158 * @param {number} currentTime | |
| 159 * @param {boolean} isRunning | |
| 160 */ | |
| 161 function mycallback(error, currentTime, isRunning) | |
| 162 { | |
| 163 if (error) { | |
| 164 console.error(error); | |
| 165 return; | |
| 166 } | |
| 167 callback(currentTime, isRunning); | |
| 168 } | |
| 169 this.target().animationModel._agent.getAnimationPlayerState(this.id(), m ycallback); | |
| 170 }, | |
| 171 | |
| 172 __proto__: WebInspector.SDKObject.prototype | |
| 173 } | |
| 174 | |
| 175 /** | |
| 176 * @constructor | |
| 177 * @extends {WebInspector.SDKObject} | |
| 178 * @param {!WebInspector.Target} target | |
| 179 * @param {!AnimationAgent.AnimationNode} payload | |
| 180 */ | |
| 181 WebInspector.AnimationModel.AnimationNode = function(target, payload) | |
| 182 { | |
| 183 WebInspector.SDKObject.call(this, target); | |
| 184 this._payload = payload; | |
| 185 } | |
| 186 | |
| 187 WebInspector.AnimationModel.AnimationNode.prototype = { | |
| 188 /** | |
| 189 * @return {number} | |
| 190 */ | |
| 191 startDelay: function() | |
| 192 { | |
| 193 return this._payload.startDelay; | |
| 194 }, | |
| 195 | |
| 196 /** | |
| 197 * @return {number} | |
| 198 */ | |
| 199 playbackRate: function() | |
| 200 { | |
| 201 return this._payload.playbackRate; | |
| 202 }, | |
| 203 | |
| 204 /** | |
| 205 * @return {number} | |
| 206 */ | |
| 207 iterationStart: function() | |
| 208 { | |
| 209 return this._payload.iterationStart; | |
| 210 }, | |
| 211 | |
| 212 /** | |
| 213 * @return {number} | |
| 214 */ | |
| 215 iterationCount: function() | |
| 216 { | |
| 217 return this._payload.iterationCount; | |
| 218 }, | |
| 219 | |
| 220 /** | |
| 221 * @return {number} | |
| 222 */ | |
| 223 duration: function() | |
| 224 { | |
| 225 return this._payload.duration; | |
| 226 }, | |
| 227 | |
| 228 /** | |
| 229 * @return {number} | |
| 230 */ | |
| 231 direction: function() | |
| 232 { | |
| 233 return this._payload.direction; | |
| 234 }, | |
| 235 | |
| 236 /** | |
| 237 * @return {number} | |
| 238 */ | |
| 239 fillMode: function() | |
| 240 { | |
| 241 return this._payload.fillMode; | |
| 242 }, | |
| 243 | |
| 244 /** | |
| 245 * @return {number} | |
| 246 */ | |
| 247 timeFraction: function() | |
| 248 { | |
| 249 return this._payload.timeFraction; | |
| 250 }, | |
| 251 | |
| 252 /** | |
| 253 * @return {string} | |
| 254 */ | |
| 255 name: function() | |
| 256 { | |
| 257 return this._payload.name; | |
| 258 }, | |
| 259 | |
| 260 __proto__: WebInspector.SDKObject.prototype | |
| 261 } | |
| OLD | NEW |