Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/sources/UISourceCodeFrame.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/sources/UISourceCodeFrame.js b/third_party/WebKit/Source/devtools/front_end/sources/UISourceCodeFrame.js |
| index df56d748899a2be33b825c6110a4fb8679790baa..049262fc082a534a3adb7132f62e68910b046095 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/sources/UISourceCodeFrame.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/sources/UISourceCodeFrame.js |
| @@ -41,6 +41,8 @@ WebInspector.UISourceCodeFrame = function(uiSourceCode) |
| this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyCommitted, this._onWorkingCopyCommitted, this); |
| this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.MessageAdded, this._onMessageAdded, this); |
| this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.MessageRemoved, this._onMessageRemoved, this); |
| + this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.LineMarkerAdded, this._onLineMarkerAdded, this); |
| + this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.LineMarkerRemoved, this._onLineMarkerRemoved, this); |
| this._updateStyle(); |
| this._errorPopoverHelper = new WebInspector.PopoverHelper(this.element, this._getErrorAnchor.bind(this), this._showErrorPopover.bind(this)); |
| @@ -118,6 +120,7 @@ WebInspector.UISourceCodeFrame.prototype = { |
| WebInspector.SourceFrame.prototype.onTextEditorContentLoaded.call(this); |
| for (var message of this._uiSourceCode.messages()) |
| this._addMessageToSource(message); |
| + this._populateLineMarkers(); |
| }, |
| /** |
| @@ -330,6 +333,37 @@ WebInspector.UISourceCodeFrame.prototype = { |
| } |
| }, |
| + /** |
| + * @param {!WebInspector.Event} event |
| + */ |
| + _onLineMarkerAdded: function(event) |
| + { |
| + var marker = /** @type {!WebInspector.UISourceCode.LineMarker} */ (event.data); |
| + var decorator = WebInspector.UISourceCodeFrame._lineMarkerDecorator(marker.type()); |
| + if (!decorator) |
| + return; |
| + this._textEditor.setGutterMarker(marker.line(), marker.type(), decorator.decorate(marker.data())); |
| + }, |
| + |
| + /** |
| + * @param {!WebInspector.Event} event |
| + */ |
| + _onLineMarkerRemoved: function(event) |
| + { |
| + var marker = /** @type {!WebInspector.UISourceCode.LineMarker} */ (event.data); |
| + this._textEditor.setGutterMarker(marker.line(), marker.type(), null); |
| + }, |
| + |
| + _populateLineMarkers: function() |
| + { |
| + for (var marker of this.uiSourceCode().lineMarkers()) { |
| + var decorator = WebInspector.UISourceCodeFrame._lineMarkerDecorator(marker.type()); |
| + if (!decorator) |
| + continue; |
| + this._textEditor.setGutterMarker(marker.line(), marker.type(), decorator.decorate(marker.data())); |
| + } |
| + }, |
| + |
| __proto__: WebInspector.SourceFrame.prototype |
| } |
| @@ -554,3 +588,53 @@ WebInspector.UISourceCode.Message.messageLevelComparator = function(a, b) |
| { |
| return WebInspector.UISourceCode.Message._messageLevelPriority[a.level()] - WebInspector.UISourceCode.Message._messageLevelPriority[b.level()]; |
| } |
| + |
| +/** |
| + * @param {string} type |
| + * @return {?WebInspector.UISourceCodeFrame.Decorator} |
| + */ |
| +WebInspector.UISourceCodeFrame._lineMarkerDecorator = function(type) |
| +{ |
| + if (!WebInspector.UISourceCodeFrame._lineMarkerDecorator._decorators) { |
| + WebInspector.UISourceCodeFrame._lineMarkerDecorator._decorators = new Map(); |
| + WebInspector.UISourceCodeFrame._lineMarkerDecorator._decorators.set("performance", new WebInspector.UISourceCodeFrame.PerformanceDecorator()); |
|
pfeldman
2016/03/03 02:38:42
this should move to the profiler module.
alph
2016/03/05 00:37:08
Done.
|
| + } |
| + return WebInspector.UISourceCodeFrame._lineMarkerDecorator._decorators.get(type) || null; |
| +} |
| + |
| +/** |
| + * @interface |
| + */ |
| +WebInspector.UISourceCodeFrame.Decorator = function() { } |
| + |
| +WebInspector.UISourceCodeFrame.Decorator.prototype = { |
| + /** |
| + * @param {?} data |
| + * @return {!Element} |
| + */ |
| + decorate: function(data) { } |
| +} |
| + |
| +/** |
| + * @constructor |
| + * @implements {WebInspector.UISourceCodeFrame.Decorator} |
| + */ |
| +WebInspector.UISourceCodeFrame.PerformanceDecorator = function() |
| +{ |
| +} |
| + |
| +WebInspector.UISourceCodeFrame.PerformanceDecorator.prototype = { |
| + /** |
| + * @override |
| + * @param {?} data |
| + * @return {!Element} |
| + */ |
| + decorate: function(data) |
| + { |
| + var info = /** @type {!{text: string, intensity: number}} */ (data); |
| + var element = createElementWithClass("div", "text-editor-performance-info"); |
| + element.textContent = info.text; |
| + element.style.backgroundColor = `rgba(255, 0, 0, ${info.intensity.toFixed(3)})`; |
| + return element; |
| + } |
| +} |