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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sources/UISourceCodeFrame.js

Issue 1768183003: DevTools: Support line markers in UISourceCode and Code Mirror (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor tweaks Created 4 years, 9 months 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/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..30b8169529306811a03ac210f09224f42b74678c 100644
--- a/third_party/WebKit/Source/devtools/front_end/sources/UISourceCodeFrame.js
+++ b/third_party/WebKit/Source/devtools/front_end/sources/UISourceCodeFrame.js
@@ -37,10 +37,14 @@ WebInspector.UISourceCodeFrame = function(uiSourceCode)
WebInspector.SourceFrame.call(this, this._uiSourceCode);
this.textEditor.setAutocompleteDelegate(new WebInspector.SimpleAutocompleteDelegate());
this._rowMessageBuckets = {};
+ /** @type {!Set<string>} */
+ this._typeDecorationsPending = new Set();
this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.WorkingCopyChanged, this._onWorkingCopyChanged, this);
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.LineDecorationAdded, this._onLineDecorationAdded, this);
+ this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.LineDecorationRemoved, this._onLineDecorationRemoved, this);
this._updateStyle();
this._errorPopoverHelper = new WebInspector.PopoverHelper(this.element, this._getErrorAnchor.bind(this), this._showErrorPopover.bind(this));
@@ -118,6 +122,7 @@ WebInspector.UISourceCodeFrame.prototype = {
WebInspector.SourceFrame.prototype.onTextEditorContentLoaded.call(this);
for (var message of this._uiSourceCode.messages())
this._addMessageToSource(message);
+ this._decorateAllTypes();
},
/**
@@ -330,6 +335,44 @@ WebInspector.UISourceCodeFrame.prototype = {
}
},
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _onLineDecorationAdded: function(event)
+ {
+ var marker = /** @type {!WebInspector.UISourceCode.LineMarker} */ (event.data);
+ this._decorateTypeThrottled(marker.type());
+ },
+
+ /**
+ * @param {!WebInspector.Event} event
+ */
+ _onLineDecorationRemoved: function(event)
+ {
+ var marker = /** @type {!WebInspector.UISourceCode.LineMarker} */ (event.data);
+ this._decorateTypeThrottled(marker.type());
+ },
+
+ /**
+ * @param {string} type
+ */
+ _decorateTypeThrottled: function(type)
+ {
+ if (this._typeDecorationsPending.has(type))
+ return;
+ this._typeDecorationsPending.add(type);
+ self.runtime.extensions(WebInspector.UISourceCodeFrame.LineDecorator).find(extension => extension.descriptor()["decoratorType"] === type).instancePromise().then(decorator => {
+ decorator.decorate(this.uiSourceCode(), this._textEditor);
pfeldman 2016/03/09 23:52:57 swap these lines.
alph 2016/03/09 23:58:22 Done.
+ this._typeDecorationsPending.delete(type);
+ });
+ },
+
+ _decorateAllTypes: function()
+ {
+ var extensions = self.runtime.extensions(WebInspector.UISourceCodeFrame.LineDecorator);
+ extensions.forEach(extension => this._decorateTypeThrottled(extension.descriptor()["decoratorType"]));
+ },
+
__proto__: WebInspector.SourceFrame.prototype
}
@@ -342,6 +385,19 @@ WebInspector.UISourceCodeFrame._lineClassPerLevel[WebInspector.UISourceCode.Mess
WebInspector.UISourceCodeFrame._lineClassPerLevel[WebInspector.UISourceCode.Message.Level.Warning] = "text-editor-line-with-warning";
/**
+ * @interface
+ */
+WebInspector.UISourceCodeFrame.LineDecorator = function() { }
+
+WebInspector.UISourceCodeFrame.LineDecorator.prototype = {
+ /**
+ * @param {!WebInspector.UISourceCode} uiSourceCode
+ * @param {!WebInspector.CodeMirrorTextEditor} textEditor
+ */
+ decorate: function(uiSourceCode, textEditor) { }
+}
+
+/**
* @constructor
* @param {!WebInspector.UISourceCode.Message} message
*/

Powered by Google App Engine
This is Rietveld 408576698