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

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 = 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) {
lushnikov 2016/11/16 22:53:54 why this change?
113 this._uiLocation.uiSourceCode.removeLineDecoration(
114 this._uiLocation.lineNumber, Components.LineLevelProfile.LineDecorator .type);
115 }
116 this._uiLocation = liveLocation.uiLocation(); 112 this._uiLocation = liveLocation.uiLocation();
117 if (this._uiLocation) { 113 if (this._uiLocation) {
118 this._uiLocation.uiSourceCode.addLineDecoration( 114 this._uiLocation.uiSourceCode.addLineDecoration(
119 this._uiLocation.lineNumber, Components.LineLevelProfile.LineDecorator .type, this._time); 115 this._uiLocation.lineNumber, Components.LineLevelProfile.LineDecorator .type, this._time);
120 } 116 }
121 } 117 }
122 }; 118 };
123 119
124 /** 120 /**
125 * @implements {Sources.UISourceCodeFrame.LineDecorator} 121 * @implements {Sources.UISourceCodeFrame.LineDecorator}
126 * @unrestricted 122 * @unrestricted
127 */ 123 */
128 Components.LineLevelProfile.LineDecorator = class { 124 Components.LineLevelProfile.LineDecorator = class {
129 /** 125 /**
130 * @override 126 * @override
131 * @param {!Workspace.UISourceCode} uiSourceCode 127 * @param {!Workspace.UISourceCode} uiSourceCode
132 * @param {!TextEditor.CodeMirrorTextEditor} textEditor 128 * @param {!TextEditor.CodeMirrorTextEditor} textEditor
133 */ 129 */
134 decorate(uiSourceCode, textEditor) { 130 decorate(uiSourceCode, textEditor) {
135 var gutterType = 'CodeMirror-gutter-performance'; 131 var gutterType = 'CodeMirror-gutter-performance';
136 var decorations = uiSourceCode.lineDecorations(Components.LineLevelProfile.L ineDecorator.type); 132 var decorations = uiSourceCode.decorations(Components.LineLevelProfile.LineD ecorator.type);
137 textEditor.uninstallGutter(gutterType); 133 textEditor.uninstallGutter(gutterType);
138 if (!decorations) 134 if (!decorations)
139 return; 135 return;
140 textEditor.installGutter(gutterType, false); 136 textEditor.installGutter(gutterType, false);
141 for (var decoration of decorations.values()) { 137 for (var decoration of decorations) {
142 var time = /** @type {number} */ (decoration.data()); 138 var time = /** @type {number} */ (decoration.data());
143 var text = Common.UIString('%.1f\xa0ms', time); 139 var text = Common.UIString('%.1f\xa0ms', time);
144 var intensity = Number.constrain(Math.log10(1 + 2 * time) / 5, 0.02, 1); 140 var intensity = Number.constrain(Math.log10(1 + 2 * time) / 5, 0.02, 1);
145 var element = createElementWithClass('div', 'text-editor-line-marker-perfo rmance'); 141 var element = createElementWithClass('div', 'text-editor-line-marker-perfo rmance');
146 element.textContent = text; 142 element.textContent = text;
147 element.style.backgroundColor = `hsla(44, 100%, 50%, ${intensity.toFixed(3 )})`; 143 element.style.backgroundColor = `hsla(44, 100%, 50%, ${intensity.toFixed(3 )})`;
148 textEditor.setGutterDecoration(decoration.line(), gutterType, element); 144 textEditor.setGutterDecoration(decoration.line(), gutterType, element);
149 } 145 }
150 } 146 }
151 }; 147 };
152 148
153 Components.LineLevelProfile.LineDecorator.type = 'performance'; 149 Components.LineLevelProfile.LineDecorator.type = 'performance';
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698