Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/animation/AnimationTimeline.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/animation/AnimationTimeline.js b/third_party/WebKit/Source/devtools/front_end/animation/AnimationTimeline.js |
| index 5e29669b0064b2473e20c936cd56e848fa779aec..8e9c79309c9930a21395a82814e71f36437d4bb3 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/animation/AnimationTimeline.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/animation/AnimationTimeline.js |
| @@ -15,7 +15,8 @@ WebInspector.AnimationTimeline = function() |
| this._grid = this.contentElement.createSVGChild("svg", "animation-timeline-grid"); |
| - this._underlyingPlaybackRate = 1; |
| + this._playbackRate = 1; |
| + this._allPaused = false; |
| this._createHeader(); |
| this._animationsContainer = this.contentElement.createChild("div", "animation-timeline-rows"); |
| var timelineHint = this.contentElement.createChild("div", "animation-timeline-rows-hint"); |
| @@ -127,11 +128,15 @@ WebInspector.AnimationTimeline.prototype = { |
| topToolbar.appendToolbarItem(clearButton); |
| topToolbar.appendSeparator(); |
| + this._pauseButton = new WebInspector.ToolbarButton(WebInspector.UIString("Pause all"), "pause-toolbar-item"); |
|
dgozman
2016/05/09 22:20:27
ToolbarToggle
pfeldman
2016/05/09 22:55:52
Done.
|
| + this._pauseButton.addEventListener("click", this._togglePauseAll.bind(this)); |
| + topToolbar.appendToolbarItem(this._pauseButton); |
| + |
| var playbackRateControl = toolbarContainer.createChild("div", "animation-playback-rate-control"); |
| this._playbackRateButtons = []; |
| for (var playbackRate of WebInspector.AnimationTimeline.GlobalPlaybackRates) { |
| var button = playbackRateControl.createChild("div", "animation-playback-rate-button"); |
| - button.textContent = WebInspector.UIString(playbackRate * 100 + "%"); |
| + button.textContent = playbackRate ? WebInspector.UIString(playbackRate * 100 + "%") : WebInspector.UIString("Pause"); |
| button.playbackRate = playbackRate; |
| button.addEventListener("click", this._setPlaybackRate.bind(this, playbackRate)); |
| button.title = WebInspector.UIString("Set speed to ") + button.textContent; |
| @@ -198,15 +203,23 @@ WebInspector.AnimationTimeline.prototype = { |
| { |
| }, |
| + _togglePauseAll: function() |
| + { |
| + this._allPaused = !this._allPaused; |
| + this._pauseButton.setState(this._allPaused ? "on" : "off"); |
|
dgozman
2016/05/09 22:20:27
setToggled
pfeldman
2016/05/09 22:55:51
Done.
|
| + this._setPlaybackRate(this._playbackRate); |
| + this._pauseButton.setTitle(this._allPaused ? WebInspector.UIString("Resume all") : WebInspector.UIString("Pause all")) |
|
dgozman
2016/05/09 22:20:27
style: semicolon missing
pfeldman
2016/05/09 22:55:52
Done.
|
| + }, |
| + |
| /** |
| * @param {number} playbackRate |
| */ |
| _setPlaybackRate: function(playbackRate) |
| { |
| - this._underlyingPlaybackRate = playbackRate; |
| + this._playbackRate = playbackRate; |
| var target = WebInspector.targetManager.mainTarget(); |
| if (target) |
| - WebInspector.AnimationModel.fromTarget(target).setPlaybackRate(this._underlyingPlaybackRate); |
| + WebInspector.AnimationModel.fromTarget(target).setPlaybackRate(this._allPaused ? 0 : this._playbackRate); |
| WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.AnimationsPlaybackRateChanged); |
| if (this._scrubberPlayer) |
| this._scrubberPlayer.playbackRate = this._effectivePlaybackRate(); |
| @@ -217,7 +230,7 @@ WebInspector.AnimationTimeline.prototype = { |
| _updatePlaybackControls: function() |
| { |
| for (var button of this._playbackRateButtons) { |
| - var selected = this._underlyingPlaybackRate === button.playbackRate; |
| + var selected = this._playbackRate === button.playbackRate; |
| button.classList.toggle("selected", selected); |
| } |
| }, |
| @@ -247,28 +260,12 @@ WebInspector.AnimationTimeline.prototype = { |
| } |
| }, |
| - _updateAnimationsPlaybackRate: function() |
| - { |
| - /** |
| - * @param {number} playbackRate |
| - * @this {WebInspector.AnimationTimeline} |
| - */ |
| - function syncPlaybackRate(playbackRate) |
| - { |
| - this._underlyingPlaybackRate = playbackRate || 1; |
| - this._updatePlaybackControls(); |
| - } |
| - |
| - for (var target of WebInspector.targetManager.targets(WebInspector.Target.Type.Page)) |
| - WebInspector.AnimationModel.fromTarget(target).playbackRatePromise().then(syncPlaybackRate.bind(this)); |
|
dgozman
2016/05/09 22:20:27
Remove playbackRatePromise and getPlaybackRate fro
|
| - }, |
| - |
| /** |
| * @return {number} |
| */ |
| _effectivePlaybackRate: function() |
| { |
| - return this._selectedGroup && this._selectedGroup.paused() ? 0 : this._underlyingPlaybackRate; |
| + return this._selectedGroup && this._selectedGroup.paused() ? 0 : this._playbackRate; |
| }, |
| /** |
| @@ -328,7 +325,12 @@ WebInspector.AnimationTimeline.prototype = { |
| _reset: function() |
| { |
| this._clearTimeline(); |
| - this._updateAnimationsPlaybackRate(); |
| + if (this._allPaused) { |
| + this._playbackRate = 1; |
| + this._togglePauseAll(); |
| + } else { |
| + this._setPlaybackRate(1); |
| + } |
| for (var group of this._groupBuffer) |
| group.release(); |
| this._groupBuffer = []; |