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 e535581587b9244229274af30104a06f603a2453..85ffa73aeadb2557602bf486d6aa4b270c085bca 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
| @@ -52,6 +52,8 @@ WebInspector.UISourceCode = function(project, url, contentType) |
| this._requestContentCallback = null; |
| /** @type {?Promise<?string>} */ |
| this._requestContentPromise = null; |
| + /** @type {?Array<!WebInspector.UISourceCode.LineMarker>} */ |
| + this._lineMarkers = null; |
| /** @type {!Array.<!WebInspector.Revision>} */ |
| this.history = []; |
| @@ -71,6 +73,7 @@ WebInspector.UISourceCode.Events = { |
| SourceMappingChanged: "SourceMappingChanged", |
| MessageAdded: "MessageAdded", |
| MessageRemoved: "MessageRemoved", |
| + LineMarkersChanged: "LineMarkersChanged" |
|
pfeldman
2016/03/02 19:48:59
MarkersChanged
alph
2016/03/03 02:02:52
Acknowledged.
|
| } |
| WebInspector.UISourceCode.prototype = { |
| @@ -644,6 +647,40 @@ WebInspector.UISourceCode.prototype = { |
| this.dispatchEventToListeners(WebInspector.UISourceCode.Events.MessageRemoved, message); |
| }, |
| + /** |
| + * @param {number} lineNumber |
| + * @param {function(number):!{text:string, color:string}} decorator |
| + */ |
| + addLineMarker: function(lineNumber, decorator) |
|
pfeldman
2016/03/02 19:48:59
Decorator is from the UI world, while the marker i
alph
2016/03/03 02:02:52
Done.
|
| + { |
| + if (!this._lineMarkers) |
| + this._lineMarkers = []; |
|
pfeldman
2016/03/02 19:48:59
Bucket by type?
alph
2016/03/03 02:02:52
Done.
|
| + var marker = new WebInspector.UISourceCode.LineMarker(lineNumber, decorator); |
| + this._lineMarkers.push(marker); |
|
pfeldman
2016/03/02 19:48:59
There should be a way to fetch markers by type.
alph
2016/03/03 02:02:52
Done.
|
| + // Batch LineMarkersChanged events. |
| + if (this._lineMarkersChanged) |
| + return; |
| + this._lineMarkersChanged = true; |
| + setImmediate(() => { |
| + this._lineMarkersChanged = false; |
| + this.dispatchEventToListeners(WebInspector.UISourceCode.Events.LineMarkersChanged); |
|
pfeldman
2016/03/02 19:48:59
pass typeString as the data so that you were not
alph
2016/03/03 02:02:52
Done.
|
| + }); |
| + }, |
| + |
| + removeAllLineMarkers: function() |
|
pfeldman
2016/03/02 19:48:59
There should be a way to clear all "message" marke
alph
2016/03/03 02:02:52
Done.
|
| + { |
| + this._lineMarkers = null; |
| + this.dispatchEventToListeners(WebInspector.UISourceCode.Events.LineMarkersChanged); |
| + }, |
| + |
| + /** |
| + * @return {?Array<!WebInspector.UISourceCode.LineMarker>} |
| + */ |
| + lineMarkers: function() |
| + { |
| + return this._lineMarkers; |
| + }, |
| + |
| __proto__: WebInspector.Object.prototype |
| } |
| @@ -837,7 +874,8 @@ WebInspector.UISourceCode.Message.prototype = { |
| /** |
| * @return {!WebInspector.TextRange} |
| */ |
| - range: function() { |
| + range: function() |
| + { |
| return this._range; |
| }, |
| @@ -871,3 +909,40 @@ WebInspector.UISourceCode.Message.prototype = { |
| this._uiSourceCode.removeMessage(this); |
| } |
| } |
| + |
| +/** |
| + * @constructor |
| + * @param {number} line |
| + * @param {function(number):!{text:string, color:string}} decorator |
| + */ |
| +WebInspector.UISourceCode.LineMarker = function(line, decorator) |
|
pfeldman
2016/03/02 19:48:59
You will only have line and opaque object here, no
alph
2016/03/03 02:02:52
Done.
|
| +{ |
| + this._line = line; |
| + this._decorator = decorator; |
| +} |
| + |
| +WebInspector.UISourceCode.LineMarker.prototype = { |
| + /** |
| + * @return {number} |
| + */ |
| + line: function() |
| + { |
| + return this._line; |
| + }, |
| + |
| + /** |
| + * @return {string} |
| + */ |
| + text: function() |
| + { |
| + return this._decorator(this._line).text; |
| + }, |
| + |
| + /** |
| + * @return {string} |
| + */ |
| + color: function() |
| + { |
| + return this._decorator(this._line).color; |
| + } |
| +} |