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

Side by Side Diff: Source/devtools/front_end/sources/JavaScriptSourceFrame.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) 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even ts.BreakpointAdded, this._breakpointAdded, this); 54 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even ts.BreakpointAdded, this._breakpointAdded, this);
55 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even ts.BreakpointRemoved, this._breakpointRemoved, this); 55 this._breakpointManager.addEventListener(WebInspector.BreakpointManager.Even ts.BreakpointRemoved, this._breakpointRemoved, this);
56 56
57 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Console MessageAdded, this._consoleMessageAdded, this); 57 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Console MessageAdded, this._consoleMessageAdded, this);
58 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Console MessageRemoved, this._consoleMessageRemoved, this); 58 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Console MessageRemoved, this._consoleMessageRemoved, this);
59 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Console MessagesCleared, this._consoleMessagesCleared, this); 59 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Console MessagesCleared, this._consoleMessagesCleared, this);
60 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.SourceM appingChanged, this._onSourceMappingChanged, this); 60 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.SourceM appingChanged, this._onSourceMappingChanged, this);
61 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyChanged, this._workingCopyChanged, this); 61 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyChanged, this._workingCopyChanged, this);
62 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyCommitted, this._workingCopyCommitted, this); 62 this._uiSourceCode.addEventListener(WebInspector.UISourceCode.Events.Working CopyCommitted, this._workingCopyCommitted, this);
63 63
64 /** @type {!Map.<!WebInspector.Target, !WebInspector.ScriptFile>}*/ 64 /** @type {!Map.<!WebInspector.Target, !WebInspector.ResourceScriptFile>}*/
65 this._scriptFileForTarget = new Map(); 65 this._scriptFileForTarget = new Map();
66 this._registerShortcuts(); 66 this._registerShortcuts();
67 var targets = WebInspector.targetManager.targets(); 67 var targets = WebInspector.targetManager.targets();
68 for (var i = 0; i < targets.length; ++i) { 68 for (var i = 0; i < targets.length; ++i) {
69 var scriptFile = uiSourceCode.scriptFileForTarget(targets[i]); 69 var scriptFile = uiSourceCode.scriptFileForTarget(targets[i]);
70 if (scriptFile) 70 if (scriptFile)
71 this._updateScriptFile(targets[i]); 71 this._updateScriptFile(targets[i]);
72 } 72 }
73 } 73 }
74 74
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 /** 298 /**
299 * @this {WebInspector.JavaScriptSourceFrame} 299 * @this {WebInspector.JavaScriptSourceFrame}
300 * @param {!WebInspector.LiveEditSupport} liveEditSupport 300 * @param {!WebInspector.LiveEditSupport} liveEditSupport
301 */ 301 */
302 function liveEdit(liveEditSupport) 302 function liveEdit(liveEditSupport)
303 { 303 {
304 var liveEditUISourceCode = liveEditSupport.uiSourceCodeForLiveEdit(t his._uiSourceCode); 304 var liveEditUISourceCode = liveEditSupport.uiSourceCodeForLiveEdit(t his._uiSourceCode);
305 WebInspector.Revealer.reveal(liveEditUISourceCode.uiLocation(lineNum ber)); 305 WebInspector.Revealer.reveal(liveEditUISourceCode.uiLocation(lineNum ber));
306 } 306 }
307 307
308 /**
309 * @this {WebInspector.JavaScriptSourceFrame}
310 * @param {!WebInspector.ResourceScriptFile} scriptFile
311 */
312 function addSourceMapURL(scriptFile)
313 {
314 WebInspector.AddSourceMapURLDialog.show(this.element, addSourceMapUR LDialogCallback.bind(null, scriptFile));
315 }
316
317 /**
318 * @param {!WebInspector.ResourceScriptFile} scriptFile
319 * @param {string} url
320 */
321 function addSourceMapURLDialogCallback(scriptFile, url)
322 {
323 if (!url)
324 return;
325 scriptFile.addSourceMapURL(url);
326 }
327
308 WebInspector.UISourceCodeFrame.prototype.populateTextAreaContextMenu.cal l(this, contextMenu, lineNumber); 328 WebInspector.UISourceCodeFrame.prototype.populateTextAreaContextMenu.cal l(this, contextMenu, lineNumber);
329
330 if (this._uiSourceCode.project().type() === WebInspector.projectTypes.Ne twork && WebInspector.settings.jsSourceMapsEnabled.get()) {
331 if (this._scriptFileForTarget.size()) {
332 var scriptFile = this._scriptFileForTarget.values()[0];
333 var addSourceMapURLLabel = WebInspector.UIString(WebInspector.us eLowerCaseMenuTitles() ? "Add source map" : "Add Source Map");
334 contextMenu.appendItem(addSourceMapURLLabel, addSourceMapURL.bin d(this, scriptFile));
335 contextMenu.appendSeparator();
336 }
337 }
309 }, 338 },
310 339
311 _workingCopyChanged: function(event) 340 _workingCopyChanged: function(event)
312 { 341 {
313 if (this._supportsEnabledBreakpointsWhileEditing() || this._scriptFileFo rTarget.size()) 342 if (this._supportsEnabledBreakpointsWhileEditing() || this._scriptFileFo rTarget.size())
314 return; 343 return;
315 344
316 if (this._uiSourceCode.isDirty()) 345 if (this._uiSourceCode.isDirty())
317 this._muteBreakpointsWhileEditing(); 346 this._muteBreakpointsWhileEditing();
318 else 347 else
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 788
760 /** 789 /**
761 * @param {!WebInspector.Target} target 790 * @param {!WebInspector.Target} target
762 */ 791 */
763 _updateScriptFile: function(target) 792 _updateScriptFile: function(target)
764 { 793 {
765 var oldScriptFile = this._scriptFileForTarget.get(target); 794 var oldScriptFile = this._scriptFileForTarget.get(target);
766 var newScriptFile = this._uiSourceCode.scriptFileForTarget(target); 795 var newScriptFile = this._uiSourceCode.scriptFileForTarget(target);
767 this._scriptFileForTarget.remove(target); 796 this._scriptFileForTarget.remove(target);
768 if (oldScriptFile) { 797 if (oldScriptFile) {
769 oldScriptFile.removeEventListener(WebInspector.ScriptFile.Events.Did MergeToVM, this._didMergeToVM, this); 798 oldScriptFile.removeEventListener(WebInspector.ResourceScriptFile.Ev ents.DidMergeToVM, this._didMergeToVM, this);
770 oldScriptFile.removeEventListener(WebInspector.ScriptFile.Events.Did DivergeFromVM, this._didDivergeFromVM, this); 799 oldScriptFile.removeEventListener(WebInspector.ResourceScriptFile.Ev ents.DidDivergeFromVM, this._didDivergeFromVM, this);
771 if (this._muted && !this._uiSourceCode.isDirty()) 800 if (this._muted && !this._uiSourceCode.isDirty())
772 this._restoreBreakpointsIfConsistentScripts(); 801 this._restoreBreakpointsIfConsistentScripts();
773 } 802 }
774 if (newScriptFile) 803 if (newScriptFile)
775 this._scriptFileForTarget.put(target, newScriptFile); 804 this._scriptFileForTarget.put(target, newScriptFile);
776 805
777 delete this._hasCommittedLiveEdit; 806 delete this._hasCommittedLiveEdit;
778 this._updateDivergedInfobar(); 807 this._updateDivergedInfobar();
779 808
780 if (newScriptFile) { 809 if (newScriptFile) {
781 newScriptFile.addEventListener(WebInspector.ScriptFile.Events.DidMer geToVM, this._didMergeToVM, this); 810 newScriptFile.addEventListener(WebInspector.ResourceScriptFile.Event s.DidMergeToVM, this._didMergeToVM, this);
782 newScriptFile.addEventListener(WebInspector.ScriptFile.Events.DidDiv ergeFromVM, this._didDivergeFromVM, this); 811 newScriptFile.addEventListener(WebInspector.ResourceScriptFile.Event s.DidDivergeFromVM, this._didDivergeFromVM, this);
783 if (this.loaded) 812 if (this.loaded)
784 newScriptFile.checkMapping(); 813 newScriptFile.checkMapping();
785 } 814 }
786 }, 815 },
787 816
788 onTextEditorContentLoaded: function() 817 onTextEditorContentLoaded: function()
789 { 818 {
790 if (typeof this._executionLineNumber === "number") 819 if (typeof this._executionLineNumber === "number")
791 this.setExecutionLine(this._executionLineNumber); 820 this.setExecutionLine(this._executionLineNumber);
792 821
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. ConsoleMessageRemoved, this._consoleMessageRemoved, this); 920 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. ConsoleMessageRemoved, this._consoleMessageRemoved, this);
892 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. ConsoleMessagesCleared, this._consoleMessagesCleared, this); 921 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. ConsoleMessagesCleared, this._consoleMessagesCleared, this);
893 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. SourceMappingChanged, this._onSourceMappingChanged, this); 922 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. SourceMappingChanged, this._onSourceMappingChanged, this);
894 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyChanged, this._workingCopyChanged, this); 923 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyChanged, this._workingCopyChanged, this);
895 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyCommitted, this._workingCopyCommitted, this); 924 this._uiSourceCode.removeEventListener(WebInspector.UISourceCode.Events. WorkingCopyCommitted, this._workingCopyCommitted, this);
896 WebInspector.UISourceCodeFrame.prototype.dispose.call(this); 925 WebInspector.UISourceCodeFrame.prototype.dispose.call(this);
897 }, 926 },
898 927
899 __proto__: WebInspector.UISourceCodeFrame.prototype 928 __proto__: WebInspector.UISourceCodeFrame.prototype
900 } 929 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/sources/AddSourceMapURLDialog.js ('k') | Source/devtools/front_end/sources/SourcesPanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698