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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // TODO(alph): use scriptId instead of urls for the target. | 67 // TODO(alph): use scriptId instead of urls for the target. |
68 this._locationPool.disposeAll(); | 68 this._locationPool.disposeAll(); |
69 Workspace.workspace.uiSourceCodes().forEach( | 69 Workspace.workspace.uiSourceCodes().forEach( |
70 uiSourceCode => uiSourceCode.removeDecorationsForType(PerfUI.LineLevelPr
ofile.LineDecorator.type)); | 70 uiSourceCode => uiSourceCode.removeDecorationsForType(PerfUI.LineLevelPr
ofile.LineDecorator.type)); |
71 for (var fileInfo of this._files) { | 71 for (var fileInfo of this._files) { |
72 var url = /** @type {string} */ (fileInfo[0]); | 72 var url = /** @type {string} */ (fileInfo[0]); |
73 var uiSourceCode = Workspace.workspace.uiSourceCodeForURL(url); | 73 var uiSourceCode = Workspace.workspace.uiSourceCodeForURL(url); |
74 if (!uiSourceCode) | 74 if (!uiSourceCode) |
75 continue; | 75 continue; |
76 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode) |
| SDK.targetManager.mainTarget(); | 76 var target = Bindings.NetworkProject.targetForUISourceCode(uiSourceCode) |
| SDK.targetManager.mainTarget(); |
77 var debuggerModel = target ? SDK.DebuggerModel.fromTarget(target) : null; | 77 var debuggerModel = target ? target.model(SDK.DebuggerModel) : null; |
78 if (!debuggerModel) | 78 if (!debuggerModel) |
79 continue; | 79 continue; |
80 for (var lineInfo of fileInfo[1]) { | 80 for (var lineInfo of fileInfo[1]) { |
81 var line = lineInfo[0] - 1; | 81 var line = lineInfo[0] - 1; |
82 var time = lineInfo[1]; | 82 var time = lineInfo[1]; |
83 var rawLocation = debuggerModel.createRawLocationByURL(url, line, 0); | 83 var rawLocation = debuggerModel.createRawLocationByURL(url, line, 0); |
84 if (rawLocation) | 84 if (rawLocation) |
85 new PerfUI.LineLevelProfile.Presentation(rawLocation, time, this._loca
tionPool); | 85 new PerfUI.LineLevelProfile.Presentation(rawLocation, time, this._loca
tionPool); |
86 else if (uiSourceCode) | 86 else if (uiSourceCode) |
87 uiSourceCode.addLineDecoration(line, PerfUI.LineLevelProfile.LineDecor
ator.type, time); | 87 uiSourceCode.addLineDecoration(line, PerfUI.LineLevelProfile.LineDecor
ator.type, time); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |