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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/timeline/TimelineFlameChartView.js

Issue 2690603003: Timeline: streamline flame chart views update logic (Closed)
Patch Set: moar fixes Created 3 years, 10 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 Timeline.FlameChartStyle = { 5 Timeline.FlameChartStyle = {
6 textColor: '#333' 6 textColor: '#333'
7 }; 7 };
8 8
9 /** 9 /**
10 * @enum {symbol} 10 * @enum {symbol}
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 this._model = null; 112 this._model = null;
113 113
114 this._splitWidget = new UI.SplitWidget(false, false, 'timelineFlamechartMain View', 150); 114 this._splitWidget = new UI.SplitWidget(false, false, 'timelineFlamechartMain View', 150);
115 115
116 this._dataProvider = new Timeline.TimelineFlameChartDataProvider(filters); 116 this._dataProvider = new Timeline.TimelineFlameChartDataProvider(filters);
117 var mainViewGroupExpansionSetting = Common.settings.createSetting('timelineF lamechartMainViewGroupExpansion', {}); 117 var mainViewGroupExpansionSetting = Common.settings.createSetting('timelineF lamechartMainViewGroupExpansion', {});
118 this._mainView = new PerfUI.FlameChart(this._dataProvider, this, mainViewGro upExpansionSetting); 118 this._mainView = new PerfUI.FlameChart(this._dataProvider, this, mainViewGro upExpansionSetting);
119 this._mainView.alwaysShowVerticalScroll(); 119 this._mainView.alwaysShowVerticalScroll();
120 this._mainView.enableRuler(false); 120 this._mainView.enableRuler(false);
121 121
122 var networkViewGroupExpansionSetting = 122 this._networkViewGroupExpansionSetting =
123 Common.settings.createSetting('timelineFlamechartNetworkViewGroupExpansi on', {}); 123 Common.settings.createSetting('timelineFlamechartNetworkViewGroupExpansi on', {});
124 this._networkDataProvider = new Timeline.TimelineFlameChartNetworkDataProvid er(); 124 this._networkDataProvider = new Timeline.TimelineFlameChartNetworkDataProvid er();
125 this._networkView = new PerfUI.FlameChart(this._networkDataProvider, this, n etworkViewGroupExpansionSetting); 125 this._networkView = new PerfUI.FlameChart(this._networkDataProvider, this, t his._networkViewGroupExpansionSetting);
126 this._networkView.alwaysShowVerticalScroll(); 126 this._networkView.alwaysShowVerticalScroll();
127 networkViewGroupExpansionSetting.addChangeListener(this.resizeToPreferredHei ghts.bind(this));
128 127
129 this._networkPane = new UI.VBox(); 128 this._networkPane = new UI.VBox();
130 this._networkPane.setMinimumSize(23, 23); 129 this._networkPane.setMinimumSize(23, 23);
131 this._networkView.show(this._networkPane.element); 130 this._networkView.show(this._networkPane.element);
132 this._splitResizer = this._networkPane.element.createChild('div', 'timeline- flamechart-resizer'); 131 this._splitResizer = this._networkPane.element.createChild('div', 'timeline- flamechart-resizer');
133 this._splitWidget.hideDefaultResizer(true); 132 this._splitWidget.hideDefaultResizer(true);
134 this._splitWidget.installResizer(this._splitResizer); 133 this._splitWidget.installResizer(this._splitResizer);
135 134
136 this._splitWidget.setMainWidget(this._mainView); 135 this._splitWidget.setMainWidget(this._mainView);
137 this._splitWidget.setSidebarWidget(this._networkPane); 136 this._splitWidget.setSidebarWidget(this._networkPane);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 if (this._model) 193 if (this._model)
195 this._model.removeEventListener(extensionDataAdded, this._appendExtensionD ata, this); 194 this._model.removeEventListener(extensionDataAdded, this._appendExtensionD ata, this);
196 this._model = model; 195 this._model = model;
197 if (this._model) 196 if (this._model)
198 this._model.addEventListener(extensionDataAdded, this._appendExtensionData , this); 197 this._model.addEventListener(extensionDataAdded, this._appendExtensionData , this);
199 this._refresh(); 198 this._refresh();
200 } 199 }
201 200
202 _refresh() { 201 _refresh() {
203 this._dataProvider.setModel(this._model); 202 this._dataProvider.setModel(this._model);
204 this._mainView.reset();
205
206 this._networkDataProvider.setModel(this._model); 203 this._networkDataProvider.setModel(this._model);
207 this._networkView.reset(); 204 if (this._detailsView)
208 205 this._detailsView.setModel(this._model);
209 this._detailsView.setModel(this._model);
210 206
211 this._nextExtensionIndex = 0; 207 this._nextExtensionIndex = 0;
212 this._appendExtensionData(); 208 this._appendExtensionData();
213 this._mainView.scheduleUpdate();
214 209
215 this._networkDataProvider.reset();
216 if (this._networkDataProvider.isEmpty()) { 210 if (this._networkDataProvider.isEmpty()) {
217 this._mainView.enableRuler(true); 211 this._mainView.enableRuler(true);
218 this._splitWidget.hideSidebar(); 212 this._splitWidget.hideSidebar();
219 } else { 213 } else {
220 this._mainView.enableRuler(false); 214 this._mainView.enableRuler(false);
221 this._splitWidget.showBoth(); 215 this._splitWidget.showBoth();
222 this.resizeToPreferredHeights(); 216 this.resizeToPreferredHeights();
223 } 217 }
224 this._networkView.scheduleUpdate(); 218 this._mainView.reset();
219 this._networkView.reset();
225 } 220 }
226 221
227 _appendExtensionData() { 222 _appendExtensionData() {
228 if (!this._model) 223 if (!this._model)
229 return; 224 return;
230 var extensions = this._model.extensionInfo(); 225 var extensions = this._model.extensionInfo();
231 while (this._nextExtensionIndex < extensions.length) 226 while (this._nextExtensionIndex < extensions.length)
232 this._dataProvider.appendExtensionEvents(extensions[this._nextExtensionInd ex++]); 227 this._dataProvider.appendExtensionEvents(extensions[this._nextExtensionInd ex++]);
233 this._mainView.scheduleUpdate(); 228 this._mainView.scheduleUpdate();
234 } 229 }
235 230
236 /** 231 /**
237 * @override 232 * @override
238 * @param {?SDK.TracingModel.Event} event 233 * @param {?SDK.TracingModel.Event} event
239 */ 234 */
240 highlightEvent(event) { 235 highlightEvent(event) {
241 var entryIndex = 236 var entryIndex =
242 event ? this._dataProvider.entryIndexForSelection(Timeline.TimelineSelec tion.fromTraceEvent(event)) : -1; 237 event ? this._dataProvider.entryIndexForSelection(Timeline.TimelineSelec tion.fromTraceEvent(event)) : -1;
243 if (entryIndex >= 0) 238 if (entryIndex >= 0)
244 this._mainView.highlightEntry(entryIndex); 239 this._mainView.highlightEntry(entryIndex);
245 else 240 else
246 this._mainView.hideHighlight(); 241 this._mainView.hideHighlight();
247 } 242 }
248 243
249 /** 244 /**
250 * @override 245 * @override
251 */ 246 */
252 willHide() { 247 willHide() {
248 this._networkViewGroupExpansionSetting.removeChangeListener(this.resizeToPre ferredHeights, this);
253 Bindings.blackboxManager.removeChangeListener(this._boundRefresh); 249 Bindings.blackboxManager.removeChangeListener(this._boundRefresh);
254 } 250 }
255 251
256 /** 252 /**
257 * @override 253 * @override
258 */ 254 */
259 wasShown() { 255 wasShown() {
256 this._networkViewGroupExpansionSetting.addChangeListener(this.resizeToPrefer redHeights, this);
260 Bindings.blackboxManager.addChangeListener(this._boundRefresh); 257 Bindings.blackboxManager.addChangeListener(this._boundRefresh);
258 if (this._needsResizeToPreferredHeights)
259 this.resizeToPreferredHeights();
261 this._mainView.scheduleUpdate(); 260 this._mainView.scheduleUpdate();
262 this._networkView.scheduleUpdate(); 261 this._networkView.scheduleUpdate();
263 } 262 }
264 263
265 /** 264 /**
266 * @override 265 * @override
267 * @return {!UI.Widget} 266 * @return {!UI.Widget}
268 */ 267 */
269 view() { 268 view() {
270 return this; 269 return this;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 /** 312 /**
314 * @param {!PerfUI.FlameChartDataProvider} dataProvider 313 * @param {!PerfUI.FlameChartDataProvider} dataProvider
315 * @param {!Common.Event} event 314 * @param {!Common.Event} event
316 */ 315 */
317 _onEntrySelected(dataProvider, event) { 316 _onEntrySelected(dataProvider, event) {
318 var entryIndex = /** @type{number} */ (event.data); 317 var entryIndex = /** @type{number} */ (event.data);
319 this._delegate.select(dataProvider.createSelection(entryIndex)); 318 this._delegate.select(dataProvider.createSelection(entryIndex));
320 } 319 }
321 320
322 resizeToPreferredHeights() { 321 resizeToPreferredHeights() {
322 if (!this.isShowing()) {
323 this._needsResizeToPreferredHeights = true;
324 return;
325 }
326 this._needsResizeToPreferredHeights = false;
323 this._networkPane.element.classList.toggle( 327 this._networkPane.element.classList.toggle(
324 'timeline-network-resizer-disabled', !this._networkDataProvider.isExpand ed()); 328 'timeline-network-resizer-disabled', !this._networkDataProvider.isExpand ed());
325 this._splitWidget.setSidebarSize( 329 this._splitWidget.setSidebarSize(
326 this._networkDataProvider.preferredHeight() + this._splitResizer.clientH eight + PerfUI.FlameChart.HeaderHeight + 330 this._networkDataProvider.preferredHeight() + this._splitResizer.clientH eight + PerfUI.FlameChart.HeaderHeight +
327 2); 331 2);
328 } 332 }
329 }; 333 };
330 334
331 /** 335 /**
332 * @unrestricted 336 * @unrestricted
333 */ 337 */
334 Timeline.TimelineFlameChartView.Selection = class { 338 Timeline.TimelineFlameChartView.Selection = class {
335 /** 339 /**
336 * @param {!Timeline.TimelineSelection} selection 340 * @param {!Timeline.TimelineSelection} selection
337 * @param {number} entryIndex 341 * @param {number} entryIndex
338 */ 342 */
339 constructor(selection, entryIndex) { 343 constructor(selection, entryIndex) {
340 this.timelineSelection = selection; 344 this.timelineSelection = selection;
341 this.entryIndex = entryIndex; 345 this.entryIndex = entryIndex;
342 } 346 }
343 }; 347 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698