Chromium Code Reviews| 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 60e4f4fe32593213ead4c32aca19740254c33b70..66d8e3e3b4ba8583a024bacd520ecbc077914708 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 {!Multimap<string, !Workspace.UISourceCode.LineMarker>} */ |
| + this._decorations = new Multimap(); |
| /** @type {!Array.<!Workspace.Revision>} */ |
| this.history = []; |
| @@ -608,52 +608,50 @@ Workspace.UISourceCode = class extends Common.Object { |
| * @param {?} data |
| */ |
| addLineDecoration(lineNumber, type, data) { |
| - var markers = this._lineDecorations.get(type); |
| - if (!markers) { |
| - markers = new Map(); |
| - this._lineDecorations.set(type, markers); |
| - } |
| - var marker = new Workspace.UISourceCode.LineMarker(lineNumber, type, data); |
| - markers.set(lineNumber, marker); |
| - this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationAdded, marker); |
| + this.addDecoration(Common.TextRange.createFromLocation(lineNumber, 0), type, data); |
| } |
| /** |
| - * @param {number} lineNumber |
| + * @param {!Common.TextRange} range |
| * @param {string} type |
| + * @param {?} data |
| */ |
| - removeLineDecoration(lineNumber, type) { |
| - var markers = this._lineDecorations.get(type); |
| - if (!markers) |
| - return; |
| - var marker = markers.get(lineNumber); |
| - if (!marker) |
| - return; |
| - markers.delete(lineNumber); |
| - this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationRemoved, marker); |
| - if (!markers.size) |
| - this._lineDecorations.delete(type); |
| + addDecoration(range, type, data) { |
| + var marker = new Workspace.UISourceCode.LineMarker(range, type, data); |
| + this._decorations.set(type, marker); |
| + this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationAdded, marker); |
| } |
| /** |
| * @param {string} type |
| */ |
| - removeAllLineDecorations(type) { |
| - var markers = this._lineDecorations.get(type); |
| - if (!markers) |
| - return; |
| - this._lineDecorations.delete(type); |
| + removeDecorationsForType(type) { |
| + var markers = this._decorations.get(type); |
| + this._decorations.removeAll(type); |
| markers.forEach(marker => { |
| this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationRemoved, marker); |
| }); |
| } |
| /** |
| + * @return {!Array<!Workspace.UISourceCode.LineMarker>} |
| + */ |
| + allDecorations() { |
| + return this._decorations.valuesArray(); |
| + } |
| + |
| + removeAllDecorations() { |
| + this._decorations.valuesArray().forEach(marker => |
| + this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationRemoved, marker)); |
|
lushnikov
2016/11/17 17:55:52
event sending should be the last thing you do. Oth
|
| + this._decorations.clear(); |
| + } |
| + |
| + /** |
| * @param {string} type |
| - * @return {?Map<number, !Workspace.UISourceCode.LineMarker>} |
| + * @return {!Set<!Workspace.UISourceCode.LineMarker>} |
| */ |
| - lineDecorations(type) { |
| - return this._lineDecorations.get(type) || null; |
| + decorationsForType(type) { |
| + return this._decorations.get(type); |
| } |
| }; |
| @@ -906,21 +904,21 @@ Workspace.UISourceCode.Message.Level = { |
| */ |
| Workspace.UISourceCode.LineMarker = class { |
| /** |
| - * @param {number} line |
| + * @param {!Common.TextRange} range |
| * @param {string} type |
| * @param {?} data |
| */ |
| - constructor(line, type, data) { |
| - this._line = line; |
| + constructor(range, type, data) { |
| + this._range = range; |
| this._type = type; |
| this._data = data; |
| } |
| /** |
| - * @return {number} |
| + * @return {!Common.TextRange} |
| */ |
| - line() { |
| - return this._line; |
| + range() { |
| + return this._range; |
| } |
| /** |