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

Side by Side 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, 3 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 254
255 onTextChanged: function(oldRange, newRange) 255 onTextChanged: function(oldRange, newRange)
256 { 256 {
257 this._scriptsPanel.setIgnoreExecutionLineEvents(true); 257 this._scriptsPanel.setIgnoreExecutionLineEvents(true);
258 WebInspector.UISourceCodeFrame.prototype.onTextChanged.call(this, oldRan ge, newRange); 258 WebInspector.UISourceCodeFrame.prototype.onTextChanged.call(this, oldRan ge, newRange);
259 this._scriptsPanel.setIgnoreExecutionLineEvents(false); 259 this._scriptsPanel.setIgnoreExecutionLineEvents(false);
260 if (this._compiler) 260 if (this._compiler)
261 this._compiler.scheduleCompile(); 261 this._compiler.scheduleCompile();
262 }, 262 },
263 263
264 /**
265 * @override
266 * @return {!Promise}
267 */
264 populateLineGutterContextMenu: function(contextMenu, lineNumber) 268 populateLineGutterContextMenu: function(contextMenu, lineNumber)
265 { 269 {
266 var uiLocation = new WebInspector.UILocation(this._uiSourceCode, lineNum ber, 0); 270 return new Promise((function(resolve, reject) {
267 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation); 271 var uiLocation = new WebInspector.UILocation(this._uiSourceCode, lin eNumber, 0);
268 var breakpoint = this._breakpointManager.findBreakpointOnLine(this._uiSo urceCode, lineNumber); 272 this._scriptsPanel.appendUILocationItems(contextMenu, uiLocation);
269 if (!breakpoint) { 273 var breakpoint = this._breakpointManager.findBreakpointOnLine(this._ uiSourceCode, lineNumber);
270 // This row doesn't have a breakpoint: We want to show Add Breakpoin t and Add and Edit Breakpoint. 274 if (!breakpoint) {
271 contextMenu.appendItem(WebInspector.UIString.capitalize("Add ^breakp oint"), this._createNewBreakpoint.bind(this, lineNumber, 0, "", true)); 275 // This row doesn't have a breakpoint: We want to show Add Break point and Add and Edit Breakpoint.
272 contextMenu.appendItem(WebInspector.UIString.capitalize("Add ^condit ional ^breakpoint…"), this._editBreakpointCondition.bind(this, lineNumber)); 276 contextMenu.appendItem(WebInspector.UIString.capitalize("Add ^br eakpoint"), this._createNewBreakpoint.bind(this, lineNumber, 0, "", true));
273 } else { 277 contextMenu.appendItem(WebInspector.UIString.capitalize("Add ^co nditional ^breakpoint…"), this._editBreakpointCondition.bind(this, lineNumber));
274 // This row has a breakpoint, we want to show edit and remove breakp oint, and either disable or enable. 278 } else {
275 contextMenu.appendItem(WebInspector.UIString.capitalize("Remove ^bre akpoint"), breakpoint.remove.bind(breakpoint)); 279 // This row has a breakpoint, we want to show edit and remove br eakpoint, and either disable or enable.
276 contextMenu.appendItem(WebInspector.UIString.capitalize("Edit ^break point…"), this._editBreakpointCondition.bind(this, lineNumber, breakpoint)); 280 contextMenu.appendItem(WebInspector.UIString.capitalize("Remove ^breakpoint"), breakpoint.remove.bind(breakpoint));
277 if (breakpoint.enabled()) 281 contextMenu.appendItem(WebInspector.UIString.capitalize("Edit ^b reakpoint…"), this._editBreakpointCondition.bind(this, lineNumber, breakpoint));
278 contextMenu.appendItem(WebInspector.UIString.capitalize("Disable ^breakpoint"), breakpoint.setEnabled.bind(breakpoint, false)); 282 if (breakpoint.enabled())
279 else 283 contextMenu.appendItem(WebInspector.UIString.capitalize("Dis able ^breakpoint"), breakpoint.setEnabled.bind(breakpoint, false));
280 contextMenu.appendItem(WebInspector.UIString.capitalize("Enable ^breakpoint"), breakpoint.setEnabled.bind(breakpoint, true)); 284 else
281 } 285 contextMenu.appendItem(WebInspector.UIString.capitalize("Ena ble ^breakpoint"), breakpoint.setEnabled.bind(breakpoint, true));
286 }
287 resolve();
288 }).bind(this));
282 }, 289 },
283 290
291 /**
292 * @override
293 * @return {!Promise}
294 */
284 populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber) 295 populateTextAreaContextMenu: function(contextMenu, lineNumber, columnNumber)
285 { 296 {
286 var textSelection = this.textEditor.selection(); 297 var textSelection = this.textEditor.selection();
287 if (textSelection && !textSelection.isEmpty()) { 298 if (textSelection && !textSelection.isEmpty()) {
288 var selection = this.textEditor.copyRange(textSelection); 299 var selection = this.textEditor.copyRange(textSelection);
289 var addToWatchLabel = WebInspector.UIString.capitalize("Add to ^watc h"); 300 var addToWatchLabel = WebInspector.UIString.capitalize("Add to ^watc h");
290 contextMenu.appendItem(addToWatchLabel, this._innerAddToWatch.bind(t his, selection)); 301 contextMenu.appendItem(addToWatchLabel, this._innerAddToWatch.bind(t his, selection));
291 var evaluateLabel = WebInspector.UIString.capitalize("Evaluate in ^c onsole"); 302 var evaluateLabel = WebInspector.UIString.capitalize("Evaluate in ^c onsole");
292 contextMenu.appendItem(evaluateLabel, this._evaluateInConsole.bind(t his, selection)); 303 contextMenu.appendItem(evaluateLabel, this._evaluateInConsole.bind(t his, selection));
293 contextMenu.appendSeparator(); 304 contextMenu.appendSeparator();
(...skipping 12 matching lines...) Expand all
306 * @param {!WebInspector.ResourceScriptFile} scriptFile 317 * @param {!WebInspector.ResourceScriptFile} scriptFile
307 * @param {string} url 318 * @param {string} url
308 */ 319 */
309 function addSourceMapURLDialogCallback(scriptFile, url) 320 function addSourceMapURLDialogCallback(scriptFile, url)
310 { 321 {
311 if (!url) 322 if (!url)
312 return; 323 return;
313 scriptFile.addSourceMapURL(url); 324 scriptFile.addSourceMapURL(url);
314 } 325 }
315 326
316 WebInspector.UISourceCodeFrame.prototype.populateTextAreaContextMenu.cal l(this, contextMenu, lineNumber, columnNumber); 327 return WebInspector.UISourceCodeFrame.prototype.populateTextAreaContextM enu.call(this, contextMenu, lineNumber, columnNumber).then((function() {
317 328 if (this._uiSourceCode.project().type() === WebInspector.projectType s.Network && WebInspector.moduleSetting("jsSourceMapsEnabled").get()) {
318 if (this._uiSourceCode.project().type() === WebInspector.projectTypes.Ne twork && WebInspector.moduleSetting("jsSourceMapsEnabled").get()) { 329 if (this._scriptFileForTarget.size) {
319 if (this._scriptFileForTarget.size) { 330 var scriptFile = this._scriptFileForTarget.valuesArray()[0];
320 var scriptFile = this._scriptFileForTarget.valuesArray()[0]; 331 var addSourceMapURLLabel = WebInspector.UIString.capitalize( "Add ^source ^map\u2026");
321 var addSourceMapURLLabel = WebInspector.UIString.capitalize("Add ^source ^map\u2026"); 332 contextMenu.appendItem(addSourceMapURLLabel, addSourceMapURL .bind(this, scriptFile));
322 contextMenu.appendItem(addSourceMapURLLabel, addSourceMapURL.bin d(this, scriptFile)); 333 contextMenu.appendSeparator();
323 contextMenu.appendSeparator(); 334 }
324 } 335 }
325 } 336 }).bind(this));
326 }, 337 },
327 338
328 _workingCopyChanged: function(event) 339 _workingCopyChanged: function(event)
329 { 340 {
330 if (this._supportsEnabledBreakpointsWhileEditing() || this._scriptFileFo rTarget.size) 341 if (this._supportsEnabledBreakpointsWhileEditing() || this._scriptFileFo rTarget.size)
331 return; 342 return;
332 343
333 if (this._uiSourceCode.isDirty()) 344 if (this._uiSourceCode.isDirty())
334 this._muteBreakpointsWhileEditing(); 345 this._muteBreakpointsWhileEditing();
335 else 346 else
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 { 398 {
388 var warningLevel = WebInspector.Console.MessageLevel.Warning; 399 var warningLevel = WebInspector.Console.MessageLevel.Warning;
389 if (!errorData) { 400 if (!errorData) {
390 if (error) 401 if (error)
391 WebInspector.console.addMessage(WebInspector.UIString("LiveE dit failed: %s", error), warningLevel); 402 WebInspector.console.addMessage(WebInspector.UIString("LiveE dit failed: %s", error), warningLevel);
392 return; 403 return;
393 } 404 }
394 var compileError = errorData.compileError; 405 var compileError = errorData.compileError;
395 if (compileError) { 406 if (compileError) {
396 var messageText = WebInspector.UIString("LiveEdit compile failed : %s", compileError.message); 407 var messageText = WebInspector.UIString("LiveEdit compile failed : %s", compileError.message);
397 var message = new WebInspector.SourceFrameMessage(messageText, W ebInspector.SourceFrameMessage.Level.Error, compileError.lineNumber - 1, compile Error.columnNumber + 1); 408 var location = {line: compileError.lineNumber - 1, column: compi leError.columnNumber + 1};
409 var message = new WebInspector.SourceFrameMessage(messageText, W ebInspector.SourceFrameMessage.Level.Error, location, location);
398 this.addMessageToSource(message); 410 this.addMessageToSource(message);
399 } else { 411 } else {
400 WebInspector.console.addMessage(WebInspector.UIString("Unknown L iveEdit error: %s; %s", JSON.stringify(errorData), error), warningLevel); 412 WebInspector.console.addMessage(WebInspector.UIString("Unknown L iveEdit error: %s; %s", JSON.stringify(errorData), error), warningLevel);
401 } 413 }
402 } 414 }
403 415
404 this._scriptsPanel.setIgnoreExecutionLineEvents(true); 416 this._scriptsPanel.setIgnoreExecutionLineEvents(true);
405 this._hasCommittedLiveEdit = true; 417 this._hasCommittedLiveEdit = true;
406 var scriptFiles = this._scriptFileForTarget.valuesArray(); 418 var scriptFiles = this._scriptFileForTarget.valuesArray();
407 for (var i = 0; i < scriptFiles.length; ++i) 419 for (var i = 0; i < scriptFiles.length; ++i)
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyChanged, this._workingCopyChanged, this); 1136 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyChanged, this._workingCopyChanged, this);
1125 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyCommitted, this._workingCopyCommitted, this); 1137 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyCommitted, this._workingCopyCommitted, this);
1126 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. TitleChanged, this._showBlackboxInfobarIfNeeded, this); 1138 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. TitleChanged, this._showBlackboxInfobarIfNeeded, this);
1127 WebInspector.moduleSetting("skipStackFramesPattern").removeChangeListene r(this._showBlackboxInfobarIfNeeded, this); 1139 WebInspector.moduleSetting("skipStackFramesPattern").removeChangeListene r(this._showBlackboxInfobarIfNeeded, this);
1128 WebInspector.moduleSetting("skipContentScripts").removeChangeListener(th is._showBlackboxInfobarIfNeeded, this); 1140 WebInspector.moduleSetting("skipContentScripts").removeChangeListener(th is._showBlackboxInfobarIfNeeded, this);
1129 WebInspector.UISourceCodeFrame.prototype.dispose.call(this); 1141 WebInspector.UISourceCodeFrame.prototype.dispose.call(this);
1130 }, 1142 },
1131 1143
1132 __proto__: WebInspector.UISourceCodeFrame.prototype 1144 __proto__: WebInspector.UISourceCodeFrame.prototype
1133 } 1145 }
OLDNEW
« 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