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

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.removeDecorationsForType(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 = 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 ? SDK.DebuggerModel.fromTarget(target) : 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]) {
(...skipping 21 matching lines...) Expand all
102 */ 102 */
103 constructor(rawLocation, time, locationPool) { 103 constructor(rawLocation, time, locationPool) {
104 this._time = time; 104 this._time = time;
105 Bindings.debuggerWorkspaceBinding.createLiveLocation(rawLocation, this.updat eLocation.bind(this), locationPool); 105 Bindings.debuggerWorkspaceBinding.createLiveLocation(rawLocation, this.updat eLocation.bind(this), locationPool);
106 } 106 }
107 107
108 /** 108 /**
109 * @param {!Bindings.LiveLocation} liveLocation 109 * @param {!Bindings.LiveLocation} liveLocation
110 */ 110 */
111 updateLocation(liveLocation) { 111 updateLocation(liveLocation) {
112 if (this._uiLocation) { 112 if (this._uiLocation)
113 this._uiLocation.uiSourceCode.removeLineDecoration( 113 this._uiLocation.uiSourceCode.removeDecorationsForType(Components.LineLeve lProfile.LineDecorator.type);
114 this._uiLocation.lineNumber, Components.LineLevelProfile.LineDecorator .type);
115 }
116 this._uiLocation = liveLocation.uiLocation(); 114 this._uiLocation = liveLocation.uiLocation();
117 if (this._uiLocation) { 115 if (this._uiLocation) {
118 this._uiLocation.uiSourceCode.addLineDecoration( 116 this._uiLocation.uiSourceCode.addLineDecoration(
119 this._uiLocation.lineNumber, Components.LineLevelProfile.LineDecorator .type, this._time); 117 this._uiLocation.lineNumber, Components.LineLevelProfile.LineDecorator .type, this._time);
120 } 118 }
121 } 119 }
122 }; 120 };
123 121
124 /** 122 /**
125 * @implements {Sources.UISourceCodeFrame.LineDecorator} 123 * @implements {Sources.UISourceCodeFrame.LineDecorator}
126 * @unrestricted 124 * @unrestricted
127 */ 125 */
128 Components.LineLevelProfile.LineDecorator = class { 126 Components.LineLevelProfile.LineDecorator = class {
129 /** 127 /**
130 * @override 128 * @override
131 * @param {!Workspace.UISourceCode} uiSourceCode 129 * @param {!Workspace.UISourceCode} uiSourceCode
132 * @param {!TextEditor.CodeMirrorTextEditor} textEditor 130 * @param {!TextEditor.CodeMirrorTextEditor} textEditor
133 */ 131 */
134 decorate(uiSourceCode, textEditor) { 132 decorate(uiSourceCode, textEditor) {
135 var gutterType = 'CodeMirror-gutter-performance'; 133 var gutterType = 'CodeMirror-gutter-performance';
136 var decorations = uiSourceCode.lineDecorations(Components.LineLevelProfile.L ineDecorator.type); 134 var decorations = uiSourceCode.decorationsForType(Components.LineLevelProfil e.LineDecorator.type);
137 textEditor.uninstallGutter(gutterType); 135 textEditor.uninstallGutter(gutterType);
138 if (!decorations) 136 if (!decorations.size)
139 return; 137 return;
140 textEditor.installGutter(gutterType, false); 138 textEditor.installGutter(gutterType, false);
141 for (var decoration of decorations.values()) { 139 for (var decoration of decorations) {
142 var time = /** @type {number} */ (decoration.data()); 140 var time = /** @type {number} */ (decoration.data());
143 var text = Common.UIString('%.1f\xa0ms', time); 141 var text = Common.UIString('%.1f\xa0ms', time);
144 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);
145 var element = createElementWithClass('div', 'text-editor-line-marker-perfo rmance'); 143 var element = createElementWithClass('div', 'text-editor-line-marker-perfo rmance');
146 element.textContent = text; 144 element.textContent = text;
147 element.style.backgroundColor = `hsla(44, 100%, 50%, ${intensity.toFixed(3 )})`; 145 element.style.backgroundColor = `hsla(44, 100%, 50%, ${intensity.toFixed(3 )})`;
148 textEditor.setGutterDecoration(decoration.line(), gutterType, element); 146 textEditor.setGutterDecoration(decoration.range().startLine, gutterType, e lement);
149 } 147 }
150 } 148 }
151 }; 149 };
152 150
153 Components.LineLevelProfile.LineDecorator.type = 'performance'; 151 Components.LineLevelProfile.LineDecorator.type = 'performance';
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698