Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 this._detailsSplitWidget.show(this.element); | 72 this._detailsSplitWidget.show(this.element); |
| 73 | 73 |
| 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 | |
| 83 this._mainDataProvider.setEntryColorMapping(Timeline.TimelineUIUtils.eventCo lor); | |
| 84 ProductRegistry.instance().then(registry => this._productRegistry = registry ); | |
|
caseq
2017/05/08 18:20:35
Let's make this conditional on experiment.
alph
2017/05/08 19:00:20
Done.
| |
| 82 } | 85 } |
| 83 | 86 |
| 84 /** | 87 /** |
| 88 * @param {!UI.Toolbar} toolbar | |
| 89 */ | |
| 90 populateToolbar(toolbar) { | |
| 91 if (!Runtime.experiments.isEnabled('timelineColorByProduct')) | |
| 92 return; | |
| 93 toolbar.appendSeparator(); | |
| 94 var colorBySetting = Common.settings.createSetting('timelineColorBy', Timeli ne.TimelineFlameChartView._ColorBy.URL); | |
| 95 colorBySetting.addChangeListener(this._onColorByChanged, this); | |
| 96 var options = [ | |
| 97 {value: Timeline.TimelineFlameChartView._ColorBy.URL, label: Common.UIStri ng('Color by URL')}, | |
| 98 {value: Timeline.TimelineFlameChartView._ColorBy.Product, label: Common.UI String('Color by Product')} | |
| 99 ]; | |
| 100 this._colorByCombobox = new UI.ToolbarSettingComboBox(options, colorBySettin g); | |
| 101 toolbar.appendToolbarItem(this._colorByCombobox); | |
| 102 this._onColorByChanged(); | |
| 103 } | |
| 104 | |
| 105 _onColorByChanged() { | |
| 106 /** @type {!Map<string, string>} */ | |
| 107 this._urlToColorCache = new Map(); | |
| 108 this._mainDataProvider.setEntryColorMapping( | |
| 109 this._colorByCombobox.selectedOption().value === Timeline.TimelineFlameC hartView._ColorBy.Product ? | |
| 110 colorByProduct.bind(this) : | |
| 111 Timeline.TimelineUIUtils.eventColor); | |
| 112 | |
| 113 /** | |
| 114 * @param {!SDK.TracingModel.Event} event | |
| 115 * @this {Timeline.TimelineFlameChartView} | |
| 116 * @return {string} | |
| 117 */ | |
| 118 function colorByProduct(event) { | |
| 119 if (event.name === TimelineModel.TimelineModel.RecordType.JSFrame) { | |
|
caseq
2017/05/08 18:20:35
if (event.name !== ...)
return Timeline.TimelineU
alph
2017/05/08 19:00:20
Done.
| |
| 120 var frame = event.args['data']; | |
| 121 if (Timeline.TimelineUIUtils.isUserFrame(frame)) { | |
| 122 var color = this._urlToColorCache.get(frame.url); | |
| 123 if (!color) { | |
| 124 var defaultColor = '#f2ecdc'; | |
| 125 if (!this._productRegistry) | |
| 126 return defaultColor; | |
| 127 var parsedURL = frame.url.asParsedURL(); | |
| 128 var name = parsedURL && this._productRegistry.nameForUrl(parsedURL); | |
| 129 color = name ? Timeline.TimelineUIUtils.colorForId(name) : defaultCo lor; | |
| 130 this._urlToColorCache.set(frame.url, color); | |
| 131 } | |
| 132 return color; | |
| 133 } | |
| 134 } | |
| 135 return Timeline.TimelineUIUtils.eventStyle(event).category.color; | |
| 136 } | |
| 137 } | |
| 138 | |
| 139 /** | |
| 85 * @override | 140 * @override |
| 86 * @return {?Element} | 141 * @return {?Element} |
| 87 */ | 142 */ |
| 88 resizerElement() { | 143 resizerElement() { |
| 89 return null; | 144 return null; |
| 90 } | 145 } |
| 91 | 146 |
| 92 /** | 147 /** |
| 93 * @override | 148 * @override |
| 94 * @param {number} windowStartTime | 149 * @param {number} windowStartTime |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 context.translate(this._style.lineWidth < 1 || (this._style.lineWidth & 1) ? 0.5 : 0, 0.5); | 581 context.translate(this._style.lineWidth < 1 || (this._style.lineWidth & 1) ? 0.5 : 0, 0.5); |
| 527 context.beginPath(); | 582 context.beginPath(); |
| 528 context.moveTo(x, height); | 583 context.moveTo(x, height); |
| 529 context.setLineDash(this._style.dashStyle); | 584 context.setLineDash(this._style.dashStyle); |
| 530 context.lineTo(x, context.canvas.height); | 585 context.lineTo(x, context.canvas.height); |
| 531 context.stroke(); | 586 context.stroke(); |
| 532 } | 587 } |
| 533 context.restore(); | 588 context.restore(); |
| 534 } | 589 } |
| 535 }; | 590 }; |
| 591 | |
| 592 /** @enum {string} */ | |
| 593 Timeline.TimelineFlameChartView._ColorBy = { | |
| 594 URL: 'URL', | |
| 595 Product: 'Product' | |
| 596 }; | |
| OLD | NEW |