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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/snippets/ScriptSnippetModel.js

Issue 2173233002: [DevTools] Better locations for snippets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added a test Created 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 * @param {!RuntimeAgent.ScriptId=} scriptId 233 * @param {!RuntimeAgent.ScriptId=} scriptId
234 * @param {?RuntimeAgent.ExceptionDetails=} exceptionDetails 234 * @param {?RuntimeAgent.ExceptionDetails=} exceptionDetails
235 * @this {WebInspector.ScriptSnippetModel} 235 * @this {WebInspector.ScriptSnippetModel}
236 */ 236 */
237 function compileCallback(scriptId, exceptionDetails) 237 function compileCallback(scriptId, exceptionDetails)
238 { 238 {
239 var mapping = this._mappingForTarget.get(target); 239 var mapping = this._mappingForTarget.get(target);
240 if (mapping.evaluationIndex(uiSourceCode) !== evaluationIndex) 240 if (mapping.evaluationIndex(uiSourceCode) !== evaluationIndex)
241 return; 241 return;
242 242
243 mapping._addScript(executionContext.debuggerModel.scriptForId(script Id || exceptionDetails.scriptId), uiSourceCode);
243 if (!scriptId) { 244 if (!scriptId) {
244 this._printRunOrCompileScriptResultFailure(target, exceptionDeta ils, evaluationUrl); 245 this._printRunOrCompileScriptResultFailure(target, exceptionDeta ils, evaluationUrl);
245 return; 246 return;
246 } 247 }
247 248
248 mapping._addScript(executionContext.debuggerModel.scriptForId(script Id), uiSourceCode);
249 var breakpointLocations = this._removeBreakpoints(uiSourceCode); 249 var breakpointLocations = this._removeBreakpoints(uiSourceCode);
250 this._restoreBreakpoints(uiSourceCode, breakpointLocations); 250 this._restoreBreakpoints(uiSourceCode, breakpointLocations);
251 251
252 this._runScript(scriptId, executionContext, evaluationUrl); 252 this._runScript(scriptId, executionContext, evaluationUrl);
253 } 253 }
254 }, 254 },
255 255
256 /** 256 /**
257 * @param {!RuntimeAgent.ScriptId} scriptId 257 * @param {!RuntimeAgent.ScriptId} scriptId
258 * @param {!WebInspector.ExecutionContext} executionContext 258 * @param {!WebInspector.ExecutionContext} executionContext
259 * @param {?string=} sourceURL 259 * @param {?string=} sourceURL
260 */ 260 */
261 _runScript: function(scriptId, executionContext, sourceURL) 261 _runScript: function(scriptId, executionContext, sourceURL)
262 { 262 {
263 var target = executionContext.target(); 263 var target = executionContext.target();
264 target.runtimeModel.runScript(scriptId, executionContext.id, "console", false, true, runCallback.bind(this, target)); 264 target.runtimeModel.runScript(scriptId, executionContext.id, "console", false, true, runCallback.bind(this, target));
265 265
266 /** 266 /**
267 * @param {!WebInspector.Target} target 267 * @param {!WebInspector.Target} target
268 * @param {?RuntimeAgent.RemoteObject} result 268 * @param {?RuntimeAgent.RemoteObject} result
269 * @param {?RuntimeAgent.ExceptionDetails=} exceptionDetails 269 * @param {?RuntimeAgent.ExceptionDetails=} exceptionDetails
270 * @this {WebInspector.ScriptSnippetModel} 270 * @this {WebInspector.ScriptSnippetModel}
271 */ 271 */
272 function runCallback(target, result, exceptionDetails) 272 function runCallback(target, result, exceptionDetails)
273 { 273 {
274 if (!exceptionDetails) 274 if (!exceptionDetails)
275 this._printRunScriptResult(target, result, sourceURL); 275 this._printRunScriptResult(target, result, scriptId, sourceURL);
276 else 276 else
277 this._printRunOrCompileScriptResultFailure(target, exceptionDeta ils, sourceURL); 277 this._printRunOrCompileScriptResultFailure(target, exceptionDeta ils, sourceURL);
278 } 278 }
279 }, 279 },
280 280
281 /** 281 /**
282 * @param {!WebInspector.Target} target 282 * @param {!WebInspector.Target} target
283 * @param {?RuntimeAgent.RemoteObject} result 283 * @param {?RuntimeAgent.RemoteObject} result
284 * @param {!RuntimeAgent.ScriptId} scriptId
284 * @param {?string=} sourceURL 285 * @param {?string=} sourceURL
285 */ 286 */
286 _printRunScriptResult: function(target, result, sourceURL) 287 _printRunScriptResult: function(target, result, scriptId, sourceURL)
287 { 288 {
288 var consoleMessage = new WebInspector.ConsoleMessage( 289 var consoleMessage = new WebInspector.ConsoleMessage(
289 target, 290 target,
290 WebInspector.ConsoleMessage.MessageSource.JS, 291 WebInspector.ConsoleMessage.MessageSource.JS,
291 WebInspector.ConsoleMessage.MessageLevel.Log, 292 WebInspector.ConsoleMessage.MessageLevel.Log,
292 "", 293 "",
293 undefined, 294 undefined,
294 sourceURL, 295 sourceURL,
295 undefined, 296 undefined,
296 undefined, 297 undefined,
297 undefined, 298 undefined,
298 [result], 299 [result],
299 undefined); 300 undefined,
301 undefined,
302 undefined,
303 scriptId);
300 target.consoleModel.addMessage(consoleMessage); 304 target.consoleModel.addMessage(consoleMessage);
301 }, 305 },
302 306
303 /** 307 /**
304 * @param {!WebInspector.Target} target 308 * @param {!WebInspector.Target} target
305 * @param {?RuntimeAgent.ExceptionDetails=} exceptionDetails 309 * @param {?RuntimeAgent.ExceptionDetails=} exceptionDetails
306 * @param {?string=} sourceURL 310 * @param {?string=} sourceURL
307 */ 311 */
308 _printRunOrCompileScriptResultFailure: function(target, exceptionDetails, so urceURL) 312 _printRunOrCompileScriptResultFailure: function(target, exceptionDetails, so urceURL)
309 { 313 {
310 var consoleMessage = new WebInspector.ConsoleMessage( 314 var consoleMessage = new WebInspector.ConsoleMessage(
311 target, 315 target,
312 exceptionDetails.source, 316 exceptionDetails.source,
313 WebInspector.ConsoleMessage.MessageLevel.Error, 317 WebInspector.ConsoleMessage.MessageLevel.Error,
314 exceptionDetails.text, 318 exceptionDetails.text,
315 undefined, 319 undefined,
316 sourceURL, 320 sourceURL,
317 exceptionDetails.lineNumber, 321 exceptionDetails.lineNumber,
318 exceptionDetails.columnNumber, 322 exceptionDetails.columnNumber,
319 undefined, 323 undefined,
320 undefined, 324 undefined,
321 exceptionDetails.stackTrace); 325 exceptionDetails.stackTrace,
326 undefined,
327 undefined,
328 exceptionDetails.stackTrace ? undefined : exceptionDetails.scriptId) ;
322 target.consoleModel.addMessage(consoleMessage); 329 target.consoleModel.addMessage(consoleMessage);
323 }, 330 },
324 331
325 /** 332 /**
326 * @param {!WebInspector.UISourceCode} uiSourceCode 333 * @param {!WebInspector.UISourceCode} uiSourceCode
327 * @return {!Array.<!{breakpoint: !WebInspector.BreakpointManager.Breakpoint , uiLocation: !WebInspector.UILocation}>} 334 * @return {!Array.<!{breakpoint: !WebInspector.BreakpointManager.Breakpoint , uiLocation: !WebInspector.UILocation}>}
328 */ 335 */
329 _removeBreakpoints: function(uiSourceCode) 336 _removeBreakpoints: function(uiSourceCode)
330 { 337 {
331 var breakpointLocations = WebInspector.breakpointManager.breakpointLocat ionsForUISourceCode(uiSourceCode); 338 var breakpointLocations = WebInspector.breakpointManager.breakpointLocat ionsForUISourceCode(uiSourceCode);
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 this._model.deleteScriptSnippet(url); 675 this._model.deleteScriptSnippet(url);
669 }, 676 },
670 677
671 __proto__: WebInspector.ContentProviderBasedProject.prototype 678 __proto__: WebInspector.ContentProviderBasedProject.prototype
672 } 679 }
673 680
674 /** 681 /**
675 * @type {!WebInspector.ScriptSnippetModel} 682 * @type {!WebInspector.ScriptSnippetModel}
676 */ 683 */
677 WebInspector.scriptSnippetModel = new WebInspector.ScriptSnippetModel(WebInspect or.workspace); 684 WebInspector.scriptSnippetModel = new WebInspector.ScriptSnippetModel(WebInspect or.workspace);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698