Changeset 73730 in webkit
- Timestamp:
- Dec 10, 2010 8:33:00 AM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r73729 r73730 1 2010-12-10 Pavel Podivilov <podivilov@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: eliminate SourceFrameDelegate by passing scripts to SourceFrame constructor. 6 https://bugs.webkit.org/show_bug.cgi?id=50679 7 8 * inspector/front-end/Script.js: 9 * inspector/front-end/ScriptView.js: 10 (WebInspector.ScriptView): 11 * inspector/front-end/ScriptsPanel.js: 12 (WebInspector.ScriptsPanel.prototype.reset): 13 * inspector/front-end/SourceFrame.js: 14 (WebInspector.SourceFrame): 15 (WebInspector.SourceFrame.prototype._createViewerIfNeeded): 16 (WebInspector.SourceFrame.prototype._breakpointAdded): 17 (WebInspector.SourceFrame.prototype._doEditLine): 18 (WebInspector.SourceFrame.prototype._commitEditLine): 19 (WebInspector.SourceFrame.prototype._breakpoints): 20 (WebInspector.SourceFrame.prototype._sourceIDForLine): 21 * inspector/front-end/SourceView.js: 22 (WebInspector.SourceView): 23 1 24 2010-12-10 Andreas Kling <kling@webkit.org> 2 25 -
trunk/WebCore/inspector/front-end/DebuggerModel.js
r73726 r73730 67 67 }, 68 68 69 findBreakpoints: function(filter)69 queryBreakpoints: function(filter) 70 70 { 71 71 var breakpoints = []; -
trunk/WebCore/inspector/front-end/Script.js
r73499 r73730 91 91 92 92 WebInspector.Script.prototype.__proto__ = WebInspector.Object.prototype; 93 -
trunk/WebCore/inspector/front-end/ScriptView.js
r73499 r73730 31 31 32 32 this.script = script; 33 this.script.addEventListener(WebInspector.Script.Events.SourceChanged, this._scriptSourceChanged, this); 33 34 34 35 this._frameNeedsSetup = true; 35 36 this._sourceFrameSetup = false; 36 var delegate = new WebInspector.ScriptFrameDelegateImpl(this.script); 37 this.sourceFrame = new WebInspector.SourceFrame(this.element, delegate); 38 39 this.script.addEventListener(WebInspector.Script.Events.SourceChanged, this._scriptSourceChanged, this); 37 this.sourceFrame = new WebInspector.SourceFrame(this.element, [script], WebInspector.panels.scripts.canEditScripts()); 40 38 } 41 39 … … 114 112 115 113 WebInspector.ScriptView.prototype.__proto__ = WebInspector.View.prototype; 116 117 WebInspector.ScriptFrameDelegateImpl = function(script)118 {119 WebInspector.SourceFrameDelegate.call(this);120 this._script = script;121 }122 123 WebInspector.ScriptFrameDelegateImpl.prototype = {124 canEditScripts: function()125 {126 return WebInspector.panels.scripts.canEditScripts();127 },128 129 editLineComplete: function(revertEditLineCallback, newContent)130 {131 this._script.source = newContent;132 },133 134 scripts: function()135 {136 return [this._script];137 }138 }139 140 WebInspector.ScriptFrameDelegateImpl.prototype.__proto__ = WebInspector.SourceFrameDelegate.prototype; -
trunk/WebCore/inspector/front-end/ScriptsPanel.js
r73501 r73730 294 294 295 295 // Need to clear breakpoints and re-create them later when editing source. 296 var breakpoints = WebInspector.debuggerModel. findBreakpoints(function(b) { return b.sourceID === editData.sourceID });296 var breakpoints = WebInspector.debuggerModel.queryBreakpoints(function(b) { return b.sourceID === editData.sourceID }); 297 297 for (var i = 0; i < breakpoints.length; ++i) 298 298 breakpoints[i].remove(); … … 434 434 for (var sourceID in this._sourceIDMap) { 435 435 var object = this._sourceIDMap[sourceID]; 436 if (object instanceof WebInspector.Resource) 436 if (object instanceof WebInspector.Resource) { 437 437 object.removeAllScripts(); 438 delete object._resourcesView; 439 } 438 440 } 439 441 } -
trunk/WebCore/inspector/front-end/SourceFrame.js
r73504 r73730 29 29 */ 30 30 31 WebInspector.SourceFrame = function(parentElement, delegate)31 WebInspector.SourceFrame = function(parentElement, scripts, canEditScripts) 32 32 { 33 33 this._parentElement = parentElement; 34 this._delegate = delegate; 34 this._scripts = {}; 35 for (var i = 0; i < scripts.length; ++i) 36 this._scripts[scripts[i].sourceID] = scripts[i]; 37 this._canEditScripts = canEditScripts; 35 38 36 39 this._textModel = new WebInspector.TextEditorModel(); … … 222 225 this._textViewer.endUpdates(); 223 226 224 if (this._ delegate.canEditScripts())227 if (this._canEditScripts) 225 228 this._textViewer.editCallback = this._editLine.bind(this); 226 229 }, … … 416 419 var breakpoint = event.data; 417 420 418 if ( this._shouldDisplayBreakpoint(breakpoint))421 if (breakpoint.sourceID in this._scripts) 419 422 this._addBreakpoint(breakpoint); 420 423 }, … … 798 801 { 799 802 var revertEditingCallback = this._revertEditLine.bind(this, editData); 800 var commitEditingCallback = this._ delegate.editLineComplete.bind(this._delegate, revertEditingCallback);803 var commitEditingCallback = this._commitEditLine.bind(this, editData, revertEditingCallback); 801 804 WebInspector.panels.scripts.editScriptSource(editData, commitEditingCallback, cancelEditingCallback); 805 }, 806 807 _commitEditLine: function(editData, revertEditLineCallback, newContent) 808 { 809 var script = this._scripts[editData.sourceID]; 810 script.source = newContent; 811 if (script.resource) 812 script.resource.setContent(newContent, revertEditLineCallback); 802 813 }, 803 814 … … 812 823 _breakpoints: function() 813 824 { 814 var sourceIDs = {}; 815 var scripts = this._delegate.scripts(); 816 for (var i = 0; i < scripts.length; ++i) 817 sourceIDs[scripts[i].sourceID] = true; 818 function filter(breakpoint) 819 { 820 return breakpoint.sourceID in sourceIDs; 821 } 822 return WebInspector.debuggerModel.findBreakpoints(filter); 825 var scripts = this._scripts; 826 return WebInspector.debuggerModel.queryBreakpoints(function(b) { return b.sourceID in scripts; }); 823 827 }, 824 828 … … 829 833 }, 830 834 831 _shouldDisplayBreakpoint: function(breakpoint)832 {833 var scripts = this._delegate.scripts();834 for (var i = 0; i < scripts.length; ++i) {835 if (breakpoint.sourceID === scripts[i].sourceID)836 return true;837 }838 return false;839 },840 841 835 _sourceIDForLine: function(lineNumber) 842 836 { 843 var sourceID = null; 844 var scripts = this._delegate.scripts(); 837 var sourceIDForLine = null; 845 838 var closestStartingLine = 0; 846 for (var i = 0; i < scripts.length; ++i) {847 var script = scripts[i];839 for (var sourceID in this._scripts) { 840 var script = this._scripts[sourceID]; 848 841 if (script.startingLine <= lineNumber && script.startingLine >= closestStartingLine) { 849 842 closestStartingLine = script.startingLine; 850 sourceID = script.sourceID;843 sourceIDForLine = sourceID; 851 844 } 852 845 } 853 return sourceID ;846 return sourceIDForLine; 854 847 } 855 848 } 856 849 857 850 WebInspector.SourceFrame.prototype.__proto__ = WebInspector.Object.prototype; 858 859 WebInspector.SourceFrameDelegate = function()860 {861 }862 863 WebInspector.SourceFrameDelegate.prototype = {864 canEditScripts: function()865 {866 // Implemented by subclasses.867 },868 869 editLineComplete: function(revertEditLineCallback, newContent)870 {871 // Implemented by subclasses.872 },873 874 scripts: function()875 {876 // Implemented by subclasses.877 }878 } -
trunk/WebCore/inspector/front-end/SourceView.js
r73499 r73730 33 33 this.element.addStyleClass("source"); 34 34 35 var delegate = new WebInspector.ResourceFrameDelegateImpl(this.resource);36 this.sourceFrame = new WebInspector.SourceFrame(this.element, delegate);35 var canEditScripts = WebInspector.panels.scripts.canEditScripts() && resource.type === WebInspector.Resource.Type.Script; 36 this.sourceFrame = new WebInspector.SourceFrame(this.element, resource.scripts, canEditScripts); 37 37 resource.addEventListener("finished", this._resourceLoadingFinished, this); 38 38 this._frameNeedsSetup = true; … … 239 239 240 240 WebInspector.SourceView.prototype.__proto__ = WebInspector.ResourceView.prototype; 241 242 WebInspector.ResourceFrameDelegateImpl = function(resource)243 {244 WebInspector.SourceFrameDelegate.call(this);245 this._resource = resource;246 }247 248 WebInspector.ResourceFrameDelegateImpl.prototype = {249 canEditScripts: function()250 {251 return WebInspector.panels.scripts.canEditScripts() && this._resource.type === WebInspector.Resource.Type.Script;252 },253 254 editLineComplete: function(revertEditLineCallback, newContent)255 {256 this._resource.setContent(newContent, revertEditLineCallback);257 },258 259 scripts: function()260 {261 return this._resource.scripts;262 }263 }264 265 WebInspector.ResourceFrameDelegateImpl.prototype.__proto__ = WebInspector.SourceFrameDelegate.prototype;
Note: See TracChangeset
for help on using the changeset viewer.