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

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

Issue 1403373013: DevTools: move ui messages from SourceFrame to UISourceCodeFrame (step2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed Created 5 years, 2 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 e1cced3f650dd1e229f51f9e39b5e55e8053a778..5b8763c8207a255edc300f4734737ee572770dde 100644
--- a/third_party/WebKit/Source/devtools/front_end/sources/UISourceCodeFrame.js
+++ b/third_party/WebKit/Source/devtools/front_end/sources/UISourceCodeFrame.js
@@ -39,6 +39,8 @@ WebInspector.UISourceCodeFrame = function(uiSourceCode)
this._rowMessageBuckets = {};
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._updateStyle();
this._errorPopoverHelper = new WebInspector.PopoverHelper(this.element, this._getErrorAnchor.bind(this), this._showErrorPopover.bind(this));
@@ -108,10 +110,25 @@ WebInspector.UISourceCodeFrame.prototype = {
delete this._muteSourceCodeEvents;
},
+ /**
+ * @override
+ */
+ onTextEditorContentLoaded: function()
+ {
+ WebInspector.SourceFrame.prototype.onTextEditorContentLoaded.call(this);
+ for (var message of this._uiSourceCode.messages())
+ this._addMessageToSource(message);
+ },
+
+ /**
+ * @override
+ * @param {!WebInspector.TextRange} oldRange
+ * @param {!WebInspector.TextRange} newRange
+ */
onTextChanged: function(oldRange, newRange)
{
WebInspector.SourceFrame.prototype.onTextChanged.call(this, oldRange, newRange);
- this.clearMessages();
+ this._clearMessages();
if (this._isSettingContent)
return;
this._muteSourceCodeEvents = true;
@@ -122,12 +139,6 @@ WebInspector.UISourceCodeFrame.prototype = {
delete this._muteSourceCodeEvents;
},
- onTextEditorContentLoaded: function()
- {
- WebInspector.SourceFrame.prototype.onTextEditorContentLoaded.call(this);
- this.clearMessages();
- },
-
/**
* @param {!WebInspector.Event} event
*/
@@ -201,9 +212,20 @@ WebInspector.UISourceCodeFrame.prototype = {
},
/**
+ * @param {!WebInspector.Event} event
+ */
+ _onMessageAdded: function(event)
+ {
+ if (!this.loaded)
+ return;
+ var message = /** @type {!WebInspector.UISourceCode.Message} */ (event.data);
+ this._addMessageToSource(message);
+ },
+
+ /**
* @param {!WebInspector.UISourceCode.Message} message
*/
- addMessageToSource: function(message)
+ _addMessageToSource: function(message)
{
var lineNumber = message.lineNumber();
if (lineNumber >= this._textEditor.linesCount)
@@ -218,9 +240,20 @@ WebInspector.UISourceCodeFrame.prototype = {
},
/**
+ * @param {!WebInspector.Event} event
+ */
+ _onMessageRemoved: function(event)
+ {
+ if (!this.loaded)
+ return;
+ var message = /** @type {!WebInspector.UISourceCode.Message} */ (event.data);
+ this._removeMessageFromSource(message);
+ },
+
+ /**
* @param {!WebInspector.UISourceCode.Message} message
*/
- removeMessageFromSource: function(message)
+ _removeMessageFromSource: function(message)
{
var lineNumber = message.lineNumber();
if (lineNumber >= this._textEditor.linesCount)
@@ -238,7 +271,7 @@ WebInspector.UISourceCodeFrame.prototype = {
}
},
- clearMessages: function()
+ _clearMessages: function()
{
for (var line in this._rowMessageBuckets) {
var bubble = this._rowMessageBuckets[line];
@@ -247,6 +280,7 @@ WebInspector.UISourceCodeFrame.prototype = {
this._rowMessageBuckets = {};
this._errorPopoverHelper.hidePopover();
+ this._uiSourceCode.removeAllMessages();
},
/**
@@ -361,19 +395,6 @@ WebInspector.UISourceCodeFrame.Infobar.prototype = {
__proto__: WebInspector.Infobar.prototype
}
-/**
- * @param {!WebInspector.ConsoleMessage} consoleMessage
- * @param {number} lineNumber
- * @param {number} columnNumber
- * @return {!WebInspector.UISourceCode.Message}
- */
-WebInspector.UISourceCodeFrame.uiMessageFromConsoleMessage = function(consoleMessage, lineNumber, columnNumber)
-{
- console.assert(consoleMessage.level === WebInspector.ConsoleMessage.MessageLevel.Error || consoleMessage.level === WebInspector.ConsoleMessage.MessageLevel.Warning);
- var level = consoleMessage.level === WebInspector.ConsoleMessage.MessageLevel.Error ? WebInspector.UISourceCode.Message.Level.Error : WebInspector.UISourceCode.Message.Level.Warning;
- return new WebInspector.UISourceCode.Message(level, consoleMessage.messageText, lineNumber, columnNumber);
-}
-
WebInspector.UISourceCodeFrame._iconClassPerLevel = {};
WebInspector.UISourceCodeFrame._iconClassPerLevel[WebInspector.UISourceCode.Message.Level.Error] = "error-icon";
WebInspector.UISourceCodeFrame._iconClassPerLevel[WebInspector.UISourceCode.Message.Level.Warning] = "warning-icon";

Powered by Google App Engine
This is Rietveld 408576698