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 * @implements {SDK.TargetManager.Observer} | 5 * @implements {SDK.TargetManager.Observer} |
| 6 * @unrestricted | 6 * @unrestricted |
| 7 */ | 7 */ |
| 8 Animation.AnimationTimeline = class extends UI.VBox { | 8 Animation.AnimationTimeline = class extends UI.VBox { |
| 9 constructor() { | 9 constructor() { |
| 10 super(true); | 10 super(true); |
| 11 this.registerRequiredCSS('animation/animationTimeline.css'); | 11 this.registerRequiredCSS('animation/animationTimeline.css'); |
| 12 this.element.classList.add('animations-timeline'); | 12 this.element.classList.add('animations-timeline'); |
| 13 | 13 |
| 14 this._grid = this.contentElement.createSVGChild('svg', 'animation-timeline-g rid'); | 14 this._grid = this.contentElement.createSVGChild('svg', 'animation-timeline-g rid'); |
| 15 | 15 |
| 16 this._playbackRate = 1; | 16 this._playbackRateSetting = Common.settings.createSetting('animationPlayback Rate', 1); |
| 17 this._playbackRate = this._playbackRateSetting.get(); | |
| 17 this._allPaused = false; | 18 this._allPaused = false; |
| 18 this._createHeader(); | 19 this._createHeader(); |
| 19 this._animationsContainer = this.contentElement.createChild('div', 'animatio n-timeline-rows'); | 20 this._animationsContainer = this.contentElement.createChild('div', 'animatio n-timeline-rows'); |
| 20 var timelineHint = this.contentElement.createChild('div', 'animation-timelin e-rows-hint'); | 21 var timelineHint = this.contentElement.createChild('div', 'animation-timelin e-rows-hint'); |
| 21 timelineHint.textContent = Common.UIString('Select an effect above to inspec t and modify.'); | 22 timelineHint.textContent = Common.UIString('Select an effect above to inspec t and modify.'); |
| 22 | 23 |
| 23 /** @const */ this._defaultDuration = 100; | 24 /** @const */ this._defaultDuration = 100; |
| 24 this._duration = this._defaultDuration; | 25 this._duration = this._defaultDuration; |
| 25 /** @const */ this._timelineControlsWidth = 150; | 26 /** @const */ this._timelineControlsWidth = 150; |
| 26 /** @type {!Map.<!Protocol.DOM.BackendNodeId, !Animation.AnimationTimeline.N odeUI>} */ | 27 /** @type {!Map.<!Protocol.DOM.BackendNodeId, !Animation.AnimationTimeline.N odeUI>} */ |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 this._allPaused = !this._allPaused; | 211 this._allPaused = !this._allPaused; |
| 211 this._pauseButton.setToggled(this._allPaused); | 212 this._pauseButton.setToggled(this._allPaused); |
| 212 this._setPlaybackRate(this._playbackRate); | 213 this._setPlaybackRate(this._playbackRate); |
| 213 this._pauseButton.setTitle(this._allPaused ? Common.UIString('Resume all') : Common.UIString('Pause all')); | 214 this._pauseButton.setTitle(this._allPaused ? Common.UIString('Resume all') : Common.UIString('Pause all')); |
| 214 } | 215 } |
| 215 | 216 |
| 216 /** | 217 /** |
| 217 * @param {number} playbackRate | 218 * @param {number} playbackRate |
| 218 */ | 219 */ |
| 219 _setPlaybackRate(playbackRate) { | 220 _setPlaybackRate(playbackRate) { |
| 221 this._playbackRateSetting.set(playbackRate); | |
| 220 this._playbackRate = playbackRate; | 222 this._playbackRate = playbackRate; |
| 221 var target = SDK.targetManager.mainTarget(); | 223 var target = SDK.targetManager.mainTarget(); |
| 222 if (target) | 224 if (target) |
| 223 Animation.AnimationModel.fromTarget(target).setPlaybackRate(this._allPause d ? 0 : this._playbackRate); | 225 Animation.AnimationModel.fromTarget(target).setPlaybackRate(this._allPause d ? 0 : this._playbackRate); |
| 224 Host.userMetrics.actionTaken(Host.UserMetrics.Action.AnimationsPlaybackRateC hanged); | 226 Host.userMetrics.actionTaken(Host.UserMetrics.Action.AnimationsPlaybackRateC hanged); |
| 225 if (this._scrubberPlayer) | 227 if (this._scrubberPlayer) |
| 226 this._scrubberPlayer.playbackRate = this._effectivePlaybackRate(); | 228 this._scrubberPlayer.playbackRate = this._effectivePlaybackRate(); |
| 227 | 229 |
| 228 this._updatePlaybackControls(); | 230 this._updatePlaybackControls(); |
| 229 } | 231 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 delete this._selectedGroup; | 317 delete this._selectedGroup; |
| 316 if (this._scrubberPlayer) | 318 if (this._scrubberPlayer) |
| 317 this._scrubberPlayer.cancel(); | 319 this._scrubberPlayer.cancel(); |
| 318 delete this._scrubberPlayer; | 320 delete this._scrubberPlayer; |
| 319 this._currentTime.textContent = ''; | 321 this._currentTime.textContent = ''; |
| 320 this._updateControlButton(); | 322 this._updateControlButton(); |
| 321 } | 323 } |
| 322 | 324 |
| 323 _reset() { | 325 _reset() { |
| 324 this._clearTimeline(); | 326 this._clearTimeline(); |
| 325 if (this._allPaused) { | 327 if (this._allPaused) |
| 326 this._playbackRate = 1; | |
| 327 this._togglePauseAll(); | 328 this._togglePauseAll(); |
| 328 } else { | 329 else |
| 329 this._setPlaybackRate(1); | 330 this._setPlaybackRate(this._playbackRateSetting.get()); |
|
dgozman
2016/12/16 05:44:31
Setting is used to persist between DevTools reopen
einbinder
2016/12/16 22:37:05
I thought we wanted it to persist between devtools
| |
| 330 } | 331 |
| 331 for (var group of this._groupBuffer) | 332 for (var group of this._groupBuffer) |
| 332 group.release(); | 333 group.release(); |
| 333 this._groupBuffer = []; | 334 this._groupBuffer = []; |
| 334 this._previewMap.clear(); | 335 this._previewMap.clear(); |
| 335 this._previewContainer.removeChildren(); | 336 this._previewContainer.removeChildren(); |
| 336 this._popoverHelper.hidePopover(); | 337 this._popoverHelper.hidePopover(); |
| 337 this._renderGrid(); | 338 this._renderGrid(); |
| 338 } | 339 } |
| 339 | 340 |
| 340 /** | 341 /** |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 734 static parse(text) { | 735 static parse(text) { |
| 735 var match = text.match(/^steps\((\d+), (start|middle)\)$/); | 736 var match = text.match(/^steps\((\d+), (start|middle)\)$/); |
| 736 if (match) | 737 if (match) |
| 737 return new Animation.AnimationTimeline.StepTimingFunction(parseInt(match[1 ], 10), match[2]); | 738 return new Animation.AnimationTimeline.StepTimingFunction(parseInt(match[1 ], 10), match[2]); |
| 738 match = text.match(/^steps\((\d+)\)$/); | 739 match = text.match(/^steps\((\d+)\)$/); |
| 739 if (match) | 740 if (match) |
| 740 return new Animation.AnimationTimeline.StepTimingFunction(parseInt(match[1 ], 10), 'end'); | 741 return new Animation.AnimationTimeline.StepTimingFunction(parseInt(match[1 ], 10), 'end'); |
| 741 return null; | 742 return null; |
| 742 } | 743 } |
| 743 }; | 744 }; |
| OLD | NEW |