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

Side by Side Diff: Source/devtools/front_end/elements/AnimationsSidebarPane.js

Issue 682423002: Devtools Animations: Show subtree animations for a given node (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review changes Created 6 years, 1 month 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
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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.ElementsSidebarPane} 7 * @extends {WebInspector.ElementsSidebarPane}
8 */ 8 */
9 WebInspector.AnimationsSidebarPane = function(stylesPane) 9 WebInspector.AnimationsSidebarPane = function(stylesPane)
10 { 10 {
11 WebInspector.ElementsSidebarPane.call(this, WebInspector.UIString("Animation s")); 11 WebInspector.ElementsSidebarPane.call(this, WebInspector.UIString("Animation s"));
12 this._stylesPane = stylesPane; 12 this._stylesPane = stylesPane;
13 13
14 this.headerElement = createElementWithClass("div", "animationsSettings");
15 this.headerElement.appendChild(WebInspector.AnimationsSidebarPane._showSubtr eeAnimationsCheckbox());
16 WebInspector.settings.showSubtreeAnimations.addChangeListener(this._showSubt reeAnimationsChanged.bind(this));
14 this._emptyElement = createElement("div"); 17 this._emptyElement = createElement("div");
15 this._emptyElement.className = "info"; 18 this._emptyElement.className = "info";
16 this._emptyElement.textContent = WebInspector.UIString("No Animations"); 19 this._emptyElement.textContent = WebInspector.UIString("No Animations");
20 this.animationsElement = createElement("div");
21 this.animationsElement.appendChild(this._emptyElement);
17 22
18 this._animationSections = []; 23 this._animationSections = [];
19 24
20 this.bodyElement.appendChild(this._emptyElement); 25 this.bodyElement.appendChild(this.headerElement);
26 this.bodyElement.appendChild(this.animationsElement);
27 }
28
29 /**
30 * @return {!Element}
31 */
32 WebInspector.AnimationsSidebarPane._showSubtreeAnimationsCheckbox = function()
33 {
34 if (!WebInspector.AnimationsSidebarPane._showSubtreeAnimationsCheckboxElemen t) {
35 WebInspector.AnimationsSidebarPane._showSubtreeAnimationsCheckboxElement = WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Show sub tree animations"), WebInspector.settings.showSubtreeAnimations, true);
36 WebInspector.AnimationsSidebarPane._showSubtreeAnimationsCheckboxElement .classList.add("checkbox-with-label");
37 }
38 return WebInspector.AnimationsSidebarPane._showSubtreeAnimationsCheckboxElem ent;
21 } 39 }
22 40
23 WebInspector.AnimationsSidebarPane.prototype = { 41 WebInspector.AnimationsSidebarPane.prototype = {
42 _showSubtreeAnimationsChanged: function()
43 {
44 this._forceUpdate = true;
45 this.update();
46 },
47
24 /** 48 /**
25 * @param {!WebInspector.Throttler.FinishCallback} finishCallback 49 * @param {!WebInspector.Throttler.FinishCallback} finishCallback
26 * @protected 50 * @protected
27 */ 51 */
28 doUpdate: function(finishCallback) 52 doUpdate: function(finishCallback)
29 { 53 {
30 /** 54 /**
31 * @param {?Array.<!WebInspector.AnimationModel.AnimationPlayer>} animat ionPlayers 55 * @param {?Array.<!WebInspector.AnimationModel.AnimationPlayer>} animat ionPlayers
32 * @this {WebInspector.AnimationsSidebarPane} 56 * @this {WebInspector.AnimationsSidebarPane}
33 */ 57 */
34 function animationPlayersCallback(animationPlayers) 58 function animationPlayersCallback(animationPlayers)
35 { 59 {
36 this.bodyElement.removeChildren(); 60 this.animationsElement.removeChildren();
37 this._animationSections = []; 61 this._animationSections = [];
38 if (!animationPlayers || !animationPlayers.length) { 62 if (!animationPlayers || !animationPlayers.length) {
39 this.bodyElement.appendChild(this._emptyElement); 63 this.animationsElement.appendChild(this._emptyElement);
40 finishCallback(); 64 finishCallback();
41 return; 65 return;
42 } 66 }
43
44 for (var i = 0; i < animationPlayers.length; ++i) { 67 for (var i = 0; i < animationPlayers.length; ++i) {
45 var player = animationPlayers[i]; 68 var player = animationPlayers[i];
46 this._animationSections[i] = new WebInspector.AnimationSection(t his, player); 69 this._animationSections[i] = new WebInspector.AnimationSection(t his, this._stylesPane, player);
47 var separatorElement = this.bodyElement.createChild("div", "side bar-separator"); 70 if (animationPlayers.length < 5)
48 separatorElement.createTextChild(WebInspector.UIString("Animatio n") + " " + player.name()); 71 this._animationSections[i].expand(true);
49 this.bodyElement.appendChild(this._animationSections[i].element) ; 72 this.animationsElement.appendChild(this._animationSections[i].el ement);
50
51 if (player.source().keyframesRule()) {
52 var keyframes = player.source().keyframesRule().keyframes();
53 for (var j = 0; j < keyframes.length; j++) {
54 var style = { selectorText: keyframes[j].offset(), style : keyframes[j].style(), isAttribute: true };
55 var section = new WebInspector.StylePropertiesSection(th is._stylesPane, style, true, false);
56 section.expanded = true;
57 this.bodyElement.appendChild(section.element);
58 }
59 }
60 } 73 }
61 finishCallback(); 74 finishCallback();
62 } 75 }
63 76
64 if (!this.node()) 77 if (!this.node()) {
78 finishCallback();
65 return; 79 return;
66 this.node().target().animationModel.getAnimationPlayers(this.node().id, animationPlayersCallback.bind(this)); 80 }
81
82 if (!this._forceUpdate && this._selectedNode === this.node()) {
83 for (var i = 0; i < this._animationSections.length; ++i)
84 this._animationSections[i].updateCurrentTime();
85 finishCallback();
86 return;
87 }
88
89 this._forceUpdate = false;
90 this._selectedNode = this.node();
91 this.node().target().animationModel.animationPlayers(this.node().id, Web Inspector.settings.showSubtreeAnimations.get(), animationPlayersCallback.bind(th is));
67 }, 92 },
68 93
69 __proto__: WebInspector.ElementsSidebarPane.prototype 94 __proto__: WebInspector.ElementsSidebarPane.prototype
70 } 95 }
71 96
72 /** 97 /**
73 * @constructor 98 * @constructor
74 * @param {!WebInspector.AnimationsSidebarPane} parentPane 99 * @param {!WebInspector.AnimationsSidebarPane} parentPane
100 * @param {!WebInspector.StylesSidebarPane} stylesPane
75 * @param {?WebInspector.AnimationModel.AnimationPlayer} animationPlayer 101 * @param {?WebInspector.AnimationModel.AnimationPlayer} animationPlayer
76 */ 102 */
77 WebInspector.AnimationSection = function(parentPane, animationPlayer) 103 WebInspector.AnimationSection = function(parentPane, stylesPane, animationPlayer )
78 { 104 {
79 this._parentPane = parentPane; 105 this._parentPane = parentPane;
80 this.propertiesSection = createElement("div"); 106 this._stylesPane = stylesPane;
107 this._propertiesElement = createElement("div");
108 this._keyframesElement = createElement("div");
81 this._setAnimationPlayer(animationPlayer); 109 this._setAnimationPlayer(animationPlayer);
82 110
111 this._updateThrottler = new WebInspector.Throttler(WebInspector.AnimationSec tion.updateTimeout);
112
83 this.element = createElement("div"); 113 this.element = createElement("div");
84 this.element.className = "styles-section"; 114 this.element.appendChild(this._createHeader());
85 115 this.bodyElement = this.element.createChild("div", "animationSectionBody");
86 this._updateThrottler = new WebInspector.Throttler(WebInspector.AnimationSec tion.updateTimeout); 116 this.bodyElement.appendChild(this._createAnimationControls());
87 this.element.appendChild(this._createAnimationControls()); 117 this.bodyElement.appendChild(this._propertiesElement);
88 this.element.appendChild(this.propertiesSection); 118 this.bodyElement.appendChild(this._keyframesElement);
89 } 119 }
90 120
91 WebInspector.AnimationSection.updateTimeout = 100; 121 WebInspector.AnimationSection.updateTimeout = 100;
92 122
93 WebInspector.AnimationSection.prototype = { 123 WebInspector.AnimationSection.prototype = {
94 updateCurrentTime: function() 124 /**
125 * @return {boolean}
126 */
127 expanded: function()
vsevik 2014/11/12 09:14:35 Can we make it private?
samli 2014/11/13 01:12:43 Done.
95 { 128 {
96 this._updateThrottler.schedule(this._updateCurrentTime.bind(this), false ); 129 return this.bodyElement.classList.contains("expanded");
130 },
131
132 toggle: function()
vsevik 2014/11/12 09:14:35 Can we make it private?
samli 2014/11/13 01:12:43 Done.
133 {
134 this.bodyElement.classList.toggle("expanded");
97 }, 135 },
98 136
99 /** 137 /**
138 * @param {boolean} expand
139 */
140 expand: function(expand)
141 {
142 if (expand) {
vsevik 2014/11/12 09:14:35 this.bodyElement.classList.toggle("expanded", expa
samli 2014/11/13 01:12:43 Done.
143 this.bodyElement.classList.add("expanded");
144 this.updateCurrentTime();
145 } else {
146 this.bodyElement.classList.remove("expanded");
147 }
148 },
149
150 updateCurrentTime: function()
151 {
152 if (this.expanded)
vsevik 2014/11/12 09:14:35 this.expanded is a function, it is always true :)
samli 2014/11/13 01:12:44 Done.
153 this._updateThrottler.schedule(this._updateCurrentTime.bind(this), f alse);
154 },
155
156 /**
100 * @param {!WebInspector.Throttler.FinishCallback} finishCallback 157 * @param {!WebInspector.Throttler.FinishCallback} finishCallback
101 */ 158 */
102 _updateCurrentTime: function(finishCallback) 159 _updateCurrentTime: function(finishCallback)
103 { 160 {
104 /** 161 /**
105 * @param {number} currentTime 162 * @param {number} currentTime
106 * @param {boolean} isRunning 163 * @param {boolean} isRunning
107 * @this {WebInspector.AnimationSection} 164 * @this {WebInspector.AnimationSection}
108 */ 165 */
109 function updateSliderCallback(currentTime, isRunning) 166 function updateSliderCallback(currentTime, isRunning)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 204 }
148 205
149 slider.addEventListener("input", sliderInputHandler.bind(this)); 206 slider.addEventListener("input", sliderInputHandler.bind(this));
150 this.updateCurrentTime(); 207 this.updateCurrentTime();
151 return slider; 208 return slider;
152 }, 209 },
153 210
154 /** 211 /**
155 * @return {!Element} 212 * @return {!Element}
156 */ 213 */
214 _createHeader: function()
215 {
216 /**
217 * @param {?WebInspector.DOMNode} node
218 */
219 function nodeResolved(node)
220 {
221 headerElement.addEventListener("mouseover", node.highlight.bind(node , undefined, undefined), false);
222 headerElement.addEventListener("mouseleave", node.domModel().hideDOM NodeHighlight.bind(node.domModel()), false);
vsevik 2014/11/12 09:14:35 I think we should also add a node description with
samli 2014/11/13 01:12:44 I agree, but I think we need to agree on a UI for
223 }
224
225 var headerElement = createElementWithClass("div", "sidebar-separator");
226 var id = this.player.source().name() ? this.player.source().name() : thi s.player.id();
227 headerElement.createTextChild(WebInspector.UIString("Animation") + " " + id);
228 headerElement.addEventListener("click", this.toggle.bind(this), false);
229 this.player.source().node(nodeResolved);
230 return headerElement;
231 },
232
233 /**
234 * @return {!Element}
235 */
157 _createAnimationControls: function() 236 _createAnimationControls: function()
158 { 237 {
159 /** 238 /**
160 * @this {WebInspector.AnimationSection} 239 * @this {WebInspector.AnimationSection}
161 */ 240 */
162 function pauseButtonHandler() 241 function pauseButtonHandler()
163 { 242 {
164 if (this.player.paused()) { 243 if (this.player.paused()) {
165 this.player.play(this._setAnimationPlayer.bind(this)); 244 this.player.play(this._setAnimationPlayer.bind(this));
166 updatePauseButton.call(this, false); 245 updatePauseButton.call(this, false);
(...skipping 28 matching lines...) Expand all
195 }, 274 },
196 275
197 /** 276 /**
198 * @param {?WebInspector.AnimationModel.AnimationPlayer} p 277 * @param {?WebInspector.AnimationModel.AnimationPlayer} p
199 */ 278 */
200 _setAnimationPlayer: function(p) 279 _setAnimationPlayer: function(p)
201 { 280 {
202 if (!p || p === this.player) 281 if (!p || p === this.player)
203 return; 282 return;
204 this.player = p; 283 this.player = p;
205 this.propertiesSection.removeChildren(); 284 this._propertiesElement.removeChildren();
206 var animationObject = { 285 var animationObject = {
207 "playState": p.playState(), 286 "playState": p.playState(),
208 "start-time": p.startTime(), 287 "start-time": p.startTime(),
209 "player-playback-rate": p.playbackRate(), 288 "player-playback-rate": p.playbackRate(),
210 "id": p.id(), 289 "id": p.id(),
211 "start-delay": p.source().startDelay(), 290 "start-delay": p.source().startDelay(),
212 "playback-rate": p.source().playbackRate(), 291 "playback-rate": p.source().playbackRate(),
213 "iteration-start": p.source().iterationStart(), 292 "iteration-start": p.source().iterationStart(),
214 "iteration-count": p.source().iterationCount(), 293 "iteration-count": p.source().iterationCount(),
215 "duration": p.source().duration(), 294 "duration": p.source().duration(),
216 "direction": p.source().direction(), 295 "direction": p.source().direction(),
217 "fill-mode": p.source().fillMode(), 296 "fill-mode": p.source().fillMode(),
218 "time-fraction": p.source().timeFraction() 297 "time-fraction": p.source().timeFraction()
219 }; 298 };
220 var obj = WebInspector.RemoteObject.fromLocalObject(animationObject); 299 var obj = WebInspector.RemoteObject.fromLocalObject(animationObject);
221 var section = new WebInspector.ObjectPropertiesSection(obj, WebInspector .UIString("Animation Properties")); 300 var objSection = new WebInspector.ObjectPropertiesSection(obj, WebInspec tor.UIString("Animation Properties"));
222 this.propertiesSection.appendChild(section.element); 301 this._propertiesElement.appendChild(objSection.element);
302
303 if (this.player.source().keyframesRule()) {
304 var keyframes = this.player.source().keyframesRule().keyframes();
305 for (var j = 0; j < keyframes.length; j++) {
306 var inlineStyle = { selectorText: keyframes[j].offset(), style: keyframes[j].style(), isAttribute: true };
307 var styleSection = new WebInspector.StylePropertiesSection(this. _stylesPane, inlineStyle, true, false);
308 styleSection.expanded = true;
309 this._keyframesElement.appendChild(styleSection.element);
310 }
311 }
223 } 312 }
224 } 313 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698