| 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 * @constructor | 6 * @constructor |
| 7 */ | 7 */ |
| 8 WebInspector.LineLevelProfile = function() | 8 WebInspector.LineLevelProfile = function() |
| 9 { | 9 { |
| 10 this._locationPool = new WebInspector.LiveLocationPool(); | 10 this._locationPool = new WebInspector.LiveLocationPool(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 if (this._updateTimer) | 64 if (this._updateTimer) |
| 65 return; | 65 return; |
| 66 this._updateTimer = setTimeout(() => { | 66 this._updateTimer = setTimeout(() => { |
| 67 this._updateTimer = null; | 67 this._updateTimer = null; |
| 68 this._doUpdate(); | 68 this._doUpdate(); |
| 69 }, 0); | 69 }, 0); |
| 70 }, | 70 }, |
| 71 | 71 |
| 72 _doUpdate: function() | 72 _doUpdate: function() |
| 73 { | 73 { |
| 74 // TODO(alph): use scriptId instead of urls for the target. |
| 74 this._locationPool.disposeAll(); | 75 this._locationPool.disposeAll(); |
| 75 WebInspector.workspace.uiSourceCodes().forEach(uiSourceCode => uiSourceC
ode.removeAllLineDecorations(WebInspector.LineLevelProfile.LineDecorator.type)); | 76 WebInspector.workspace.uiSourceCodes().forEach(uiSourceCode => uiSourceC
ode.removeAllLineDecorations(WebInspector.LineLevelProfile.LineDecorator.type)); |
| 76 var debuggerModel = WebInspector.DebuggerModel.fromTarget(WebInspector.t
argetManager.mainTarget()); | |
| 77 if (!debuggerModel) | |
| 78 return; | |
| 79 for (var fileInfo of this._files) { | 77 for (var fileInfo of this._files) { |
| 80 var url = /** @type {string} */ (fileInfo[0]); | 78 var url = /** @type {string} */ (fileInfo[0]); |
| 81 var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(url); | 79 var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(url); |
| 80 if (!uiSourceCode) |
| 81 continue; |
| 82 var target = WebInspector.NetworkProject.targetForUISourceCode(uiSou
rceCode) || WebInspector.targetManager.mainTarget(); |
| 83 var debuggerModel = target ? WebInspector.DebuggerModel.fromTarget(t
arget) : null; |
| 84 if (!debuggerModel) |
| 85 continue; |
| 82 for (var lineInfo of fileInfo[1]) { | 86 for (var lineInfo of fileInfo[1]) { |
| 83 var line = lineInfo[0] - 1; | 87 var line = lineInfo[0] - 1; |
| 84 var time = lineInfo[1]; | 88 var time = lineInfo[1]; |
| 85 var rawLocation = debuggerModel.createRawLocationByURL(url, line
, 0); | 89 var rawLocation = debuggerModel.createRawLocationByURL(url, line
, 0); |
| 86 if (rawLocation) | 90 if (rawLocation) |
| 87 new WebInspector.LineLevelProfile.Presentation(rawLocation,
time, this._locationPool); | 91 new WebInspector.LineLevelProfile.Presentation(rawLocation,
time, this._locationPool); |
| 88 else if (uiSourceCode) | 92 else if (uiSourceCode) |
| 89 uiSourceCode.addLineDecoration(line, WebInspector.LineLevelP
rofile.LineDecorator.type, time); | 93 uiSourceCode.addLineDecoration(line, WebInspector.LineLevelP
rofile.LineDecorator.type, time); |
| 90 } | 94 } |
| 91 } | 95 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 var time = /** @type {number} */ (decoration.data()); | 150 var time = /** @type {number} */ (decoration.data()); |
| 147 var text = WebInspector.UIString("%.1f\xa0ms", time); | 151 var text = WebInspector.UIString("%.1f\xa0ms", time); |
| 148 var intensity = Number.constrain(Math.log10(1 + 2 * time) / 5, 0.02,
1); | 152 var intensity = Number.constrain(Math.log10(1 + 2 * time) / 5, 0.02,
1); |
| 149 var element = createElementWithClass("div", "text-editor-line-marker
-performance"); | 153 var element = createElementWithClass("div", "text-editor-line-marker
-performance"); |
| 150 element.textContent = text; | 154 element.textContent = text; |
| 151 element.style.backgroundColor = `hsla(44, 100%, 50%, ${intensity.toF
ixed(3)})`; | 155 element.style.backgroundColor = `hsla(44, 100%, 50%, ${intensity.toF
ixed(3)})`; |
| 152 textEditor.setGutterDecoration(decoration.line(), gutterType, elemen
t); | 156 textEditor.setGutterDecoration(decoration.line(), gutterType, elemen
t); |
| 153 } | 157 } |
| 154 } | 158 } |
| 155 } | 159 } |
| OLD | NEW |