| 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.StylesSidebarPane.BaseToolbarPaneWidget} |
| 7 */ | 8 */ |
| 8 WebInspector.AnimationControlPane = function() | 9 WebInspector.AnimationControlPane = function(toolbarItem) |
| 9 { | 10 { |
| 11 WebInspector.StylesSidebarPane.BaseToolbarPaneWidget.call(this, toolbarItem)
; |
| 10 this._animationsPaused = false; | 12 this._animationsPaused = false; |
| 11 this._animationsPlaybackRate = 1; | 13 this._animationsPlaybackRate = 1; |
| 12 | 14 |
| 13 this.element = createElementWithClass("div", "styles-animations-controls-pan
e"); | 15 this.element.className = "styles-animations-controls-pane"; |
| 14 this.element.createChild("div").createTextChild("Animations"); | 16 this.element.createChild("div").createTextChild("Animations"); |
| 15 var container = this.element.createChild("div", "animations-controls"); | 17 var container = this.element.createChild("div", "animations-controls"); |
| 16 | 18 |
| 17 var toolbar = new WebInspector.Toolbar(); | 19 var toolbar = new WebInspector.Toolbar(); |
| 18 this._animationsPauseButton = new WebInspector.ToolbarButton("", "pause-tool
bar-item"); | 20 this._animationsPauseButton = new WebInspector.ToolbarButton("", "pause-tool
bar-item"); |
| 19 toolbar.appendToolbarItem(this._animationsPauseButton); | 21 toolbar.appendToolbarItem(this._animationsPauseButton); |
| 20 this._animationsPauseButton.addEventListener("click", this._pauseButtonHandl
er.bind(this)); | 22 this._animationsPauseButton.addEventListener("click", this._pauseButtonHandl
er.bind(this)); |
| 21 container.appendChild(toolbar.element); | 23 container.appendChild(toolbar.element); |
| 22 | 24 |
| 23 this._animationsPlaybackSlider = container.createChild("input"); | 25 this._animationsPlaybackSlider = container.createChild("input"); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 { | 69 { |
| 68 this._animationsPlaybackSlider.value = WebInspector.AnimationTimelin
e.GlobalPlaybackRates.indexOf(playbackRate); | 70 this._animationsPlaybackSlider.value = WebInspector.AnimationTimelin
e.GlobalPlaybackRates.indexOf(playbackRate); |
| 69 this._animationsPlaybackLabel.textContent = playbackRate + "x"; | 71 this._animationsPlaybackLabel.textContent = playbackRate + "x"; |
| 70 } | 72 } |
| 71 | 73 |
| 72 if (this._target) | 74 if (this._target) |
| 73 this._target.animationAgent().getPlaybackRate(setPlaybackRate.bind(t
his)); | 75 this._target.animationAgent().getPlaybackRate(setPlaybackRate.bind(t
his)); |
| 74 }, | 76 }, |
| 75 | 77 |
| 76 /** | 78 /** |
| 79 * @override |
| 77 * @param {?WebInspector.DOMNode} node | 80 * @param {?WebInspector.DOMNode} node |
| 78 */ | 81 */ |
| 79 setNode: function(node) | 82 onNodeChanged: function(node) |
| 80 { | 83 { |
| 81 if (!node) | 84 if (!node) { |
| 85 this.detach(); |
| 82 return; | 86 return; |
| 87 } |
| 83 | 88 |
| 84 if (this._target) | 89 if (this._target) |
| 85 this._target.resourceTreeModel.removeEventListener(WebInspector.Reso
urceTreeModel.EventTypes.MainFrameNavigated, this._updateAnimationsPlaybackRate,
this); | 90 this._target.resourceTreeModel.removeEventListener(WebInspector.Reso
urceTreeModel.EventTypes.MainFrameNavigated, this._updateAnimationsPlaybackRate,
this); |
| 86 | 91 |
| 87 this._target = node.target(); | 92 this._target = node.target(); |
| 88 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre
eModel.EventTypes.MainFrameNavigated, this._updateAnimationsPlaybackRate, this); | 93 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre
eModel.EventTypes.MainFrameNavigated, this._updateAnimationsPlaybackRate, this); |
| 89 this._updateAnimationsPlaybackRate(); | 94 this._updateAnimationsPlaybackRate(); |
| 95 }, |
| 96 |
| 97 __proto__: WebInspector.StylesSidebarPane.BaseToolbarPaneWidget.prototype |
| 98 } |
| 99 |
| 100 /** |
| 101 * @constructor |
| 102 * @implements {WebInspector.ToolbarItem.Provider} |
| 103 */ |
| 104 WebInspector.AnimationControlPane.ButtonProvider = function() |
| 105 { |
| 106 this._button = new WebInspector.ToolbarButton(WebInspector.UIString("Animati
ons Controls"), "animation-toolbar-item"); |
| 107 this._button.addEventListener("click", this._clicked, this); |
| 108 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this._nod
eChanged, this); |
| 109 this._nodeChanged(); |
| 110 } |
| 111 |
| 112 WebInspector.AnimationControlPane.ButtonProvider.prototype = { |
| 113 _animationTimelineModeClick: function() |
| 114 { |
| 115 if (!this._animationTimeline) |
| 116 this._animationTimeline = new WebInspector.AnimationTimeline(); |
| 117 this._button.setToggled(!this._animationTimeline.isShowing()); |
| 118 var elementsPanel = WebInspector.ElementsPanel.instance(); |
| 119 elementsPanel.setWidgetBelowDOM(!this._animationTimeline.isShowing() ? t
his._animationTimeline : null); |
| 120 }, |
| 121 |
| 122 _animationControlPaneModeClick: function() |
| 123 { |
| 124 if (!this._animationsControlPane) |
| 125 this._animationsControlPane = new WebInspector.AnimationControlPane(
this.item()); |
| 126 var stylesSidebarPane = WebInspector.ElementsPanel.instance().sidebarPan
es.styles; |
| 127 stylesSidebarPane.showToolbarPane(!this._animationsControlPane.isShowing
() ? this._animationsControlPane : null); |
| 128 }, |
| 129 |
| 130 _clicked: function() |
| 131 { |
| 132 if (Runtime.experiments.isEnabled("animationInspection")) |
| 133 this._animationTimelineModeClick(); |
| 134 else |
| 135 this._animationControlPaneModeClick(); |
| 136 }, |
| 137 |
| 138 _nodeChanged: function() |
| 139 { |
| 140 this._button.setEnabled(!!WebInspector.context.flavor(WebInspector.DOMNo
de)); |
| 141 }, |
| 142 |
| 143 /** |
| 144 * @override |
| 145 * @return {!WebInspector.ToolbarItem} |
| 146 */ |
| 147 item: function() |
| 148 { |
| 149 return this._button; |
| 90 } | 150 } |
| 91 | |
| 92 } | 151 } |
| OLD | NEW |