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

Unified Diff: Source/devtools/front_end/sources/JavaScriptSourceFrame.js

Issue 1264133002: Devtools: [WIP] Implement enhanced devtools extension language APIs Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Small cleanups - prefer URIs to contentURLs, revert protocol unifications, remove lambdas Created 5 years, 4 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: Source/devtools/front_end/sources/JavaScriptSourceFrame.js
diff --git a/Source/devtools/front_end/sources/JavaScriptSourceFrame.js b/Source/devtools/front_end/sources/JavaScriptSourceFrame.js
index 6c0bacdb7442dacf3d5c8388e5e46b8bd3f3021c..086445e4f31f307b4fa79d8c919c7a0db73496c2 100644
--- a/Source/devtools/front_end/sources/JavaScriptSourceFrame.js
+++ b/Source/devtools/front_end/sources/JavaScriptSourceFrame.js
@@ -261,26 +261,37 @@ WebInspector.JavaScriptSourceFrame.prototype = {
this._compiler.scheduleCompile();
},
+ /**
+ * @override
+ * @return {!Promise}
+ */
populateLineGutterContextMenu: function(contextMenu, lineNumber)
{
- var uiLocation = new WebInspector.UILocation(this._uiSourceCode, lineNumber, 0);
- this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation);
- var breakpoint = this._breakpointManager.findBreakpointOnLine(this._uiSourceCode, lineNumber);
- if (!breakpoint) {
- // This row doesn't have a breakpoint: We want to show Add Breakpoint and Add and Edit Breakpoint.
- contextMenu.appendItem(WebInspector.UIString.capitalize("Add ^breakpoint"), this._createNewBreakpoint.bind(this, lineNumber, 0, "", true));
- contextMenu.appendItem(WebInspector.UIString.capitalize("Add ^conditional ^breakpoint…"), this._editBreakpointCondition.bind(this, lineNumber));
- } else {
- // This row has a breakpoint, we want to show edit and remove breakpoint, and either disable or enable.
- contextMenu.appendItem(WebInspector.UIString.capitalize("Remove ^breakpoint"), breakpoint.remove.bind(breakpoint));
- contextMenu.appendItem(WebInspector.UIString.capitalize("Edit ^breakpoint…"), this._editBreakpointCondition.bind(this, lineNumber, breakpoint));
- if (breakpoint.enabled())
- contextMenu.appendItem(WebInspector.UIString.capitalize("Disable ^breakpoint"), breakpoint.setEnabled.bind(breakpoint, false));
- else
- contextMenu.appendItem(WebInspector.UIString.capitalize("Enable ^breakpoint"), breakpoint.setEnabled.bind(breakpoint, true));
- }
+ return new Promise((function(resolve, reject) {
+ var uiLocation = new WebInspector.UILocation(this._uiSourceCode, lineNumber, 0);
+ this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation);
+ var breakpoint = this._breakpointManager.findBreakpointOnLine(this._uiSourceCode, lineNumber);
+ if (!breakpoint) {
+ // This row doesn't have a breakpoint: We want to show Add Breakpoint and Add and Edit Breakpoint.
+ contextMenu.appendItem(WebInspector.UIString.capitalize("Add ^breakpoint"), this._createNewBreakpoint.bind(this, lineNumber, 0, "", true));
+ contextMenu.appendItem(WebInspector.UIString.capitalize("Add ^conditional ^breakpoint…"), this._editBreakpointCondition.bind(this, lineNumber));
+ } else {
+ // This row has a breakpoint, we want to show edit and remove breakpoint, and either disable or enable.
+ contextMenu.appendItem(WebInspector.UIString.capitalize("Remove ^breakpoint"), breakpoint.remove.bind(breakpoint));
+ contextMenu.appendItem(WebInspector.UIString.capitalize("Edit ^breakpoint…"), this._editBreakpointCondition.bind(this, lineNumber, breakpoint));
+ if (breakpoint.enabled())
+ contextMenu.appendItem(WebInspector.UIString.capitalize("Disable ^breakpoint"), breakpoint.setEnabled.bind(breakpoint, false));
+ else
+ contextMenu.appendItem(WebInspector.UIString.capitalize("Enable ^breakpoint"), breakpoint.setEnabled.bind(breakpoint, true));
+ }
+ resolve();
+ }).bind(this));
},
+ /**
+ * @override
+ * @return {!Promise}
+ */
populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber)
{
var textSelection = this.textEditor.selection();
@@ -313,16 +324,16 @@ WebInspector.JavaScriptSourceFrame.prototype = {
scriptFile.addSourceMapURL(url);
}
- WebInspector.UISourceCodeFrame.prototype.populateTextAreaContextMenu.call(this, contextMenu, lineNumber, columnNumber);
-
- if (this._uiSourceCode.project().type() === WebInspector.projectTypes.Network && WebInspector.moduleSetting("jsSourceMapsEnabled").get()) {
- if (this._scriptFileForTarget.size) {
- var scriptFile = this._scriptFileForTarget.valuesArray()[0];
- var addSourceMapURLLabel = WebInspector.UIString.capitalize("Add ^source ^map\u2026");
- contextMenu.appendItem(addSourceMapURLLabel, addSourceMapURL.bind(this, scriptFile));
- contextMenu.appendSeparator();
+ return WebInspector.UISourceCodeFrame.prototype.populateTextAreaContextMenu.call(this, contextMenu, lineNumber, columnNumber).then((function() {
+ if (this._uiSourceCode.project().type() === WebInspector.projectTypes.Network && WebInspector.moduleSetting("jsSourceMapsEnabled").get()) {
+ if (this._scriptFileForTarget.size) {
+ var scriptFile = this._scriptFileForTarget.valuesArray()[0];
+ var addSourceMapURLLabel = WebInspector.UIString.capitalize("Add ^source ^map\u2026");
+ contextMenu.appendItem(addSourceMapURLLabel, addSourceMapURL.bind(this, scriptFile));
+ contextMenu.appendSeparator();
+ }
}
- }
+ }).bind(this));
},
_workingCopyChanged: function(event)
@@ -394,7 +405,8 @@ WebInspector.JavaScriptSourceFrame.prototype = {
var compileError = errorData.compileError;
if (compileError) {
var messageText = WebInspector.UIString("LiveEdit compile failed: %s", compileError.message);
- var message = new WebInspector.SourceFrameMessage(messageText, WebInspector.SourceFrameMessage.Level.Error, compileError.lineNumber - 1, compileError.columnNumber + 1);
+ var location = {line: compileError.lineNumber - 1, column: compileError.columnNumber + 1};
+ var message = new WebInspector.SourceFrameMessage(messageText, WebInspector.SourceFrameMessage.Level.Error, location, location);
this.addMessageToSource(message);
} else {
WebInspector.console.addMessage(WebInspector.UIString("Unknown LiveEdit error: %s; %s", JSON.stringify(errorData), error), warningLevel);
« no previous file with comments | « Source/devtools/front_end/sources/JavaScriptCompiler.js ('k') | Source/devtools/front_end/sources/SourcesPanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698