| 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 PerfUI.LineLevelProfile = class { | 7 PerfUI.LineLevelProfile = class { |
| 8 constructor() { | 8 constructor() { |
| 9 this._locationPool = new Bindings.LiveLocationPool(); | 9 this._locationPool = new Bindings.LiveLocationPool(); |
| 10 this.reset(); | 10 this.reset(); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 }; | 120 }; |
| 121 | 121 |
| 122 /** | 122 /** |
| 123 * @implements {SourceFrame.UISourceCodeFrame.LineDecorator} | 123 * @implements {SourceFrame.UISourceCodeFrame.LineDecorator} |
| 124 * @unrestricted | 124 * @unrestricted |
| 125 */ | 125 */ |
| 126 PerfUI.LineLevelProfile.LineDecorator = class { | 126 PerfUI.LineLevelProfile.LineDecorator = class { |
| 127 /** | 127 /** |
| 128 * @override | 128 * @override |
| 129 * @param {!Workspace.UISourceCode} uiSourceCode | 129 * @param {!Workspace.UISourceCode} uiSourceCode |
| 130 * @param {!TextEditor.CodeMirrorTextEditor} textEditor | 130 * @param {!SourceFrame.SourcesTextEditor} textEditor |
| 131 */ | 131 */ |
| 132 decorate(uiSourceCode, textEditor) { | 132 decorate(uiSourceCode, textEditor) { |
| 133 var gutterType = 'CodeMirror-gutter-performance'; | 133 var gutterType = 'CodeMirror-gutter-performance'; |
| 134 var decorations = uiSourceCode.decorationsForType(PerfUI.LineLevelProfile.Li
neDecorator.type); | 134 var decorations = uiSourceCode.decorationsForType(PerfUI.LineLevelProfile.Li
neDecorator.type); |
| 135 textEditor.uninstallGutter(gutterType); | 135 textEditor.uninstallGutter(gutterType); |
| 136 if (!decorations || !decorations.size) | 136 if (!decorations || !decorations.size) |
| 137 return; | 137 return; |
| 138 textEditor.installGutter(gutterType, false); | 138 textEditor.installGutter(gutterType, false); |
| 139 for (var decoration of decorations) { | 139 for (var decoration of decorations) { |
| 140 var time = /** @type {number} */ (decoration.data()); | 140 var time = /** @type {number} */ (decoration.data()); |
| 141 var text = Common.UIString('%.1f\xa0ms', time); | 141 var text = Common.UIString('%.1f\xa0ms', time); |
| 142 var intensity = Number.constrain(Math.log10(1 + 2 * time) / 5, 0.02, 1); | 142 var intensity = Number.constrain(Math.log10(1 + 2 * time) / 5, 0.02, 1); |
| 143 var element = createElementWithClass('div', 'text-editor-line-marker-perfo
rmance'); | 143 var element = createElementWithClass('div', 'text-editor-line-marker-perfo
rmance'); |
| 144 element.textContent = text; | 144 element.textContent = text; |
| 145 element.style.backgroundColor = `hsla(44, 100%, 50%, ${intensity.toFixed(3
)})`; | 145 element.style.backgroundColor = `hsla(44, 100%, 50%, ${intensity.toFixed(3
)})`; |
| 146 textEditor.setGutterDecoration(decoration.range().startLine, gutterType, e
lement); | 146 textEditor.setGutterDecoration(decoration.range().startLine, gutterType, e
lement); |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 PerfUI.LineLevelProfile.LineDecorator.type = 'performance'; | 151 PerfUI.LineLevelProfile.LineDecorator.type = 'performance'; |
| OLD | NEW |