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

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

Issue 2882343002: DevTools: Make flamechart coloring depend on group by selector. (Closed)
Patch Set: . Created 3 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.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 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 /** 5 /**
6 * @implements {Timeline.TimelineModeView} 6 * @implements {Timeline.TimelineModeView}
7 * @implements {PerfUI.FlameChartDelegate} 7 * @implements {PerfUI.FlameChartDelegate}
8 * @implements {UI.Searchable} 8 * @implements {UI.Searchable}
9 * @unrestricted 9 * @unrestricted
10 */ 10 */
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 this._onMainEntrySelected = this._onEntrySelected.bind(this, this._mainDataP rovider); 74 this._onMainEntrySelected = this._onEntrySelected.bind(this, this._mainDataP rovider);
75 this._onNetworkEntrySelected = this._onEntrySelected.bind(this, this._networ kDataProvider); 75 this._onNetworkEntrySelected = this._onEntrySelected.bind(this, this._networ kDataProvider);
76 this._mainFlameChart.addEventListener(PerfUI.FlameChart.Events.EntrySelected , this._onMainEntrySelected, this); 76 this._mainFlameChart.addEventListener(PerfUI.FlameChart.Events.EntrySelected , this._onMainEntrySelected, this);
77 this._networkFlameChart.addEventListener(PerfUI.FlameChart.Events.EntrySelec ted, this._onNetworkEntrySelected, this); 77 this._networkFlameChart.addEventListener(PerfUI.FlameChart.Events.EntrySelec ted, this._onNetworkEntrySelected, this);
78 this._mainFlameChart.addEventListener(PerfUI.FlameChart.Events.EntryHighligh ted, this._onEntryHighlighted, this); 78 this._mainFlameChart.addEventListener(PerfUI.FlameChart.Events.EntryHighligh ted, this._onEntryHighlighted, this);
79 this._nextExtensionIndex = 0; 79 this._nextExtensionIndex = 0;
80 80
81 this._boundRefresh = this._refresh.bind(this); 81 this._boundRefresh = this._refresh.bind(this);
82 82
83 this._mainDataProvider.setEventColorMapping(Timeline.TimelineUIUtils.eventCo lor); 83 this._mainDataProvider.setEventColorMapping(Timeline.TimelineUIUtils.eventCo lor);
84 if (Runtime.experiments.isEnabled('timelineColorByProduct')) 84 if (!Runtime.experiments.isEnabled('timelineColorByProduct'))
85 ProductRegistry.instance().then(registry => this._productRegistry = regist ry); 85 return;
86 this._groupBySetting =
87 Common.settings.createSetting('timelineTreeGroupBy', Timeline.Aggregated TimelineTreeView.GroupBy.None);
88 this._groupBySetting.addChangeListener(this._onGroupByChanged, this);
89 this._onGroupByChanged();
90 ProductRegistry.instance().then(registry => this._productRegistry = registry );
86 } 91 }
87 92
88 /** 93 _onGroupByChanged() {
89 * @param {!UI.Toolbar} toolbar
90 */
91 populateToolbar(toolbar) {
92 if (!Runtime.experiments.isEnabled('timelineColorByProduct'))
93 return;
94 toolbar.appendSeparator();
95 var colorBySetting = Common.settings.createSetting('timelineColorBy', Timeli ne.TimelineFlameChartView._ColorBy.URL);
96 colorBySetting.addChangeListener(this._onColorByChanged, this);
97 var options = [
98 {value: Timeline.TimelineFlameChartView._ColorBy.URL, label: Common.UIStri ng('Color by URL')},
99 {value: Timeline.TimelineFlameChartView._ColorBy.Product, label: Common.UI String('Color by Product')}
100 ];
101 this._colorByCombobox = new UI.ToolbarSettingComboBox(options, colorBySettin g);
102 toolbar.appendToolbarItem(this._colorByCombobox);
103 this._onColorByChanged();
104 }
105
106 _onColorByChanged() {
107 /** @type {!Map<string, string>} */ 94 /** @type {!Map<string, string>} */
108 this._urlToColorCache = new Map(); 95 this._urlToColorCache = new Map();
96 var colorByProduct = Runtime.experiments.isEnabled('timelineColorByProduct') &&
97 this._groupBySetting.get() === Timeline.AggregatedTimelineTreeView.Group By.Product;
109 this._mainDataProvider.setEventColorMapping( 98 this._mainDataProvider.setEventColorMapping(
110 this._colorByCombobox.selectedOption().value === Timeline.TimelineFlameC hartView._ColorBy.Product ? 99 colorByProduct ? eventToColorByProduct.bind(this) : Timeline.TimelineUIU tils.eventColor);
111 colorByProduct.bind(this) :
112 Timeline.TimelineUIUtils.eventColor);
113 this._mainFlameChart.update(); 100 this._mainFlameChart.update();
114 101
115 /** 102 /**
116 * @param {!SDK.TracingModel.Event} event 103 * @param {!SDK.TracingModel.Event} event
117 * @this {Timeline.TimelineFlameChartView} 104 * @this {Timeline.TimelineFlameChartView}
118 * @return {string} 105 * @return {string}
119 */ 106 */
120 function colorByProduct(event) { 107 function eventToColorByProduct(event) {
121 if (event.name !== TimelineModel.TimelineModel.RecordType.JSFrame) 108 var url = Timeline.TimelineUIUtils.eventURL(event) || '';
122 return Timeline.TimelineUIUtils.eventStyle(event).category.color; 109 var color = this._urlToColorCache.get(url);
123 var frame = event.args['data'];
124 if (!Timeline.TimelineUIUtils.isUserFrame(frame))
125 return Timeline.TimelineUIUtils.eventStyle(event).category.color;
126 var color = this._urlToColorCache.get(frame.url);
127 if (!color) { 110 if (!color) {
111 var defaultColor = '#f2ecdc';
128 if (!this._productRegistry) 112 if (!this._productRegistry)
129 return Timeline.TimelineUIUtils.colorForId(''); 113 return defaultColor;
130 var parsedURL = frame.url.asParsedURL(); 114 var parsedURL = url.asParsedURL();
131 var name = parsedURL && this._productRegistry.nameForUrl(parsedURL) || ' '; 115 if (!parsedURL)
132 color = Timeline.TimelineUIUtils.colorForId(name); 116 return defaultColor;
133 this._urlToColorCache.set(frame.url, color); 117 var name = this._productRegistry.nameForUrl(parsedURL);
118 if (!name) {
119 name = parsedURL.host;
120 var rootFrames = this._model.timelineModel().rootFrames();
121 if (rootFrames.some(pageFrame => new Common.ParsedURL(pageFrame.url).h ost === name))
122 return defaultColor;
123 }
124 color = name ? ProductRegistry.BadgePool.colorForEntryName(name) : defau ltColor;
125 this._urlToColorCache.set(url, color);
134 } 126 }
135 return color; 127 return color;
136 } 128 }
137 } 129 }
138 130
139 /** 131 /**
140 * @override 132 * @override
141 * @return {?Element} 133 * @return {?Element}
142 */ 134 */
143 resizerElement() { 135 resizerElement() {
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 } 569 }
578 context.restore(); 570 context.restore();
579 } 571 }
580 }; 572 };
581 573
582 /** @enum {string} */ 574 /** @enum {string} */
583 Timeline.TimelineFlameChartView._ColorBy = { 575 Timeline.TimelineFlameChartView._ColorBy = {
584 URL: 'URL', 576 URL: 'URL',
585 Product: 'Product' 577 Product: 'Product'
586 }; 578 };
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698