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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/components_lazy/CoverageProfile.js
diff --git a/third_party/WebKit/Source/devtools/front_end/components_lazy/CoverageProfile.js b/third_party/WebKit/Source/devtools/front_end/components_lazy/CoverageProfile.js
new file mode 100644
index 0000000000000000000000000000000000000000..ca61e6107a0a9f536a7dcf3b8e319c561d6ab787
--- /dev/null
+++ b/third_party/WebKit/Source/devtools/front_end/components_lazy/CoverageProfile.js
@@ -0,0 +1,69 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+WebInspector.CoverageProfile = class {
+ constructor() {
+ this._updateTimer = null;
+ this.reset();
+ }
+
+ /**
+ * @return {!WebInspector.CoverageProfile}
+ */
+ static instance() {
+ if (!WebInspector.CoverageProfile._instance)
+ WebInspector.CoverageProfile._instance = new WebInspector.CoverageProfile();
+
+ return WebInspector.CoverageProfile._instance;
+ }
+
+ /**
+ * @param {string} url
+ * @param {!Protocol.CSS.SourceRange} range
+ */
+ appendUnusedRule(url, range) {
+ if (!url)
+ return;
+
+ var uiSourceCode = WebInspector.workspace.uiSourceCodeForURL(url);
+ if (!uiSourceCode)
+ return;
+
+ for (var line = range.startLine; line <= range.endLine; ++line)
+ uiSourceCode.addLineDecoration(line, WebInspector.CoverageProfile.LineDecorator.type, range.startColumn);
+ }
+
+ reset() {
+ WebInspector.workspace.uiSourceCodes().forEach(
+ uiSourceCode => uiSourceCode.removeAllLineDecorations(WebInspector.CoverageProfile.LineDecorator.type));
+ }
+};
+
+/**
+ * @implements {WebInspector.UISourceCodeFrame.LineDecorator}
+ */
+WebInspector.CoverageProfile.LineDecorator = class {
+ /**
+ * @override
+ * @param {!WebInspector.UISourceCode} uiSourceCode
+ * @param {!WebInspector.CodeMirrorTextEditor} textEditor
+ */
+ decorate(uiSourceCode, textEditor) {
+ var gutterType = 'CodeMirror-gutter-coverage';
+
+ var decorations = uiSourceCode.lineDecorations(WebInspector.CoverageProfile.LineDecorator.type);
+ textEditor.uninstallGutter(gutterType);
+ if (!decorations)
+ return;
+
+ textEditor.installGutter(gutterType, false);
+
+ for (var decoration of decorations.values()) {
+ var element = createElementWithClass('div', 'text-editor-line-marker-coverage');
+ textEditor.setGutterDecoration(decoration.line(), gutterType, element);
+ }
+ }
+};
+
+WebInspector.CoverageProfile.LineDecorator.type = 'coverage';
« 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