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

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

Issue 2472213005: DevTools: introduce "Track CSS Usage" experiment (Closed)
Patch Set: Unused CSS highlight in sources panel 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
(Empty)
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
3 // found in the LICENSE file.
4
5 WebInspector.CoverageProfile = class {
6 constructor() {
7 this._updateTimer = null;
8 this.reset();
9 }
10
11 /**
12 * @return {!WebInspector.CoverageProfile}
13 */
14 static instance() {
15 if (!WebInspector.CoverageProfile._instance)
16 WebInspector.CoverageProfile._instance = new WebInspector.CoverageProfile( );
17
18 return WebInspector.CoverageProfile._instance;
19 }
20
21 /**
22 * @param {string} url
23 * @param {!Protocol.CSS.SourceRange} range
24 */
25 appendUnusedRule(url, range) {
26 if (!url)
27 return;
28
29 var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(url);
30 if (!uiSourceCode)
31 return;
32
33 for (var line = range.startLine; line <= range.endLine; ++line)
34 uiSourceCode.addLineDecoration(line, WebInspector.CoverageProfile.LineDeco rator.type, range.startColumn);
35 }
36
37 reset() {
38 WebInspector.workspace.uiSourceCodes().forEach(
39 uiSourceCode => uiSourceCode.removeAllLineDecorations(WebInspector.Cover ageProfile.LineDecorator.type));
40 }
41 };
42
43 /**
44 * @implements {WebInspector.UISourceCodeFrame.LineDecorator}
45 */
46 WebInspector.CoverageProfile.LineDecorator = class {
47 /**
48 * @override
49 * @param {!WebInspector.UISourceCode} uiSourceCode
50 * @param {!WebInspector.CodeMirrorTextEditor} textEditor
51 */
52 decorate(uiSourceCode, textEditor) {
53 var gutterType = 'CodeMirror-gutter-coverage';
54
55 var decorations = uiSourceCode.lineDecorations(WebInspector.CoverageProfile. LineDecorator.type);
56 textEditor.uninstallGutter(gutterType);
57 if (!decorations)
58 return;
59
60 textEditor.installGutter(gutterType, false);
61
62 for (var decoration of decorations.values()) {
63 var element = createElementWithClass('div', 'text-editor-line-marker-cover age');
64 textEditor.setGutterDecoration(decoration.line(), gutterType, element);
65 }
66 }
67 };
68
69 WebInspector.CoverageProfile.LineDecorator.type = 'coverage';
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/BUILD.gn ('k') | third_party/WebKit/Source/devtools/front_end/components_lazy/module.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698