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

Side by Side Diff: Source/devtools/front_end/sdk/ResourceScriptMapping.js

Issue 373743003: DevTools: Add support for adding source map to a script from the DevTools window. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebaselined Created 6 years, 5 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 | Annotate | Revision Log
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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 214
215 dispose: function() 215 dispose: function()
216 { 216 {
217 this._debuggerReset(); 217 this._debuggerReset();
218 this._workspace.removeEventListener(WebInspector.Workspace.Events.UISour ceCodeAdded, this._uiSourceCodeAddedToWorkspace, this); 218 this._workspace.removeEventListener(WebInspector.Workspace.Events.UISour ceCodeAdded, this._uiSourceCodeAddedToWorkspace, this);
219 } 219 }
220 220
221 } 221 }
222 222
223 /** 223 /**
224 * @interface
225 * @extends {WebInspector.EventTarget}
226 */
227 WebInspector.ScriptFile = function()
228 {
229 }
230
231 WebInspector.ScriptFile.Events = {
232 DidMergeToVM: "DidMergeToVM",
233 DidDivergeFromVM: "DidDivergeFromVM",
234 }
235
236 WebInspector.ScriptFile.prototype = {
237 /**
238 * @return {boolean}
239 */
240 hasDivergedFromVM: function() { return false; },
241
242 /**
243 * @return {boolean}
244 */
245 isDivergingFromVM: function() { return false; },
246
247 /**
248 * @return {boolean}
249 */
250 isMergingToVM: function() { return false; },
251
252 checkMapping: function() { },
253
254 /**
255 * @return {?WebInspector.Target}
256 */
257 target: function() { return null; },
258 }
259
260 /**
261 * @constructor 224 * @constructor
262 * @implements {WebInspector.ScriptFile}
263 * @extends {WebInspector.Object} 225 * @extends {WebInspector.Object}
264 * @param {!WebInspector.ResourceScriptMapping} resourceScriptMapping 226 * @param {!WebInspector.ResourceScriptMapping} resourceScriptMapping
265 * @param {!WebInspector.UISourceCode} uiSourceCode 227 * @param {!WebInspector.UISourceCode} uiSourceCode
266 * @param {!Array.<!WebInspector.Script>} scripts 228 * @param {!Array.<!WebInspector.Script>} scripts
267 */ 229 */
268 WebInspector.ResourceScriptFile = function(resourceScriptMapping, uiSourceCode, scripts) 230 WebInspector.ResourceScriptFile = function(resourceScriptMapping, uiSourceCode, scripts)
269 { 231 {
270 console.assert(scripts.length); 232 console.assert(scripts.length);
271 233
272 WebInspector.ScriptFile.call(this);
273 this._resourceScriptMapping = resourceScriptMapping; 234 this._resourceScriptMapping = resourceScriptMapping;
274 this._uiSourceCode = uiSourceCode; 235 this._uiSourceCode = uiSourceCode;
275 236
276 if (this._uiSourceCode.contentType() === WebInspector.resourceTypes.Script) 237 if (this._uiSourceCode.contentType() === WebInspector.resourceTypes.Script)
277 this._script = scripts[0]; 238 this._script = scripts[0];
278 239
279 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyChanged, this._workingCopyChanged, this); 240 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyChanged, this._workingCopyChanged, this);
280 this._update(); 241 this._update();
281 } 242 }
282 243
244 WebInspector.ResourceScriptFile.Events = {
245 DidMergeToVM: "DidMergeToVM",
246 DidDivergeFromVM: "DidDivergeFromVM",
247 }
248
283 WebInspector.ResourceScriptFile.prototype = { 249 WebInspector.ResourceScriptFile.prototype = {
284 /** 250 /**
285 * @param {function(?string,!DebuggerAgent.SetScriptSourceError=,!WebInspect or.Script=)=} callback 251 * @param {function(?string,!DebuggerAgent.SetScriptSourceError=,!WebInspect or.Script=)=} callback
286 */ 252 */
287 commitLiveEdit: function(callback) 253 commitLiveEdit: function(callback)
288 { 254 {
289 var target = this._resourceScriptMapping._target; 255 var target = this._resourceScriptMapping._target;
290 /** 256 /**
291 * @param {?string} error 257 * @param {?string} error
292 * @param {!DebuggerAgent.SetScriptSourceError=} errorData 258 * @param {!DebuggerAgent.SetScriptSourceError=} errorData
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 else if (!this._isDiverged() && this._hasDivergedFromVM) 304 else if (!this._isDiverged() && this._hasDivergedFromVM)
339 this._mergeToVM(); 305 this._mergeToVM();
340 }, 306 },
341 307
342 _divergeFromVM: function() 308 _divergeFromVM: function()
343 { 309 {
344 this._isDivergingFromVM = true; 310 this._isDivergingFromVM = true;
345 this._resourceScriptMapping._hasDivergedFromVM(this._uiSourceCode); 311 this._resourceScriptMapping._hasDivergedFromVM(this._uiSourceCode);
346 delete this._isDivergingFromVM; 312 delete this._isDivergingFromVM;
347 this._hasDivergedFromVM = true; 313 this._hasDivergedFromVM = true;
348 this.dispatchEventToListeners(WebInspector.ScriptFile.Events.DidDivergeF romVM, this._uiSourceCode); 314 this.dispatchEventToListeners(WebInspector.ResourceScriptFile.Events.Did DivergeFromVM, this._uiSourceCode);
349 }, 315 },
350 316
351 _mergeToVM: function() 317 _mergeToVM: function()
352 { 318 {
353 delete this._hasDivergedFromVM; 319 delete this._hasDivergedFromVM;
354 this._isMergingToVM = true; 320 this._isMergingToVM = true;
355 this._resourceScriptMapping._hasMergedToVM(this._uiSourceCode); 321 this._resourceScriptMapping._hasMergedToVM(this._uiSourceCode);
356 delete this._isMergingToVM; 322 delete this._isMergingToVM;
357 this.dispatchEventToListeners(WebInspector.ScriptFile.Events.DidMergeToV M, this._uiSourceCode); 323 this.dispatchEventToListeners(WebInspector.ResourceScriptFile.Events.Did MergeToVM, this._uiSourceCode);
358 }, 324 },
359 325
360 /** 326 /**
361 * @return {boolean} 327 * @return {boolean}
362 */ 328 */
363 hasDivergedFromVM: function() 329 hasDivergedFromVM: function()
364 { 330 {
365 return this._hasDivergedFromVM; 331 return this._hasDivergedFromVM;
366 }, 332 },
367 333
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 if (!this._script) 374 if (!this._script)
409 return null; 375 return null;
410 return this._script.target(); 376 return this._script.target();
411 }, 377 },
412 378
413 dispose: function() 379 dispose: function()
414 { 380 {
415 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyChanged, this._workingCopyChanged, this); 381 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyChanged, this._workingCopyChanged, this);
416 }, 382 },
417 383
384 /**
385 * @param {string} sourceMapURL
386 */
387 addSourceMapURL: function(sourceMapURL)
388 {
389 if (!this._script)
390 return;
391 this._script.addSourceMapURL(sourceMapURL);
392 },
393
418 __proto__: WebInspector.Object.prototype 394 __proto__: WebInspector.Object.prototype
419 } 395 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/sdk/CompilerScriptMapping.js ('k') | Source/devtools/front_end/sdk/Script.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698