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

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: Collapse animation sections if there are a lot 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.SidebarPane} 7 * @extends {WebInspector.SidebarPane}
8 */ 8 */
9 WebInspector.AnimationsSidebarPane = function(stylesPane) 9 WebInspector.AnimationsSidebarPane = function(stylesPane)
10 { 10 {
11 WebInspector.SidebarPane.call(this, WebInspector.UIString("Animations")); 11 WebInspector.SidebarPane.call(this, WebInspector.UIString("Animations"));
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.bodyElement.appendChild(this._emptyElement); 23 this.bodyElement.appendChild(this.headerElement);
24 this.bodyElement.appendChild(this.animationsElement);
25 }
26
27 /**
28 * @return {!Element}
29 */
30 WebInspector.AnimationsSidebarPane._showSubtreeAnimationsCheckbox = function()
31 {
32 if (!WebInspector.AnimationsSidebarPane._showSubtreeAnimationsCheckboxElemen t) {
33 WebInspector.AnimationsSidebarPane._showSubtreeAnimationsCheckboxElement = WebInspector.SettingsUI.createSettingCheckbox(WebInspector.UIString("Show sub tree animations"), WebInspector.settings.showSubtreeAnimations, true);
34 WebInspector.AnimationsSidebarPane._showSubtreeAnimationsCheckboxElement .classList.add("checkbox-with-label");
35 }
36 return WebInspector.AnimationsSidebarPane._showSubtreeAnimationsCheckboxElem ent;
19 } 37 }
20 38
21 WebInspector.AnimationsSidebarPane.prototype = { 39 WebInspector.AnimationsSidebarPane.prototype = {
40 _showSubtreeAnimationsChanged: function()
41 {
42 this.update(this._selectedNode, true);
43 },
44
22 /** 45 /**
23 * @param {?WebInspector.DOMNode} node 46 * @param {?WebInspector.DOMNode} node
47 * @param {boolean=} forceUpdate
24 */ 48 */
25 update: function(node) 49 update: function(node, forceUpdate)
26 { 50 {
27 /** 51 /**
28 * @param {?Array.<!WebInspector.AnimationModel.AnimationPlayer>} animat ionPlayers 52 * @param {?Array.<!WebInspector.AnimationModel.AnimationPlayer>} animat ionPlayers
29 * @this {WebInspector.AnimationsSidebarPane} 53 * @this {WebInspector.AnimationsSidebarPane}
30 */ 54 */
31 function animationPlayersCallback(animationPlayers) 55 function animationPlayersCallback(animationPlayers)
32 { 56 {
33 this.bodyElement.removeChildren(); 57 this.animationsElement.removeChildren();
34 this._animationSections = []; 58 this._animationSections = [];
35 if (!animationPlayers || !animationPlayers.length) { 59 if (!animationPlayers || !animationPlayers.length) {
36 this.bodyElement.appendChild(this._emptyElement); 60 this.animationsElement.appendChild(this._emptyElement);
37 return; 61 return;
38 } 62 }
39
40 for (var i = 0; i < animationPlayers.length; ++i) { 63 for (var i = 0; i < animationPlayers.length; ++i) {
41 var player = animationPlayers[i]; 64 var player = animationPlayers[i];
42 this._animationSections[i] = new WebInspector.AnimationSection(t his, player); 65 this._animationSections[i] = new WebInspector.AnimationSection(t his, this._stylesPane, player);
vsevik 2014/11/05 09:48:37 Is there any specific order of the animations here
samli 2014/11/10 23:59:31 Currently they're sorted by sequence number, which
43 var separatorElement = this.bodyElement.createChild("div", "side bar-separator"); 66 if (animationPlayers.length < 5)
44 var id = player.source().name() ? player.source().name() : playe r.id(); 67 this._animationSections[i].expand(true);
45 separatorElement.createTextChild(WebInspector.UIString("Animatio n") + " " + id); 68 this.animationsElement.appendChild(this._animationSections[i].el ement);
46 this.bodyElement.appendChild(this._animationSections[i].element) ;
47
48 if (player.source().keyframesRule()) {
49 var keyframes = player.source().keyframesRule().keyframes();
50 for (var j = 0; j < keyframes.length; j++) {
51 var inlineStyle = { selectorText: keyframes[j].offset(), style: keyframes[j].style(), isAttribute: true };
52 var section = new WebInspector.StylePropertiesSection(th is._stylesPane, inlineStyle, true, false);
53 section.expanded = true;
54 this.bodyElement.appendChild(section.element);
55 }
56 }
57 } 69 }
58 } 70 }
59 71
60 if (!node) 72 if (!node)
61 return; 73 return;
62 74
63 if (this._selectedNode === node) { 75 if (!forceUpdate && this._selectedNode === node) {
64 for (var i = 0; i < this._animationSections.length; ++i) 76 for (var i = 0; i < this._animationSections.length; ++i)
65 this._animationSections[i].updateCurrentTime(); 77 this._animationSections[i].updateCurrentTime();
66 return; 78 return;
67 } 79 }
80
68 this._selectedNode = node; 81 this._selectedNode = node;
69 node.target().animationModel.animationPlayers(node.id, animationPlayersC allback.bind(this)); 82 node.target().animationModel.animationPlayers(node.id, WebInspector.sett ings.showSubtreeAnimations.get(), animationPlayersCallback.bind(this));
70 }, 83 },
71 __proto__: WebInspector.SidebarPane.prototype 84 __proto__: WebInspector.SidebarPane.prototype
72 } 85 }
73 86
74 /** 87 /**
75 * @constructor 88 * @constructor
76 * @param {!WebInspector.AnimationsSidebarPane} parentPane 89 * @param {!WebInspector.AnimationsSidebarPane} parentPane
90 * @param {!WebInspector.StylesSidebarPane} stylesPane
77 * @param {?WebInspector.AnimationModel.AnimationPlayer} animationPlayer 91 * @param {?WebInspector.AnimationModel.AnimationPlayer} animationPlayer
78 */ 92 */
79 WebInspector.AnimationSection = function(parentPane, animationPlayer) 93 WebInspector.AnimationSection = function(parentPane, stylesPane, animationPlayer )
80 { 94 {
81 this._parentPane = parentPane; 95 this._parentPane = parentPane;
82 this.propertiesSection = createElement("div"); 96 this._stylesPane = stylesPane;
97 this._propertiesElement = createElement("div");
98 this._keyframesElement = createElement("div");
83 this._setAnimationPlayer(animationPlayer); 99 this._setAnimationPlayer(animationPlayer);
84 100
101 this._updateThrottler = new WebInspector.Throttler(WebInspector.AnimationSec tion.updateTimeout);
102
85 this.element = createElement("div"); 103 this.element = createElement("div");
86 this.element.className = "styles-section"; 104 this.element.appendChild(this._createHeader());
87 105 this.bodyElement = this.element.createChild("div", "animationSectionBody");
88 this._updateThrottler = new WebInspector.Throttler(WebInspector.AnimationSec tion.updateTimeout); 106 this.bodyElement.appendChild(this._createAnimationControls());
89 this.element.appendChild(this._createAnimationControls()); 107 this.bodyElement.appendChild(this._propertiesElement);
90 this.element.appendChild(this.propertiesSection); 108 this.bodyElement.appendChild(this._keyframesElement);
91 } 109 }
92 110
93 WebInspector.AnimationSection.updateTimeout = 100; 111 WebInspector.AnimationSection.updateTimeout = 100;
94 112
95 WebInspector.AnimationSection.prototype = { 113 WebInspector.AnimationSection.prototype = {
96 updateCurrentTime: function() 114 /**
115 * @return {boolean}
116 */
117 expanded: function()
97 { 118 {
98 this._updateThrottler.schedule(this._updateCurrentTime.bind(this), false ); 119 return this.bodyElement.classList.contains("expanded");
120 },
121
122 toggle: function()
123 {
124 this.bodyElement.classList.toggle("expanded");
99 }, 125 },
100 126
101 /** 127 /**
128 * @param {boolean} expand
129 */
130 expand: function(expand)
131 {
132 if (expand) {
133 this.bodyElement.classList.add("expanded");
134 this.updateCurrentTime();
135 } else {
136 this.bodyElement.classList.remove("expanded");
137 }
138 },
139
140 updateCurrentTime: function()
141 {
142 if (this.expanded)
143 this._updateThrottler.schedule(this._updateCurrentTime.bind(this), f alse);
144 },
145
146 /**
102 * @param {!WebInspector.Throttler.FinishCallback} finishCallback 147 * @param {!WebInspector.Throttler.FinishCallback} finishCallback
103 */ 148 */
104 _updateCurrentTime: function(finishCallback) 149 _updateCurrentTime: function(finishCallback)
105 { 150 {
106 /** 151 /**
107 * @param {number} currentTime 152 * @param {number} currentTime
108 * @param {boolean} isRunning 153 * @param {boolean} isRunning
109 * @this {WebInspector.AnimationSection} 154 * @this {WebInspector.AnimationSection}
110 */ 155 */
111 function updateSliderCallback(currentTime, isRunning) 156 function updateSliderCallback(currentTime, isRunning)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 194 }
150 195
151 slider.addEventListener("input", sliderInputHandler.bind(this)); 196 slider.addEventListener("input", sliderInputHandler.bind(this));
152 this.updateCurrentTime(); 197 this.updateCurrentTime();
153 return slider; 198 return slider;
154 }, 199 },
155 200
156 /** 201 /**
157 * @return {!Element} 202 * @return {!Element}
158 */ 203 */
204 _createHeader: function()
205 {
206 var headerElement = createElementWithClass("div", "sidebar-separator");
207 var id = this.player.source().name() ? this.player.source().name() : thi s.player.id();
208 headerElement.createTextChild(WebInspector.UIString("Animation") + " " + id);
209 var animationTargetNode = this.player.source().node();
210 headerElement.addEventListener("mouseover", animationTargetNode.highligh t.bind(animationTargetNode, undefined, undefined), false);
211 headerElement.addEventListener("mouseleave", animationTargetNode.domMode l().hideDOMNodeHighlight.bind(animationTargetNode.domModel()), false);
212 headerElement.addEventListener("click", this.toggle.bind(this), false);
213 return headerElement;
214 },
215
216 /**
217 * @return {!Element}
218 */
159 _createAnimationControls: function() 219 _createAnimationControls: function()
160 { 220 {
161 /** 221 /**
162 * @this {WebInspector.AnimationSection} 222 * @this {WebInspector.AnimationSection}
163 */ 223 */
164 function pauseButtonHandler() 224 function pauseButtonHandler()
165 { 225 {
166 if (this.player.paused()) { 226 if (this.player.paused()) {
167 this.player.play(this._setAnimationPlayer.bind(this)); 227 this.player.play(this._setAnimationPlayer.bind(this));
168 updatePauseButton.call(this, false); 228 updatePauseButton.call(this, false);
(...skipping 28 matching lines...) Expand all
197 }, 257 },
198 258
199 /** 259 /**
200 * @param {?WebInspector.AnimationModel.AnimationPlayer} p 260 * @param {?WebInspector.AnimationModel.AnimationPlayer} p
201 */ 261 */
202 _setAnimationPlayer: function(p) 262 _setAnimationPlayer: function(p)
203 { 263 {
204 if (!p || p === this.player) 264 if (!p || p === this.player)
205 return; 265 return;
206 this.player = p; 266 this.player = p;
207 this.propertiesSection.removeChildren(); 267 this._propertiesElement.removeChildren();
208 var animationObject = { 268 var animationObject = {
209 "playState": p.playState(), 269 "playState": p.playState(),
210 "start-time": p.startTime(), 270 "start-time": p.startTime(),
211 "player-playback-rate": p.playbackRate(), 271 "player-playback-rate": p.playbackRate(),
212 "id": p.id(), 272 "id": p.id(),
213 "start-delay": p.source().startDelay(), 273 "start-delay": p.source().startDelay(),
214 "playback-rate": p.source().playbackRate(), 274 "playback-rate": p.source().playbackRate(),
215 "iteration-start": p.source().iterationStart(), 275 "iteration-start": p.source().iterationStart(),
216 "iteration-count": p.source().iterationCount(), 276 "iteration-count": p.source().iterationCount(),
217 "duration": p.source().duration(), 277 "duration": p.source().duration(),
218 "direction": p.source().direction(), 278 "direction": p.source().direction(),
219 "fill-mode": p.source().fillMode(), 279 "fill-mode": p.source().fillMode(),
220 "time-fraction": p.source().timeFraction() 280 "time-fraction": p.source().timeFraction()
221 }; 281 };
222 var obj = WebInspector.RemoteObject.fromLocalObject(animationObject); 282 var obj = WebInspector.RemoteObject.fromLocalObject(animationObject);
223 var section = new WebInspector.ObjectPropertiesSection(obj, WebInspector .UIString("Animation Properties")); 283 var objSection = new WebInspector.ObjectPropertiesSection(obj, WebInspec tor.UIString("Animation Properties"));
224 this.propertiesSection.appendChild(section.element); 284 this._propertiesElement.appendChild(objSection.element);
285
286 if (this.player.source().keyframesRule()) {
287 var keyframes = this.player.source().keyframesRule().keyframes();
288 for (var j = 0; j < keyframes.length; j++) {
289 var inlineStyle = { selectorText: keyframes[j].offset(), style: keyframes[j].style(), isAttribute: true };
290 var styleSection = new WebInspector.StylePropertiesSection(this. _stylesPane, inlineStyle, true, false);
291 styleSection.expanded = true;
292 this._keyframesElement.appendChild(styleSection.element);
293 }
294 }
225 } 295 }
226 } 296 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698