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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/ResourceScriptMapping.js

Issue 2349343002: DevTools: introduce persistence/ module (Closed)
Patch Set: reupload Created 4 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 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 * @param {!WebInspector.ResourceScriptMapping} resourceScriptMapping 279 * @param {!WebInspector.ResourceScriptMapping} resourceScriptMapping
280 * @param {!WebInspector.UISourceCode} uiSourceCode 280 * @param {!WebInspector.UISourceCode} uiSourceCode
281 * @param {!Array.<!WebInspector.Script>} scripts 281 * @param {!Array.<!WebInspector.Script>} scripts
282 */ 282 */
283 WebInspector.ResourceScriptFile = function(resourceScriptMapping, uiSourceCode, scripts) 283 WebInspector.ResourceScriptFile = function(resourceScriptMapping, uiSourceCode, scripts)
284 { 284 {
285 console.assert(scripts.length); 285 console.assert(scripts.length);
286 286
287 this._resourceScriptMapping = resourceScriptMapping; 287 this._resourceScriptMapping = resourceScriptMapping;
288 this._uiSourceCode = uiSourceCode; 288 this._uiSourceCode = uiSourceCode;
289 this._uiSourceCode.forceLoadOnCheckContent();
290 289
291 if (this._uiSourceCode.contentType().isScript()) 290 if (this._uiSourceCode.contentType().isScript())
292 this._script = scripts[0]; 291 this._script = scripts[0];
293 292
294 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyChanged, this._workingCopyChanged, this); 293 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyChanged, this._workingCopyChanged, this);
295 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyCommitted, this._workingCopyCommitted, this); 294 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyCommitted, this._workingCopyCommitted, this);
296 } 295 }
297 296
298 /** @enum {symbol} */ 297 /** @enum {symbol} */
299 WebInspector.ResourceScriptFile.Events = { 298 WebInspector.ResourceScriptFile.Events = {
(...skipping 18 matching lines...) Expand all
318 { 317 {
319 if (this._uiSourceCode.isDirty()) 318 if (this._uiSourceCode.isDirty())
320 return true; 319 return true;
321 if (!this._script) 320 if (!this._script)
322 return false; 321 return false;
323 if (typeof this._scriptSource === "undefined") 322 if (typeof this._scriptSource === "undefined")
324 return false; 323 return false;
325 var workingCopy = this._uiSourceCode.workingCopy(); 324 var workingCopy = this._uiSourceCode.workingCopy();
326 325
327 // Match ignoring sourceURL. 326 // Match ignoring sourceURL.
328 if (workingCopy.startsWith(this._scriptSource.trimRight())) { 327 if (!workingCopy.startsWith(this._scriptSource.trimRight()))
329 var suffix = this._uiSourceCode.workingCopy().substr(this._scriptSou rce.length); 328 return true;
330 return !!suffix.length && !suffix.match(WebInspector.Script.sourceUR LRegex); 329 var suffix = this._uiSourceCode.workingCopy().substr(this._scriptSource. length);
331 } 330 return !!suffix.length && !suffix.match(WebInspector.Script.sourceURLReg ex);
332
333 // Match ignoring Node wrapper.
334 var nodePrefix = "(function (exports, require, module, __filename, __dir name) { \n";
335 var nodeSuffix = "\n});";
336 if (workingCopy.startsWith("#!/usr/bin/env node\n"))
337 workingCopy = workingCopy.substring("#!/usr/bin/env node\n".length);
338 if (this._scriptSource === nodePrefix + workingCopy + nodeSuffix)
339 return false;
340 return true;
341 }, 331 },
342 332
343 /** 333 /**
344 * @param {!WebInspector.Event} event 334 * @param {!WebInspector.Event} event
345 */ 335 */
346 _workingCopyChanged: function(event) 336 _workingCopyChanged: function(event)
347 { 337 {
348 this._update(); 338 this._update();
349 }, 339 },
350 340
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 /** 471 /**
482 * @return {boolean} 472 * @return {boolean}
483 */ 473 */
484 hasSourceMapURL: function() 474 hasSourceMapURL: function()
485 { 475 {
486 return this._script && !!this._script.sourceMapURL; 476 return this._script && !!this._script.sourceMapURL;
487 }, 477 },
488 478
489 __proto__: WebInspector.Object.prototype 479 __proto__: WebInspector.Object.prototype
490 } 480 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698