Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: Source/devtools/front_end/animation/AnimationControlPane.js

Issue 1176413002: Devtools: Fix disabled element state pane button after reloading (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/devtools/front_end/elements/ElementStatePaneWidget.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * @extends {WebInspector.StylesSidebarPane.BaseToolbarPaneWidget}
8 */ 8 */
9 WebInspector.AnimationControlPane = function(toolbarItem) 9 WebInspector.AnimationControlPane = function(toolbarItem)
10 { 10 {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 if (this._target) 74 if (this._target)
75 this._target.animationAgent().getPlaybackRate(setPlaybackRate.bind(t his)); 75 this._target.animationAgent().getPlaybackRate(setPlaybackRate.bind(t his));
76 }, 76 },
77 77
78 /** 78 /**
79 * @override 79 * @override
80 * @param {?WebInspector.DOMNode} node 80 * @param {?WebInspector.DOMNode} node
81 */ 81 */
82 onNodeChanged: function(node) 82 onNodeChanged: function(node)
83 { 83 {
84 if (!node) { 84 if (!node)
85 this.detach();
86 return; 85 return;
87 }
88 86
89 if (this._target) 87 if (this._target)
90 this._target.resourceTreeModel.removeEventListener(WebInspector.Reso urceTreeModel.EventTypes.MainFrameNavigated, this._updateAnimationsPlaybackRate, this); 88 this._target.resourceTreeModel.removeEventListener(WebInspector.Reso urceTreeModel.EventTypes.MainFrameNavigated, this._updateAnimationsPlaybackRate, this);
91 89
92 this._target = node.target(); 90 this._target = node.target();
93 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.MainFrameNavigated, this._updateAnimationsPlaybackRate, this); 91 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTre eModel.EventTypes.MainFrameNavigated, this._updateAnimationsPlaybackRate, this);
94 this._updateAnimationsPlaybackRate(); 92 this._updateAnimationsPlaybackRate();
95 }, 93 },
96 94
97 __proto__: WebInspector.StylesSidebarPane.BaseToolbarPaneWidget.prototype 95 __proto__: WebInspector.StylesSidebarPane.BaseToolbarPaneWidget.prototype
98 } 96 }
99 97
100 /** 98 /**
101 * @constructor 99 * @constructor
102 * @implements {WebInspector.ToolbarItem.Provider} 100 * @implements {WebInspector.ToolbarItem.Provider}
103 */ 101 */
104 WebInspector.AnimationControlPane.ButtonProvider = function() 102 WebInspector.AnimationControlPane.ButtonProvider = function()
105 { 103 {
106 this._button = new WebInspector.ToolbarButton(WebInspector.UIString("Animati ons Controls"), "animation-toolbar-item"); 104 this._button = new WebInspector.ToolbarButton(WebInspector.UIString("Animati ons Controls"), "animation-toolbar-item");
107 this._button.addEventListener("click", this._clicked, this); 105 this._button.addEventListener("click", this._clicked, this);
108 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this._nod eChanged, this); 106 WebInspector.context.addFlavorChangeListener(WebInspector.DOMNode, this._nod eChanged, this);
109 this._nodeChanged(); 107 this._nodeChanged();
110 } 108 }
111 109
112 WebInspector.AnimationControlPane.ButtonProvider.prototype = { 110 WebInspector.AnimationControlPane.ButtonProvider.prototype = {
113 _animationTimelineModeClick: function() 111 /**
112 * @param {boolean} toggleOn
113 */
114 _toggleAnimationTimelineMode: function(toggleOn)
114 { 115 {
115 if (!this._animationTimeline) 116 if (!this._animationTimeline)
116 this._animationTimeline = new WebInspector.AnimationTimeline(); 117 this._animationTimeline = new WebInspector.AnimationTimeline();
117 this._button.setToggled(!this._animationTimeline.isShowing()); 118 this._button.setToggled(toggleOn);
118 var elementsPanel = WebInspector.ElementsPanel.instance(); 119 var elementsPanel = WebInspector.ElementsPanel.instance();
119 elementsPanel.setWidgetBelowDOM(!this._animationTimeline.isShowing() ? t his._animationTimeline : null); 120 elementsPanel.setWidgetBelowDOM(toggleOn ? this._animationTimeline : nul l);
120 }, 121 },
121 122
122 _animationControlPaneModeClick: function() 123 /**
124 * @param {boolean} toggleOn
125 */
126 _toggleAnimationControlPaneMode: function(toggleOn)
123 { 127 {
124 if (!this._animationsControlPane) 128 if (!this._animationsControlPane)
125 this._animationsControlPane = new WebInspector.AnimationControlPane( this.item()); 129 this._animationsControlPane = new WebInspector.AnimationControlPane( this.item());
126 var stylesSidebarPane = WebInspector.ElementsPanel.instance().sidebarPan es.styles; 130 var stylesSidebarPane = WebInspector.ElementsPanel.instance().sidebarPan es.styles;
127 stylesSidebarPane.showToolbarPane(!this._animationsControlPane.isShowing () ? this._animationsControlPane : null); 131 stylesSidebarPane.showToolbarPane(toggleOn ? this._animationsControlPane : null);
128 }, 132 },
129 133
130 _clicked: function() 134 _clicked: function()
131 { 135 {
132 if (Runtime.experiments.isEnabled("animationInspection")) 136 if (Runtime.experiments.isEnabled("animationInspection"))
133 this._animationTimelineModeClick(); 137 this._toggleAnimationTimelineMode(!this._button.toggled());
134 else 138 else
135 this._animationControlPaneModeClick(); 139 this._toggleAnimationControlPaneMode(!this._button.toggled());
136 }, 140 },
137 141
138 _nodeChanged: function() 142 _nodeChanged: function()
139 { 143 {
140 this._button.setEnabled(!!WebInspector.context.flavor(WebInspector.DOMNo de)); 144 var enabled = !!WebInspector.context.flavor(WebInspector.DOMNode);
145 this._button.setEnabled(enabled);
146 if (enabled)
147 return;
148
149 if (Runtime.experiments.isEnabled("animationInspection"))
150 this._toggleAnimationTimelineMode(false);
151 else
152 this._toggleAnimationControlPaneMode(false);
141 }, 153 },
142 154
143 /** 155 /**
144 * @override 156 * @override
145 * @return {!WebInspector.ToolbarItem} 157 * @return {!WebInspector.ToolbarItem}
146 */ 158 */
147 item: function() 159 item: function()
148 { 160 {
149 return this._button; 161 return this._button;
150 } 162 }
151 } 163 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/elements/ElementStatePaneWidget.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698