diff options
Diffstat (limited to 'WebCore/inspector/front-end/ScriptView.js')
-rw-r--r-- | WebCore/inspector/front-end/ScriptView.js | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/WebCore/inspector/front-end/ScriptView.js b/WebCore/inspector/front-end/ScriptView.js index c5a8b81..e55a685 100644 --- a/WebCore/inspector/front-end/ScriptView.js +++ b/WebCore/inspector/front-end/ScriptView.js @@ -33,7 +33,8 @@ WebInspector.ScriptView = function(script) this._frameNeedsSetup = true; this._sourceFrameSetup = false; - this.sourceFrame = new WebInspector.SourceFrame(this.element, this._addBreakpoint.bind(this), this._removeBreakpoint.bind(this)); + var canEditScripts = WebInspector.panels.scripts.canEditScripts(); + this.sourceFrame = new WebInspector.SourceFrame(this.element, this._addBreakpoint.bind(this), this._removeBreakpoint.bind(this), canEditScripts ? this._editLine.bind(this) : null); } WebInspector.ScriptView.prototype = { @@ -52,11 +53,18 @@ WebInspector.ScriptView.prototype = { this.attach(); - this.sourceFrame.setContent("text/javascript", this.script.source); + this.sourceFrame.setContent("text/javascript", this._prependWhitespace(this.script.source)); this._sourceFrameSetup = true; delete this._frameNeedsSetup; }, + _prependWhitespace: function(content) { + var prefix = ""; + for (var i = 0; i < this.script.startingLine - 1; ++i) + prefix += "\n"; + return prefix + content; + }, + attach: function() { if (!this.element.parentNode) @@ -69,6 +77,17 @@ WebInspector.ScriptView.prototype = { WebInspector.panels.scripts.addBreakpoint(breakpoint); }, + _editLine: function(line, newContent) + { + WebInspector.panels.scripts.editScriptLine(this.script.sourceID, line, newContent, this._editLineComplete.bind(this)); + }, + + _editLineComplete: function(newBody) + { + this.script.source = newBody; + this.sourceFrame.updateContent(this._prependWhitespace(newBody)); + }, + // The follow methods are pulled from SourceView, since they are // generic and work with ScriptView just fine. |