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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/components_lazy/CoverageProfile.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 Components.CoverageProfile = class { 5 Components.CoverageProfile = class {
6 constructor() { 6 constructor() {
7 this._updateTimer = null; 7 this._updateTimer = null;
8 this.reset(); 8 this.reset();
9 } 9 }
10 10
11 /** 11 /**
12 * @return {!Components.CoverageProfile} 12 * @return {!Components.CoverageProfile}
13 */ 13 */
14 static instance() { 14 static instance() {
15 if (!Components.CoverageProfile._instance) 15 if (!Components.CoverageProfile._instance)
16 Components.CoverageProfile._instance = new Components.CoverageProfile(); 16 Components.CoverageProfile._instance = new Components.CoverageProfile();
17 17
18 return Components.CoverageProfile._instance; 18 return Components.CoverageProfile._instance;
19 } 19 }
20 20
21 /** 21 /**
22 * @param {string} url 22 * @param {string} url
23 * @param {!Protocol.CSS.SourceRange} range 23 * @param {!Common.TextRange} range
24 */ 24 */
25 appendUnusedRule(url, range) { 25 appendUnusedRule(url, range) {
26 if (!url) 26 if (!url)
27 return; 27 return;
28 28
29 var uiSourceCode = Workspace.workspace.uiSourceCodeForURL(url); 29 var uiSourceCode = Workspace.workspace.uiSourceCodeForURL(url);
30 if (!uiSourceCode) 30 if (!uiSourceCode)
31 return; 31 return;
32 32
33 for (var line = range.startLine; line <= range.endLine; ++line) 33 if (range.startColumn)
34 uiSourceCode.addLineDecoration(line, Components.CoverageProfile.LineDecora tor.type, range.startColumn); 34 range.startColumn--;
35 uiSourceCode.addDecoration(range, Components.CoverageProfile.LineDecorator.t ype, 0);
35 } 36 }
36 37
37 reset() { 38 reset() {
38 Workspace.workspace.uiSourceCodes().forEach( 39 Workspace.workspace.uiSourceCodes().forEach(
39 uiSourceCode => uiSourceCode.removeAllLineDecorations(Components.Coverag eProfile.LineDecorator.type)); 40 uiSourceCode => uiSourceCode.removeDecorationsForType(Components.Coverag eProfile.LineDecorator.type));
40 } 41 }
41 }; 42 };
42 43
43 /** 44 /**
44 * @implements {Sources.UISourceCodeFrame.LineDecorator} 45 * @implements {Sources.UISourceCodeFrame.LineDecorator}
45 */ 46 */
46 Components.CoverageProfile.LineDecorator = class { 47 Components.CoverageProfile.LineDecorator = class {
47 /** 48 /**
48 * @override 49 * @override
49 * @param {!Workspace.UISourceCode} uiSourceCode 50 * @param {!Workspace.UISourceCode} uiSourceCode
50 * @param {!TextEditor.CodeMirrorTextEditor} textEditor 51 * @param {!TextEditor.CodeMirrorTextEditor} textEditor
51 */ 52 */
52 decorate(uiSourceCode, textEditor) { 53 decorate(uiSourceCode, textEditor) {
53 var gutterType = 'CodeMirror-gutter-coverage'; 54 var gutterType = 'CodeMirror-gutter-coverage';
54 55
55 var decorations = uiSourceCode.lineDecorations(Components.CoverageProfile.Li neDecorator.type); 56 var decorations = uiSourceCode.decorationsForType(Components.CoverageProfile .LineDecorator.type);
56 textEditor.uninstallGutter(gutterType); 57 textEditor.uninstallGutter(gutterType);
57 if (!decorations) 58 if (!decorations.size)
58 return; 59 return;
59 60
60 textEditor.installGutter(gutterType, false); 61 textEditor.installGutter(gutterType, false);
61 62
62 for (var decoration of decorations.values()) { 63 for (var decoration of decorations) {
63 var element = createElementWithClass('div', 'text-editor-line-marker-cover age'); 64 for (var line = decoration.range().startLine; line <= decoration.range().e ndLine; ++line) {
64 textEditor.setGutterDecoration(decoration.line(), gutterType, element); 65 var element = createElementWithClass('div', 'text-editor-line-marker-cov erage');
66 textEditor.setGutterDecoration(line, gutterType, element);
67 }
65 } 68 }
66 } 69 }
67 }; 70 };
68 71
69 Components.CoverageProfile.LineDecorator.type = 'coverage'; 72 Components.CoverageProfile.LineDecorator.type = 'coverage';
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698