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 * @unrestricted | 5 * @unrestricted |
| 6 */ | 6 */ |
| 7 WebInspector.LineLevelProfile = class { | 7 WebInspector.LineLevelProfile = class { |
| 8 constructor() { | 8 constructor() { |
| 9 this._locationPool = new WebInspector.LiveLocationPool(); | 9 this._locationPool = new WebInspector.LiveLocationPool(); |
| 10 this.reset(); | 10 this.reset(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 * @unrestricted | 125 * @unrestricted |
| 126 */ | 126 */ |
| 127 WebInspector.LineLevelProfile.LineDecorator = class { | 127 WebInspector.LineLevelProfile.LineDecorator = class { |
| 128 /** | 128 /** |
| 129 * @override | 129 * @override |
| 130 * @param {!WebInspector.UISourceCode} uiSourceCode | 130 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 131 * @param {!WebInspector.CodeMirrorTextEditor} textEditor | 131 * @param {!WebInspector.CodeMirrorTextEditor} textEditor |
| 132 */ | 132 */ |
| 133 decorate(uiSourceCode, textEditor) { | 133 decorate(uiSourceCode, textEditor) { |
| 134 var gutterType = 'CodeMirror-gutter-performance'; | 134 var gutterType = 'CodeMirror-gutter-performance'; |
| 135 var decorations = uiSourceCode.lineDecorations(WebInspector.LineLevelProfile .LineDecorator.type); | 135 var decorations = uiSourceCode.lineDecorations(WebInspector.LineLevelProfile .LineDecorator.type); |
|
lushnikov
2016/11/11 23:28:01
let's make .lineDecorations() non-nullable
| |
| 136 textEditor.uninstallGutter(gutterType); | 136 textEditor.uninstallGutter(gutterType); |
| 137 if (!decorations) | 137 if (!decorations || !decorations.size) |
| 138 return; | 138 return; |
| 139 textEditor.installGutter(gutterType, false); | 139 textEditor.installGutter(gutterType, false); |
| 140 for (var decoration of decorations.values()) { | 140 for (var decoration of decorations) { |
| 141 var time = /** @type {number} */ (decoration.data()); | 141 var time = /** @type {number} */ (decoration.data()); |
| 142 var text = WebInspector.UIString('%.1f\xa0ms', time); | 142 var text = WebInspector.UIString('%.1f\xa0ms', time); |
| 143 var intensity = Number.constrain(Math.log10(1 + 2 * time) / 5, 0.02, 1); | 143 var intensity = Number.constrain(Math.log10(1 + 2 * time) / 5, 0.02, 1); |
| 144 var element = createElementWithClass('div', 'text-editor-line-marker-perfo rmance'); | 144 var element = createElementWithClass('div', 'text-editor-line-marker-perfo rmance'); |
| 145 element.textContent = text; | 145 element.textContent = text; |
| 146 element.style.backgroundColor = `hsla(44, 100%, 50%, ${intensity.toFixed(3 )})`; | 146 element.style.backgroundColor = `hsla(44, 100%, 50%, ${intensity.toFixed(3 )})`; |
| 147 textEditor.setGutterDecoration(decoration.line(), gutterType, element); | 147 textEditor.setGutterDecoration(decoration.line(), gutterType, element); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 WebInspector.LineLevelProfile.LineDecorator.type = 'performance'; | 152 WebInspector.LineLevelProfile.LineDecorator.type = 'performance'; |
| OLD | NEW |