Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(582)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/components_lazy/LineLevelProfile.js

Issue 2492343002: Devtools: Pretty print fix for CSS coverage decorations. (Closed)
Patch Set: Pretty print fix for CSS coverage decorations. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 Components.LineLevelProfile = class { 7 Components.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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 this._updateTimer = setTimeout(() => { 60 this._updateTimer = setTimeout(() => {
61 this._updateTimer = null; 61 this._updateTimer = null;
62 this._doUpdate(); 62 this._doUpdate();
63 }, 0); 63 }, 0);
64 } 64 }
65 65
66 _doUpdate() { 66 _doUpdate() {
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.removeAllLineDecorations(Components.LineLev elProfile.LineDecorator.type)); 70 uiSourceCode => uiSourceCode.removeAllTypeDecorations(Components.LineLev elProfile.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 = 76 var target =
77 Bindings.NetworkProject.targetForUISourceCode(uiSourceCode) || SDK.tar getManager.mainTarget(); 77 Bindings.NetworkProject.targetForUISourceCode(uiSourceCode) || SDK.tar getManager.mainTarget();
78 var debuggerModel = target ? SDK.DebuggerModel.fromTarget(target) : null; 78 var debuggerModel = target ? SDK.DebuggerModel.fromTarget(target) : null;
79 if (!debuggerModel) 79 if (!debuggerModel)
80 continue; 80 continue;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 * @unrestricted 125 * @unrestricted
126 */ 126 */
127 Components.LineLevelProfile.LineDecorator = class { 127 Components.LineLevelProfile.LineDecorator = class {
128 /** 128 /**
129 * @override 129 * @override
130 * @param {!Workspace.UISourceCode} uiSourceCode 130 * @param {!Workspace.UISourceCode} uiSourceCode
131 * @param {!TextEditor.CodeMirrorTextEditor} textEditor 131 * @param {!TextEditor.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(Components.LineLevelProfile.L ineDecorator.type); 135 var decorations = uiSourceCode.decorations(Components.LineLevelProfile.LineD ecorator.type);
136 textEditor.uninstallGutter(gutterType); 136 textEditor.uninstallGutter(gutterType);
137 if (!decorations) 137 if (!decorations)
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.values()) {
141 var time = /** @type {number} */ (decoration.data()); 141 var time = /** @type {number} */ (decoration.data());
142 var text = Common.UIString('%.1f\xa0ms', time); 142 var text = Common.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 Components.LineLevelProfile.LineDecorator.type = 'performance'; 152 Components.LineLevelProfile.LineDecorator.type = 'performance';
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698