Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.VBox} | 7 * @extends {WebInspector.VBox} |
| 8 * @implements {WebInspector.TargetManager.Observer} | 8 * @implements {WebInspector.TargetManager.Observer} |
| 9 */ | 9 */ |
| 10 WebInspector.AnimationTimeline = function() | 10 WebInspector.AnimationTimeline = function() |
| 11 { | 11 { |
| 12 WebInspector.VBox.call(this, true); | 12 WebInspector.VBox.call(this, true); |
| 13 this.registerRequiredCSS("animation/animationTimeline.css"); | 13 this.registerRequiredCSS("animation/animationTimeline.css"); |
| 14 this.element.classList.add("animations-timeline"); | 14 this.element.classList.add("animations-timeline"); |
| 15 | 15 |
| 16 this._grid = this.contentElement.createSVGChild("svg", "animation-timeline-g rid"); | 16 this._grid = this.contentElement.createSVGChild("svg", "animation-timeline-g rid"); |
| 17 this.contentElement.appendChild(this._createScrubber()); | 17 this.contentElement.appendChild(this._createScrubber()); |
| 18 WebInspector.installDragHandle(this._timelineScrubberHead, this._scrubberDra gStart.bind(this), this._scrubberDragMove.bind(this), this._scrubberDragEnd.bind (this), "move"); | 18 WebInspector.installDragHandle(this._timelineScrubberHead, this._scrubberDra gStart.bind(this), this._scrubberDragMove.bind(this), this._scrubberDragEnd.bind (this), "move"); |
| 19 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.millis ToString(0)); | 19 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.millis ToString(0)); |
| 20 | 20 |
| 21 this._underlyingPlaybackRate = 1; | 21 this._underlyingPlaybackRate = 1; |
| 22 this.contentElement.appendChild(this._createHeader()); | 22 this.contentElement.appendChild(this._createHeader()); |
| 23 this._animationsContainer = this.contentElement.createChild("div", "animatio n-timeline-rows"); | 23 this._animationsContainer = this.contentElement.createChild("div", "animatio n-timeline-rows"); |
| 24 | |
| 25 this._emptyTimelineMessage = this._animationsContainer.createChild("div", "a nimation-timeline-empty-message"); | |
| 26 var message = this._emptyTimelineMessage.createChild("div"); | |
| 27 message.textContent = WebInspector.UIString("Trigger animations on the page to view and tweak them on the animation timeline."); | |
| 28 | |
| 24 this._duration = this._defaultDuration(); | 29 this._duration = this._defaultDuration(); |
| 25 this._scrubberRadius = 25; | 30 this._scrubberRadius = 30; |
| 26 this._timelineControlsWidth = 200; | 31 this._timelineControlsWidth = 230; |
| 27 /** @type {!Map.<!DOMAgent.BackendNodeId, !WebInspector.AnimationTimeline.No deUI>} */ | 32 /** @type {!Map.<!DOMAgent.BackendNodeId, !WebInspector.AnimationTimeline.No deUI>} */ |
| 28 this._nodesMap = new Map(); | 33 this._nodesMap = new Map(); |
| 29 this._symbol = Symbol("animationTimeline"); | 34 this._symbol = Symbol("animationTimeline"); |
| 30 /** @type {!Map.<string, !WebInspector.AnimationModel.Animation>} */ | 35 /** @type {!Map.<string, !WebInspector.AnimationModel.Animation>} */ |
| 31 this._animationsMap = new Map(); | 36 this._animationsMap = new Map(); |
| 32 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._mainFrameNav igated, this); | 37 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._mainFrameNav igated, this); |
| 33 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspec tor.DOMModel.Events.NodeRemoved, this._nodeRemoved, this); | 38 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspec tor.DOMModel.Events.NodeRemoved, this._nodeRemoved, this); |
| 34 | 39 |
| 35 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Type.Pag e); | 40 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Type.Pag e); |
| 36 } | 41 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 */ | 124 */ |
| 120 _createHeader: function() | 125 _createHeader: function() |
| 121 { | 126 { |
| 122 /** | 127 /** |
| 123 * @param {!Event} event | 128 * @param {!Event} event |
| 124 * @this {WebInspector.AnimationTimeline} | 129 * @this {WebInspector.AnimationTimeline} |
| 125 */ | 130 */ |
| 126 function playbackSliderInputHandler(event) | 131 function playbackSliderInputHandler(event) |
| 127 { | 132 { |
| 128 this._underlyingPlaybackRate = WebInspector.AnimationTimeline.Global PlaybackRates[event.target.value]; | 133 this._underlyingPlaybackRate = WebInspector.AnimationTimeline.Global PlaybackRates[event.target.value]; |
| 129 this._setPlaybackRate(this._playbackRate()); | 134 this._updatePlaybackControls(); |
| 130 this._playbackLabel.textContent = this._underlyingPlaybackRate + "✕" ; | |
| 131 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record(); | |
| 132 if (this._scrubberPlayer) | |
| 133 this._scrubberPlayer.playbackRate = this._playbackRate(); | |
| 134 } | 135 } |
| 135 | 136 |
| 136 var container = createElementWithClass("div", "animation-timeline-header "); | 137 var container = createElementWithClass("div", "animation-timeline-header "); |
| 137 var controls = container.createChild("div", "animation-controls"); | 138 var controls = container.createChild("div", "animation-controls"); |
| 138 container.createChild("div", "animation-timeline-markers"); | 139 container.createChild("div", "animation-timeline-markers"); |
| 139 | 140 |
| 140 var toolbar = new WebInspector.Toolbar(controls); | 141 var toolbar = new WebInspector.Toolbar(controls); |
| 141 toolbar.element.classList.add("animation-controls-toolbar"); | 142 toolbar.element.classList.add("animation-controls-toolbar"); |
| 142 this._pauseButton = new WebInspector.ToolbarButton(WebInspector.UIString ("Pause timeline"), "pause-toolbar-item"); | 143 this._controlButton = new WebInspector.ToolbarButton(WebInspector.UIStri ng("Replay timeline"), "replay-outline-toolbar-item"); |
| 143 this._pauseButton.addEventListener("click", this._togglePause.bind(this) ); | 144 this._controlButton.addEventListener("click", this._controlButtonToggle. bind(this)); |
| 144 toolbar.appendToolbarItem(this._pauseButton); | 145 toolbar.appendToolbarItem(this._controlButton); |
| 145 var replayButton = new WebInspector.ToolbarButton(WebInspector.UIString( "Replay timeline"), "replay-toolbar-item"); | |
| 146 replayButton.addEventListener("click", this._replay.bind(this)); | |
| 147 toolbar.appendToolbarItem(replayButton); | |
| 148 | 146 |
| 149 this._playbackLabel = controls.createChild("div", "animation-playback-la bel"); | 147 this._playbackLabel = controls.createChild("span", "animation-playback-l abel"); |
| 150 this._playbackLabel.createTextChild("1x"); | 148 this._playbackLabel.createTextChild("1x"); |
| 151 | 149 |
| 152 this._playbackSlider = controls.createChild("input", "animation-playback -slider"); | 150 this._playbackSlider = controls.createChild("input", "animation-playback -slider"); |
| 153 this._playbackSlider.type = "range"; | 151 this._playbackSlider.type = "range"; |
| 154 this._playbackSlider.min = 0; | 152 this._playbackSlider.min = 0; |
| 155 this._playbackSlider.max = WebInspector.AnimationTimeline.GlobalPlayback Rates.length - 1; | 153 this._playbackSlider.max = WebInspector.AnimationTimeline.GlobalPlayback Rates.length - 1; |
| 156 this._playbackSlider.value = this._playbackSlider.max; | 154 this._playbackSlider.value = this._playbackSlider.max; |
| 157 this._playbackSlider.addEventListener("input", playbackSliderInputHandle r.bind(this)); | 155 this._playbackSlider.addEventListener("input", playbackSliderInputHandle r.bind(this)); |
| 158 this._updateAnimationsPlaybackRate(); | 156 this._updateAnimationsPlaybackRate(); |
| 159 | 157 |
| 160 return container; | 158 return container; |
| 161 }, | 159 }, |
| 162 | 160 |
| 161 _updatePlaybackControls: function() | |
| 162 { | |
| 163 this._playbackLabel.textContent = this._underlyingPlaybackRate + "x"; | |
| 164 var playbackSliderValue = 0; | |
| 165 for (var rate of WebInspector.AnimationTimeline.GlobalPlaybackRates) { | |
| 166 if (this._underlyingPlaybackRate > rate) | |
| 167 playbackSliderValue++; | |
| 168 } | |
| 169 this._playbackSlider.value = playbackSliderValue; | |
| 170 | |
| 171 var target = WebInspector.targetManager.mainTarget(); | |
| 172 if (target) | |
| 173 WebInspector.AnimationModel.fromTarget(target).setPlaybackRate(this. _playbackRate()); | |
|
pfeldman
2015/09/03 19:05:01
It does not seem to be consistent with the other c
samli
2015/09/03 22:04:18
Done. Removed all instances of .mainTarget()
| |
| 174 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record(); | |
| 175 if (this._scrubberPlayer) | |
| 176 this._scrubberPlayer.playbackRate = this._playbackRate(); | |
| 177 }, | |
| 178 | |
| 179 _controlButtonToggle: function() | |
| 180 { | |
| 181 if (this._emptyTimelineMessage) | |
| 182 return; | |
| 183 if (this._controlButton.element.classList.contains("play-outline-toolbar -item")) | |
| 184 this._togglePause(false); | |
| 185 else if (this._controlButton.element.classList.contains("replay-outline- toolbar-item")) | |
| 186 this._replay(); | |
| 187 else | |
| 188 this._togglePause(true); | |
| 189 this._updateControlButton(); | |
| 190 }, | |
| 191 | |
| 192 _updateControlButton: function() | |
| 193 { | |
| 194 this._controlButton.element.classList.remove("play-outline-toolbar-item" ); | |
| 195 this._controlButton.element.classList.remove("replay-outline-toolbar-ite m"); | |
| 196 this._controlButton.element.classList.remove("pause-outline-toolbar-item "); | |
| 197 if (this._paused) { | |
| 198 this._controlButton.element.classList.add("play-outline-toolbar-item "); | |
| 199 this._controlButton.setTitle(WebInspector.UIString("Play timeline")) ; | |
| 200 } else if (!this._scrubberPlayer || this._scrubberPlayer.currentTime >= this.duration() - this._scrubberRadius / this.pixelMsRatio()) { | |
| 201 this._controlButton.element.classList.add("replay-outline-toolbar-it em"); | |
| 202 this._controlButton.setTitle(WebInspector.UIString("Replay timeline" )); | |
| 203 } else { | |
| 204 this._controlButton.element.classList.add("pause-outline-toolbar-ite m"); | |
| 205 this._controlButton.setTitle(WebInspector.UIString("Pause timeline") ); | |
| 206 } | |
| 207 }, | |
| 208 | |
| 163 _updateAnimationsPlaybackRate: function() | 209 _updateAnimationsPlaybackRate: function() |
| 164 { | 210 { |
| 165 /** | 211 /** |
| 166 * @param {?Protocol.Error} error | 212 * @param {?Protocol.Error} error |
| 167 * @param {number} playbackRate | 213 * @param {number} playbackRate |
| 168 * @this {WebInspector.AnimationTimeline} | 214 * @this {WebInspector.AnimationTimeline} |
| 169 */ | 215 */ |
| 170 function setPlaybackRate(error, playbackRate) | 216 function setPlaybackRate(error, playbackRate) |
| 171 { | 217 { |
| 172 if (playbackRate === 0) { | 218 if (playbackRate === 0) { |
| 173 playbackRate = 1; | 219 playbackRate = 1; |
| 174 target.animationAgent().setPlaybackRate(1); | 220 if (target) |
| 221 WebInspector.AnimationModel.fromTarget(target).setPlaybackRa te(1); | |
| 175 } | 222 } |
| 176 this._underlyingPlaybackRate = playbackRate; | 223 this._underlyingPlaybackRate = playbackRate; |
| 177 this._playbackSlider.value = WebInspector.AnimationTimeline.GlobalPl aybackRates.indexOf(playbackRate); | 224 this._updatePlaybackControls(); |
| 178 this._playbackLabel.textContent = playbackRate + "✕"; | |
| 179 } | 225 } |
| 180 | 226 |
| 227 delete this._paused; | |
| 181 var target = WebInspector.targetManager.mainTarget(); | 228 var target = WebInspector.targetManager.mainTarget(); |
| 182 if (target) | 229 if (target) |
| 183 target.animationAgent().getPlaybackRate(setPlaybackRate.bind(this)); | 230 target.animationAgent().getPlaybackRate(setPlaybackRate.bind(this)); |
| 184 }, | 231 }, |
| 185 | 232 |
| 186 /** | 233 /** |
| 187 * @return {number} | 234 * @return {number} |
| 188 */ | 235 */ |
| 189 _playbackRate: function() | 236 _playbackRate: function() |
| 190 { | 237 { |
| 191 return this._paused ? 0 : this._underlyingPlaybackRate; | 238 return this._paused ? 0 : this._underlyingPlaybackRate; |
| 192 }, | 239 }, |
| 193 | 240 |
| 194 _togglePause: function() | 241 /** |
| 242 * @param {boolean} pause | |
| 243 */ | |
| 244 _togglePause: function(pause) | |
| 195 { | 245 { |
| 196 this._paused = !this._paused; | 246 this._paused = pause; |
| 197 this._setPlaybackRate(this._playbackRate()); | 247 var target = WebInspector.targetManager.mainTarget(); |
| 248 if (target) | |
| 249 WebInspector.AnimationModel.fromTarget(target).setPlaybackRate(this. _playbackRate()); | |
| 198 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record(); | 250 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record(); |
| 199 this._pauseButton.element.classList.toggle("pause-toolbar-item"); | |
| 200 this._pauseButton.element.classList.toggle("play-toolbar-item"); | |
| 201 if (this._scrubberPlayer) | 251 if (this._scrubberPlayer) |
| 202 this._scrubberPlayer.playbackRate = this._playbackRate(); | 252 this._scrubberPlayer.playbackRate = this._playbackRate(); |
| 203 }, | 253 }, |
| 204 | 254 |
| 205 _replay: function() | 255 _replay: function() |
| 206 { | 256 { |
| 207 if (this.startTime() === undefined) | 257 if (this.startTime() === undefined) |
| 208 return; | 258 return; |
| 209 var targets = WebInspector.targetManager.targets(); | 259 var targets = WebInspector.targetManager.targets(); |
| 210 for (var target of targets) | 260 for (var target of targets) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 * @param {!WebInspector.Event} event | 311 * @param {!WebInspector.Event} event |
| 262 */ | 312 */ |
| 263 _mainFrameNavigated: function(event) | 313 _mainFrameNavigated: function(event) |
| 264 { | 314 { |
| 265 this._reset(); | 315 this._reset(); |
| 266 this._updateAnimationsPlaybackRate(); | 316 this._updateAnimationsPlaybackRate(); |
| 267 if (this._scrubberPlayer) | 317 if (this._scrubberPlayer) |
| 268 this._scrubberPlayer.cancel(); | 318 this._scrubberPlayer.cancel(); |
| 269 delete this._scrubberPlayer; | 319 delete this._scrubberPlayer; |
| 270 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.mi llisToString(0)); | 320 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.mi llisToString(0)); |
| 321 this._updateControlButton(); | |
| 271 }, | 322 }, |
| 272 | 323 |
| 273 /** | 324 /** |
| 274 * @param {!WebInspector.Event} event | 325 * @param {!WebInspector.Event} event |
| 275 */ | 326 */ |
| 276 _animationCreated: function(event) | 327 _animationCreated: function(event) |
| 277 { | 328 { |
| 278 this._addAnimation(/** @type {!WebInspector.AnimationModel.Animation} */ (event.data.player), event.data.resetTimeline) | 329 this._addAnimation(/** @type {!WebInspector.AnimationModel.Animation} */ (event.data.player), event.data.resetTimeline) |
| 279 }, | 330 }, |
| 280 | 331 |
| 281 /** | 332 /** |
| 282 * @param {!WebInspector.AnimationModel.Animation} animation | 333 * @param {!WebInspector.AnimationModel.Animation} animation |
| 283 * @param {boolean} resetTimeline | 334 * @param {boolean} resetTimeline |
| 284 */ | 335 */ |
| 285 _addAnimation: function(animation, resetTimeline) | 336 _addAnimation: function(animation, resetTimeline) |
| 286 { | 337 { |
| 287 /** | 338 /** |
| 288 * @param {?WebInspector.DOMNode} node | 339 * @param {?WebInspector.DOMNode} node |
| 289 * @this {WebInspector.AnimationTimeline} | 340 * @this {WebInspector.AnimationTimeline} |
| 290 */ | 341 */ |
| 291 function nodeResolved(node) | 342 function nodeResolved(node) |
| 292 { | 343 { |
| 344 if (!node) | |
| 345 return; | |
| 293 uiAnimation.setNode(node); | 346 uiAnimation.setNode(node); |
| 294 node[this._symbol] = nodeUI; | 347 node[this._symbol] = nodeUI; |
| 295 } | 348 } |
| 296 | 349 |
| 350 if (this._emptyTimelineMessage) { | |
| 351 this._emptyTimelineMessage.remove(); | |
| 352 delete this._emptyTimelineMessage; | |
| 353 } | |
| 354 | |
| 297 if (resetTimeline) | 355 if (resetTimeline) |
| 298 this._reset(); | 356 this._reset(); |
| 299 | 357 |
| 300 // Ignore Web Animations custom effects & groups | 358 // Ignore Web Animations custom effects & groups |
| 301 if (animation.type() === "WebAnimation" && animation.source().keyframesR ule().keyframes().length === 0) | 359 if (animation.type() === "WebAnimation" && animation.source().keyframesR ule().keyframes().length === 0) |
| 302 return; | 360 return; |
| 303 | 361 |
| 304 if (this._resizeWindow(animation)) | 362 if (this._resizeWindow(animation)) |
| 305 this.scheduleRedraw(); | 363 this.scheduleRedraw(); |
| 306 | 364 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 var lastDraw = undefined; | 415 var lastDraw = undefined; |
| 358 for (var time = 0; time < this.duration(); time += gridSize) { | 416 for (var time = 0; time < this.duration(); time += gridSize) { |
| 359 var line = this._grid.createSVGChild("rect", "animation-timeline-gri d-line"); | 417 var line = this._grid.createSVGChild("rect", "animation-timeline-gri d-line"); |
| 360 line.setAttribute("x", time * this.pixelMsRatio()); | 418 line.setAttribute("x", time * this.pixelMsRatio()); |
| 361 line.setAttribute("y", 0); | 419 line.setAttribute("y", 0); |
| 362 line.setAttribute("height", "100%"); | 420 line.setAttribute("height", "100%"); |
| 363 line.setAttribute("width", 1); | 421 line.setAttribute("width", 1); |
| 364 } | 422 } |
| 365 for (var time = 0; time < this.duration(); time += gridSize) { | 423 for (var time = 0; time < this.duration(); time += gridSize) { |
| 366 var gridWidth = time * this.pixelMsRatio(); | 424 var gridWidth = time * this.pixelMsRatio(); |
| 367 if (time && (!lastDraw || gridWidth - lastDraw > 50)) { | 425 if (!lastDraw || gridWidth - lastDraw > 50) { |
| 368 lastDraw = gridWidth; | 426 lastDraw = gridWidth; |
| 369 var label = this._grid.createSVGChild("text", "animation-timelin e-grid-label"); | 427 var label = this._grid.createSVGChild("text", "animation-timelin e-grid-label"); |
| 370 label.setAttribute("x", gridWidth + 5); | 428 label.setAttribute("x", gridWidth + 5); |
| 371 label.setAttribute("y", 35); | 429 label.setAttribute("y", 35); |
| 372 label.textContent = WebInspector.UIString(Number.millisToString( time)); | 430 label.textContent = WebInspector.UIString(Number.millisToString( time)); |
| 373 } | 431 } |
| 374 } | 432 } |
| 375 }, | 433 }, |
| 376 | 434 |
| 377 scheduleRedraw: function() { | 435 scheduleRedraw: function() { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 */ | 493 */ |
| 436 _animateTime: function(time) | 494 _animateTime: function(time) |
| 437 { | 495 { |
| 438 var oldPlayer = this._scrubberPlayer; | 496 var oldPlayer = this._scrubberPlayer; |
| 439 | 497 |
| 440 this._scrubberPlayer = this._timelineScrubber.animate([ | 498 this._scrubberPlayer = this._timelineScrubber.animate([ |
| 441 { transform: "translateX(0px)" }, | 499 { transform: "translateX(0px)" }, |
| 442 { transform: "translateX(" + (this.width() - this._scrubberRadius) + "px)" } | 500 { transform: "translateX(" + (this.width() - this._scrubberRadius) + "px)" } |
| 443 ], { duration: this.duration() - this._scrubberRadius / this.pixelMsRati o(), fill: "forwards" }); | 501 ], { duration: this.duration() - this._scrubberRadius / this.pixelMsRati o(), fill: "forwards" }); |
| 444 this._scrubberPlayer.playbackRate = this._playbackRate(); | 502 this._scrubberPlayer.playbackRate = this._playbackRate(); |
| 503 this._scrubberPlayer.onfinish = this._updateControlButton.bind(this); | |
| 504 this._updateControlButton(); | |
| 445 | 505 |
| 446 if (time !== undefined) | 506 if (time !== undefined) |
| 447 this._scrubberPlayer.currentTime = time; | 507 this._scrubberPlayer.currentTime = time; |
| 448 else if (oldPlayer.playState === "finished") | 508 else if (oldPlayer.playState === "finished") |
| 449 this._scrubberPlayer.finish(); | 509 this._scrubberPlayer.finish(); |
| 450 else | 510 else |
| 451 this._scrubberPlayer.startTime = oldPlayer.startTime; | 511 this._scrubberPlayer.startTime = oldPlayer.startTime; |
| 452 | 512 |
| 453 if (oldPlayer) | 513 if (oldPlayer) |
| 454 oldPlayer.cancel(); | 514 oldPlayer.cancel(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 487 _scrubberDragStart: function(event) | 547 _scrubberDragStart: function(event) |
| 488 { | 548 { |
| 489 if (!this._scrubberPlayer) | 549 if (!this._scrubberPlayer) |
| 490 return false; | 550 return false; |
| 491 | 551 |
| 492 this._originalScrubberTime = this._scrubberPlayer.currentTime; | 552 this._originalScrubberTime = this._scrubberPlayer.currentTime; |
| 493 this._timelineScrubber.classList.remove("animation-timeline-end"); | 553 this._timelineScrubber.classList.remove("animation-timeline-end"); |
| 494 this._scrubberPlayer.pause(); | 554 this._scrubberPlayer.pause(); |
| 495 this._originalMousePosition = new WebInspector.Geometry.Point(event.x, e vent.y); | 555 this._originalMousePosition = new WebInspector.Geometry.Point(event.x, e vent.y); |
| 496 | 556 |
| 497 this._setPlaybackRate(0); | 557 this._togglePause(true); |
| 558 this._updateControlButton(); | |
| 498 return true; | 559 return true; |
| 499 }, | 560 }, |
| 500 | 561 |
| 501 /** | 562 /** |
| 502 * @param {!Event} event | 563 * @param {!Event} event |
| 503 */ | 564 */ |
| 504 _scrubberDragMove: function(event) | 565 _scrubberDragMove: function(event) |
| 505 { | 566 { |
| 506 var delta = event.x - this._originalMousePosition.x; | 567 var delta = event.x - this._originalMousePosition.x; |
| 507 this._scrubberPlayer.currentTime = Math.min(this._originalScrubberTime + delta / this.pixelMsRatio(), this.duration() - this._scrubberRadius / this.pixe lMsRatio()); | 568 this._scrubberPlayer.currentTime = Math.min(this._originalScrubberTime + delta / this.pixelMsRatio(), this.duration() - this._scrubberRadius / this.pixe lMsRatio()); |
| 508 var currentTime = Math.max(0, Math.round(this._scrubberPlayer.currentTim e)); | 569 var currentTime = Math.max(0, Math.round(this._scrubberPlayer.currentTim e)); |
| 509 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.mi llisToString(currentTime)); | 570 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.mi llisToString(currentTime)); |
| 510 var targets = WebInspector.targetManager.targets(); | 571 var targets = WebInspector.targetManager.targets(); |
| 511 for (var target of targets) | 572 for (var target of targets) |
| 512 target.animationAgent().setCurrentTime(/** @type {number} */(this.st artTime() + currentTime)); | 573 target.animationAgent().setCurrentTime(/** @type {number} */(this.st artTime() + currentTime)); |
| 513 }, | 574 }, |
| 514 | 575 |
| 515 /** | 576 /** |
| 516 * @param {!Event} event | 577 * @param {!Event} event |
| 517 */ | 578 */ |
| 518 _scrubberDragEnd: function(event) | 579 _scrubberDragEnd: function(event) |
| 519 { | 580 { |
| 520 if (this._scrubberPlayer.currentTime < this.duration() - this._scrubberR adius / this.pixelMsRatio()) | 581 var currentTime = Math.max(0, this._scrubberPlayer.currentTime); |
| 521 this._scrubberPlayer.play(); | 582 this._scrubberPlayer.play(); |
| 583 this._scrubberPlayer.currentTime = currentTime; | |
| 522 this._timelineScrubberHead.window().requestAnimationFrame(this._updateSc rubber.bind(this)); | 584 this._timelineScrubberHead.window().requestAnimationFrame(this._updateSc rubber.bind(this)); |
| 523 this._setPlaybackRate(this._playbackRate()); | |
| 524 }, | |
| 525 | |
| 526 /** | |
| 527 * @param {number} playbackRate | |
| 528 */ | |
| 529 _setPlaybackRate: function(playbackRate) | |
| 530 { | |
| 531 var target = WebInspector.targetManager.mainTarget(); | |
| 532 if (target) | |
| 533 WebInspector.AnimationModel.fromTarget(target).setPlaybackRate(playb ackRate); | |
| 534 }, | 585 }, |
| 535 | 586 |
| 536 __proto__: WebInspector.VBox.prototype | 587 __proto__: WebInspector.VBox.prototype |
| 537 } | 588 } |
| 538 | 589 |
| 539 /** | 590 /** |
| 540 * @constructor | 591 * @constructor |
| 541 * @param {!WebInspector.AnimationModel.AnimationEffect} animationEffect | 592 * @param {!WebInspector.AnimationModel.AnimationEffect} animationEffect |
| 542 */ | 593 */ |
| 543 WebInspector.AnimationTimeline.NodeUI = function(animationEffect) { | 594 WebInspector.AnimationTimeline.NodeUI = function(animationEffect) { |
| 544 /** | 595 /** |
| 545 * @param {?WebInspector.DOMNode} node | 596 * @param {?WebInspector.DOMNode} node |
| 546 * @this {WebInspector.AnimationTimeline.NodeUI} | 597 * @this {WebInspector.AnimationTimeline.NodeUI} |
| 547 */ | 598 */ |
| 548 function nodeResolved(node) | 599 function nodeResolved(node) |
| 549 { | 600 { |
| 601 if (!node) | |
| 602 return; | |
| 550 this._node = node; | 603 this._node = node; |
| 551 this._description.appendChild(WebInspector.DOMPresentationUtils.linkifyN odeReference(node)); | 604 WebInspector.DOMPresentationUtils.decorateNodeLabel(node, this._descript ion); |
| 552 this.element.addEventListener("click", WebInspector.Revealer.reveal.bind (WebInspector.Revealer, node, undefined), false); | 605 this.element.addEventListener("click", WebInspector.Revealer.reveal.bind (WebInspector.Revealer, node, undefined), false); |
| 553 } | 606 } |
| 554 | 607 |
| 555 this._rows = []; | 608 this._rows = []; |
| 556 this.element = createElementWithClass("div", "animation-node-row"); | 609 this.element = createElementWithClass("div", "animation-node-row"); |
| 557 this._description = this.element.createChild("div", "animation-node-descript ion"); | 610 this._description = this.element.createChild("div", "animation-node-descript ion"); |
| 558 animationEffect.deferredNode().resolve(nodeResolved.bind(this)); | 611 animationEffect.deferredNode().resolve(nodeResolved.bind(this)); |
| 559 this._timelineElement = this.element.createChild("div", "animation-node-time line"); | 612 this._timelineElement = this.element.createChild("div", "animation-node-time line"); |
| 560 } | 613 } |
| 561 | 614 |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1085 EndpointsClickRegionSize: 10, | 1138 EndpointsClickRegionSize: 10, |
| 1086 GridCanvasHeight: 40 | 1139 GridCanvasHeight: 40 |
| 1087 } | 1140 } |
| 1088 | 1141 |
| 1089 WebInspector.AnimationUI.Colors = { | 1142 WebInspector.AnimationUI.Colors = { |
| 1090 "Purple": WebInspector.Color.parse("#9C27B0"), | 1143 "Purple": WebInspector.Color.parse("#9C27B0"), |
| 1091 "Light Blue": WebInspector.Color.parse("#03A9F4"), | 1144 "Light Blue": WebInspector.Color.parse("#03A9F4"), |
| 1092 "Deep Orange": WebInspector.Color.parse("#FF5722"), | 1145 "Deep Orange": WebInspector.Color.parse("#FF5722"), |
| 1093 "Blue": WebInspector.Color.parse("#5677FC"), | 1146 "Blue": WebInspector.Color.parse("#5677FC"), |
| 1094 "Lime": WebInspector.Color.parse("#CDDC39"), | 1147 "Lime": WebInspector.Color.parse("#CDDC39"), |
| 1095 "Blue Grey": WebInspector.Color.parse("#607D8B"), | |
| 1096 "Pink": WebInspector.Color.parse("#E91E63"), | 1148 "Pink": WebInspector.Color.parse("#E91E63"), |
| 1097 "Green": WebInspector.Color.parse("#0F9D58"), | 1149 "Green": WebInspector.Color.parse("#0F9D58"), |
| 1098 "Brown": WebInspector.Color.parse("#795548"), | 1150 "Brown": WebInspector.Color.parse("#795548"), |
| 1099 "Cyan": WebInspector.Color.parse("#00BCD4") | 1151 "Cyan": WebInspector.Color.parse("#00BCD4") |
| 1100 } | 1152 } |
| OLD | NEW |