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

Unified Diff: third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js
diff --git a/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js b/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js
index fff83b1dbd5d7b5996a6295f93f7bbae49450319..5653f5fcf263f168cb832aa92c35a8a64bba4487 100644
--- a/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js
+++ b/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js
@@ -60,8 +60,8 @@ Workspace.UISourceCode = class extends Common.Object {
this._requestContentCallback = null;
/** @type {?Promise<?string>} */
this._requestContentPromise = null;
- /** @type {!Map<string, !Map<number, !Workspace.UISourceCode.LineMarker>>} */
- this._lineDecorations = new Map();
+ /** @type {!Map<string, !Map<!Common.TextRange, !Workspace.UISourceCode.LineMarker>>} */
caseq 2016/11/15 22:07:05 I wonder if there's any reason to have map now.
+ this._decorations = new Map();
/** @type {!Array.<!Workspace.Revision>} */
this.history = [];
@@ -606,13 +606,22 @@ Workspace.UISourceCode = class extends Common.Object {
* @param {?} data
*/
addLineDecoration(lineNumber, type, data) {
- var markers = this._lineDecorations.get(type);
+ this.addDecoration(Common.TextRange.createFromLocation(lineNumber, 0), type, data);
+ }
+
+ /**
+ * @param {!Common.TextRange} range
+ * @param {string} type
+ * @param {?} data
+ */
+ addDecoration(range, type, data) {
+ var markers = this._decorations.get(type);
if (!markers) {
markers = new Map();
- this._lineDecorations.set(type, markers);
+ this._decorations.set(type, markers);
}
- var marker = new Workspace.UISourceCode.LineMarker(lineNumber, type, data);
- markers.set(lineNumber, marker);
+ var marker = new Workspace.UISourceCode.LineMarker(range.startLine, type, data);
+ markers.set(range, marker);
this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationAdded, marker);
}
@@ -621,37 +630,56 @@ Workspace.UISourceCode = class extends Common.Object {
* @param {string} type
*/
removeLineDecoration(lineNumber, type) {
- var markers = this._lineDecorations.get(type);
+ this.removeDecoration(Common.TextRange.createFromLocation(lineNumber, 0), type);
caseq 2016/11/15 22:07:05 Does this actually work?
+ }
+
+ /**
+ * @param {!Common.TextRange} range
+ * @param {string} type
+ */
+ removeDecoration(range, type) {
+ var markers = this._decorations.get(type);
if (!markers)
return;
- var marker = markers.get(lineNumber);
+ var marker = markers.get(range);
if (!marker)
return;
- markers.delete(lineNumber);
+ markers.delete(range);
this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationRemoved, marker);
if (!markers.size)
- this._lineDecorations.delete(type);
+ this._decorations.delete(type);
}
/**
* @param {string} type
*/
removeAllLineDecorations(type) {
- var markers = this._lineDecorations.get(type);
+ var markers = this._decorations.get(type);
if (!markers)
return;
- this._lineDecorations.delete(type);
+ this._decorations.delete(type);
markers.forEach(marker => {
this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationRemoved, marker);
});
}
/**
+ * @return {!Map<string, !Map<!Common.TextRange, !Workspace.UISourceCode.LineMarker>>}
+ */
+ getAllDecorations() {
+ return this._decorations;
+ }
+
+ removeAllDecorations() {
+ this._decorations.clear();
+ }
+
+ /**
* @param {string} type
- * @return {?Map<number, !Workspace.UISourceCode.LineMarker>}
+ * @return {?Map<!Common.TextRange, !Workspace.UISourceCode.LineMarker>}
*/
lineDecorations(type) {
- return this._lineDecorations.get(type) || null;
+ return this._decorations.get(type) || null;
}
};

Powered by Google App Engine
This is Rietveld 408576698