Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/timeline/TimelineFlameChartView.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineFlameChartView.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineFlameChartView.js |
| index c6c6950941aab79bf9ba8352922aec4119f1f52c..52e76cdfac34053c50473f980aeb7313c154c351 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineFlameChartView.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineFlameChartView.js |
| @@ -85,47 +85,23 @@ Timeline.TimelineFlameChartView = class extends UI.VBox { |
| return; |
| this._groupBySetting = |
| Common.settings.createSetting('timelineTreeGroupBy', Timeline.AggregatedTimelineTreeView.GroupBy.None); |
| - this._groupBySetting.addChangeListener(this._onGroupByChanged, this); |
| - this._onGroupByChanged(); |
| + this._groupBySetting.addChangeListener(this._updateColorMapper, this); |
| + this._updateColorMapper(); |
| ProductRegistry.instance().then(registry => this._productRegistry = registry); |
| } |
| - _onGroupByChanged() { |
| + _updateColorMapper() { |
| /** @type {!Map<string, string>} */ |
| this._urlToColorCache = new Map(); |
| + if (!this._model) |
| + return; |
| var colorByProduct = Runtime.experiments.isEnabled('timelineColorByProduct') && |
| this._groupBySetting.get() === Timeline.AggregatedTimelineTreeView.GroupBy.Product; |
| this._mainDataProvider.setEventColorMapping( |
| - colorByProduct ? eventToColorByProduct.bind(this) : Timeline.TimelineUIUtils.eventColor); |
| + colorByProduct ? Timeline.TimelineUIUtils.eventColorByProduct.bind( |
| + null, this._productRegistry, this._model.timelineModel(), this._urlToColorCache) : |
|
caseq
2017/05/22 18:43:49
Let's avoid keeping the model here, as this mapper
alph
2017/05/22 22:53:26
Done.
|
| + Timeline.TimelineUIUtils.eventColor); |
| this._mainFlameChart.update(); |
| - |
| - /** |
| - * @param {!SDK.TracingModel.Event} event |
| - * @this {Timeline.TimelineFlameChartView} |
| - * @return {string} |
| - */ |
| - function eventToColorByProduct(event) { |
| - var url = Timeline.TimelineUIUtils.eventURL(event) || ''; |
| - var color = this._urlToColorCache.get(url); |
| - if (!color) { |
| - var defaultColor = '#f2ecdc'; |
| - if (!this._productRegistry) |
| - return defaultColor; |
| - var parsedURL = url.asParsedURL(); |
| - if (!parsedURL) |
| - return defaultColor; |
| - var name = this._productRegistry.nameForUrl(parsedURL); |
| - if (!name) { |
| - name = parsedURL.host; |
| - var rootFrames = this._model.timelineModel().rootFrames(); |
| - if (rootFrames.some(pageFrame => new Common.ParsedURL(pageFrame.url).host === name)) |
| - return defaultColor; |
| - } |
| - color = name ? ProductRegistry.BadgePool.colorForEntryName(name) : defaultColor; |
| - this._urlToColorCache.set(url, color); |
| - } |
| - return color; |
| - } |
| } |
| /** |
| @@ -169,6 +145,7 @@ Timeline.TimelineFlameChartView = class extends UI.VBox { |
| this._networkDataProvider.setModel(this._model); |
| this._countersView.setModel(this._model); |
| this._detailsView.setModel(this._model); |
| + this._updateColorMapper(); |
| this._nextExtensionIndex = 0; |
| this._appendExtensionData(); |