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 */ | 8 */ |
| 9 WebInspector.AnimationTimeline = function() | 9 WebInspector.AnimationTimeline = function() |
| 10 { | 10 { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 this._duration = this._defaultDuration(); | 25 this._duration = this._defaultDuration(); |
| 26 this._scrubberRadius = 25; | 26 this._scrubberRadius = 25; |
| 27 this._timelineControlsWidth = 200; | 27 this._timelineControlsWidth = 200; |
| 28 /** @type {!Map.<!DOMAgent.BackendNodeId, !WebInspector.AnimationTimeline.No deUI>} */ | 28 /** @type {!Map.<!DOMAgent.BackendNodeId, !WebInspector.AnimationTimeline.No deUI>} */ |
| 29 this._nodesMap = new Map(); | 29 this._nodesMap = new Map(); |
| 30 this._symbol = Symbol("animationTimeline"); | 30 this._symbol = Symbol("animationTimeline"); |
| 31 /** @type {!Map.<string, !WebInspector.AnimationModel.AnimationPlayer>} */ | 31 /** @type {!Map.<string, !WebInspector.AnimationModel.AnimationPlayer>} */ |
| 32 this._animationsMap = new Map(); | 32 this._animationsMap = new Map(); |
| 33 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._mainFrameNav igated, this); | 33 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._mainFrameNav igated, this); |
| 34 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspec tor.DOMModel.Events.NodeRemoved, this._nodeRemoved, this); | 34 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspec tor.DOMModel.Events.NodeRemoved, this._nodeRemoved, this); |
| 35 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.FrameAdded, this._frameAdded, this); | |
| 35 } | 36 } |
| 36 | 37 |
| 37 WebInspector.AnimationTimeline.prototype = { | 38 WebInspector.AnimationTimeline.prototype = { |
| 38 _createHeader: function() | 39 _createHeader: function() |
| 39 { | 40 { |
| 40 /** | 41 /** |
| 41 * @param {!Event} event | 42 * @param {!Event} event |
| 42 * @this {WebInspector.AnimationTimeline} | 43 * @this {WebInspector.AnimationTimeline} |
| 43 */ | 44 */ |
| 44 function playbackSliderInputHandler(event) | 45 function playbackSliderInputHandler(event) |
| 45 { | 46 { |
| 46 this._animationsPlaybackRate = WebInspector.AnimationsSidebarPane.Gl obalPlaybackRates[event.target.value]; | 47 this._animationsPlaybackRate = WebInspector.AnimationsSidebarPane.Gl obalPlaybackRates[event.target.value]; |
| 47 var target = WebInspector.targetManager.mainTarget(); | 48 var target = WebInspector.targetManager.mainTarget(); |
| 48 if (target) | 49 if (target) |
| 49 target.animationAgent().setPlaybackRate(this._animationsPlayback Rate); | 50 target.animationModel.setPlaybackRate(this._animationsPlaybackRa te); |
| 50 this._playbackLabel.textContent = this._animationsPlaybackRate + "x" ; | 51 this._playbackLabel.textContent = this._animationsPlaybackRate + "x" ; |
| 51 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record(); | 52 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record(); |
| 52 if (this._scrubberPlayer) | 53 if (this._scrubberPlayer) |
| 53 this._scrubberPlayer.playbackRate = this._animationsPlaybackRate ; | 54 this._scrubberPlayer.playbackRate = this._animationsPlaybackRate ; |
| 54 } | 55 } |
| 55 | 56 |
| 56 var container = createElementWithClass("div", "animation-timeline-header "); | 57 var container = createElementWithClass("div", "animation-timeline-header "); |
| 57 var controls = container.createChild("div", "animation-controls"); | 58 var controls = container.createChild("div", "animation-controls"); |
| 58 container.createChild("div", "animation-timeline-markers"); | 59 container.createChild("div", "animation-timeline-markers"); |
| 59 | 60 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 { | 165 { |
| 165 this._reset(); | 166 this._reset(); |
| 166 this._updateAnimationsPlaybackRate(); | 167 this._updateAnimationsPlaybackRate(); |
| 167 if (this._scrubberPlayer) | 168 if (this._scrubberPlayer) |
| 168 this._scrubberPlayer.cancel(); | 169 this._scrubberPlayer.cancel(); |
| 169 delete this._scrubberPlayer; | 170 delete this._scrubberPlayer; |
| 170 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.mi llisToString(0)); | 171 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.mi llisToString(0)); |
| 171 }, | 172 }, |
| 172 | 173 |
| 173 /** | 174 /** |
| 175 * @param {!WebInspector.Event} event | |
| 176 */ | |
| 177 _frameAdded: function(event) | |
| 178 { | |
| 179 var target = WebInspector.targetManager.mainTarget(); | |
| 180 if (target && this._animationsPlaybackRate) | |
| 181 target.animationModel.setPlaybackRate(this._animationsPlaybackRate); | |
|
pfeldman
2015/04/14 09:37:53
You want to instrument it on the backend and set c
samli
2015/04/15 03:19:16
Done. PTAL, couldn't use the regular frame added i
| |
| 182 }, | |
| 183 | |
| 184 /** | |
| 174 * @param {!WebInspector.AnimationModel.AnimationPlayer} animation | 185 * @param {!WebInspector.AnimationModel.AnimationPlayer} animation |
| 175 * @param {boolean} resetTimeline | 186 * @param {boolean} resetTimeline |
| 176 */ | 187 */ |
| 177 addAnimation: function(animation, resetTimeline) | 188 addAnimation: function(animation, resetTimeline) |
| 178 { | 189 { |
| 179 /** | 190 /** |
| 180 * @param {?WebInspector.DOMNode} node | 191 * @param {?WebInspector.DOMNode} node |
| 181 * @this {WebInspector.AnimationTimeline} | 192 * @this {WebInspector.AnimationTimeline} |
| 182 */ | 193 */ |
| 183 function nodeResolved(node) | 194 function nodeResolved(node) |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 if (!this._scrubberPlayer) | 370 if (!this._scrubberPlayer) |
| 360 return false; | 371 return false; |
| 361 | 372 |
| 362 this._originalScrubberTime = this._scrubberPlayer.currentTime; | 373 this._originalScrubberTime = this._scrubberPlayer.currentTime; |
| 363 this._timelineScrubber.classList.remove("animation-timeline-end"); | 374 this._timelineScrubber.classList.remove("animation-timeline-end"); |
| 364 this._scrubberPlayer.pause(); | 375 this._scrubberPlayer.pause(); |
| 365 this._originalMousePosition = new WebInspector.Geometry.Point(event.x, e vent.y); | 376 this._originalMousePosition = new WebInspector.Geometry.Point(event.x, e vent.y); |
| 366 | 377 |
| 367 var target = WebInspector.targetManager.mainTarget(); | 378 var target = WebInspector.targetManager.mainTarget(); |
| 368 if (target) | 379 if (target) |
| 369 target.animationAgent().setPlaybackRate(0); | 380 target.animationModel.setPlaybackRate(0); |
| 370 return true; | 381 return true; |
| 371 }, | 382 }, |
| 372 | 383 |
| 373 /** | 384 /** |
| 374 * @param {!Event} event | 385 * @param {!Event} event |
| 375 */ | 386 */ |
| 376 _scrubberDragMove: function(event) | 387 _scrubberDragMove: function(event) |
| 377 { | 388 { |
| 378 var delta = event.x - this._originalMousePosition.x; | 389 var delta = event.x - this._originalMousePosition.x; |
| 379 this._scrubberPlayer.currentTime = Math.min(this._originalScrubberTime + delta / this.pixelMsRatio(), this.duration() - this._scrubberRadius / this.pixe lMsRatio()); | 390 this._scrubberPlayer.currentTime = Math.min(this._originalScrubberTime + delta / this.pixelMsRatio(), this.duration() - this._scrubberRadius / this.pixe lMsRatio()); |
| 380 var currentTime = Math.max(0, Math.round(this._scrubberPlayer.currentTim e)); | 391 var currentTime = Math.max(0, Math.round(this._scrubberPlayer.currentTim e)); |
| 381 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.mi llisToString(currentTime)); | 392 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.mi llisToString(currentTime)); |
| 382 var targets = WebInspector.targetManager.targets(); | 393 var targets = WebInspector.targetManager.targets(); |
| 383 for (var target of targets) | 394 for (var target of targets) |
| 384 target.animationAgent().setCurrentTime(/** @type {number} */(this.st artTime() + currentTime)); | 395 target.animationAgent().setCurrentTime(/** @type {number} */(this.st artTime() + currentTime)); |
| 385 }, | 396 }, |
| 386 | 397 |
| 387 /** | 398 /** |
| 388 * @param {!Event} event | 399 * @param {!Event} event |
| 389 */ | 400 */ |
| 390 _scrubberDragEnd: function(event) | 401 _scrubberDragEnd: function(event) |
| 391 { | 402 { |
| 392 if (this._scrubberPlayer.currentTime < this.duration() - this._scrubberR adius / this.pixelMsRatio()) | 403 if (this._scrubberPlayer.currentTime < this.duration() - this._scrubberR adius / this.pixelMsRatio()) |
| 393 this._scrubberPlayer.play(); | 404 this._scrubberPlayer.play(); |
| 394 this._timelineScrubberHead.window().requestAnimationFrame(this._updateSc rubber.bind(this)); | 405 this._timelineScrubberHead.window().requestAnimationFrame(this._updateSc rubber.bind(this)); |
| 395 var target = WebInspector.targetManager.mainTarget(); | 406 var target = WebInspector.targetManager.mainTarget(); |
| 396 if (target) | 407 if (target) |
| 397 target.animationAgent().setPlaybackRate(this._animationsPlaybackRate ); | 408 target.animationModel.setPlaybackRate(this._animationsPlaybackRate); |
| 398 }, | 409 }, |
| 399 | 410 |
| 400 __proto__: WebInspector.VBox.prototype | 411 __proto__: WebInspector.VBox.prototype |
| 401 } | 412 } |
| 402 | 413 |
| 403 /** | 414 /** |
| 404 * @constructor | 415 * @constructor |
| 405 * @param {!WebInspector.AnimationModel.AnimationNode} animationNode | 416 * @param {!WebInspector.AnimationModel.AnimationNode} animationNode |
| 406 */ | 417 */ |
| 407 WebInspector.AnimationTimeline.NodeUI = function(animationNode) { | 418 WebInspector.AnimationTimeline.NodeUI = function(animationNode) { |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 895 "Light Blue": WebInspector.Color.parse("#03A9F4"), | 906 "Light Blue": WebInspector.Color.parse("#03A9F4"), |
| 896 "Deep Orange": WebInspector.Color.parse("#FF5722"), | 907 "Deep Orange": WebInspector.Color.parse("#FF5722"), |
| 897 "Blue": WebInspector.Color.parse("#5677FC"), | 908 "Blue": WebInspector.Color.parse("#5677FC"), |
| 898 "Lime": WebInspector.Color.parse("#CDDC39"), | 909 "Lime": WebInspector.Color.parse("#CDDC39"), |
| 899 "Blue Grey": WebInspector.Color.parse("#607D8B"), | 910 "Blue Grey": WebInspector.Color.parse("#607D8B"), |
| 900 "Pink": WebInspector.Color.parse("#E91E63"), | 911 "Pink": WebInspector.Color.parse("#E91E63"), |
| 901 "Green": WebInspector.Color.parse("#0F9D58"), | 912 "Green": WebInspector.Color.parse("#0F9D58"), |
| 902 "Brown": WebInspector.Color.parse("#795548"), | 913 "Brown": WebInspector.Color.parse("#795548"), |
| 903 "Cyan": WebInspector.Color.parse("#00BCD4") | 914 "Cyan": WebInspector.Color.parse("#00BCD4") |
| 904 } | 915 } |
| OLD | NEW |