Changeset 58477 in webkit


Ignore:
Timestamp:
Apr 28, 2010 11:10:03 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-28 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: Allow editing script resources when resource tracking is enabled.

https://bugs.webkit.org/show_bug.cgi?id=38269

  • inspector/front-end/ScriptView.js:
  • inspector/front-end/ScriptsPanel.js: (WebInspector.ScriptsPanel.prototype.canEditScripts): (WebInspector.ScriptsPanel.prototype.editScriptSource):
  • inspector/front-end/SourceFrame.js: (WebInspector.SourceFrame.prototype.get textModel):
  • inspector/front-end/SourceView.js: (WebInspector.SourceView): (WebInspector.SourceView.prototype._addBreakpoint): (WebInspector.SourceView.prototype._editLine): (WebInspector.SourceView.prototype._editLineComplete): (WebInspector.SourceView.prototype._sourceIDForLine):

2010-04-28 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: Allow editing script resources when resource tracking is enabled.

http://bugs.webkit.org/show_bug.cgi?id=38269

  • src/js/DebuggerAgent.js:
  • src/js/InspectorControllerImpl.js: (.devtools.InspectorBackendImpl.prototype.setBreakpoint): (.devtools.InspectorBackendImpl.prototype.editScriptSource):
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r58476 r58477  
     12010-04-28  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: Allow editing script resources when resource tracking is enabled.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=38269
     8
     9        * inspector/front-end/ScriptView.js:
     10        * inspector/front-end/ScriptsPanel.js:
     11        (WebInspector.ScriptsPanel.prototype.canEditScripts):
     12        (WebInspector.ScriptsPanel.prototype.editScriptSource):
     13        * inspector/front-end/SourceFrame.js:
     14        (WebInspector.SourceFrame.prototype.get textModel):
     15        * inspector/front-end/SourceView.js:
     16        (WebInspector.SourceView):
     17        (WebInspector.SourceView.prototype._addBreakpoint):
     18        (WebInspector.SourceView.prototype._editLine):
     19        (WebInspector.SourceView.prototype._editLineComplete):
     20        (WebInspector.SourceView.prototype._sourceIDForLine):
     21
    1222010-04-25  Antonio Gomes  <tonikitoo@webkit.org>
    223
  • trunk/WebCore/inspector/front-end/ScriptView.js

    r57909 r58477  
    7878    },
    7979
    80     _editLine: function(line, newContent)
    81     {
    82         WebInspector.panels.scripts.editScriptLine(this.script.sourceID, line, newContent, this._editLineComplete.bind(this));
    83     },
    84 
    8580    _editLineComplete: function(newBody)
    8681    {
     
    108103    _sourceFrameSetupFinished: WebInspector.SourceView.prototype._sourceFrameSetupFinished,
    109104    _removeBreakpoint: WebInspector.SourceView.prototype._removeBreakpoint,
     105    _editLine: WebInspector.SourceView.prototype._editLine,
    110106    resize: WebInspector.SourceView.prototype.resize
    111107}
  • trunk/WebCore/inspector/front-end/ScriptsPanel.js

    r58252 r58477  
    360360    canEditScripts: function()
    361361    {
    362         return !!InspectorBackend.editScriptLine;
    363     },
    364 
    365     editScriptLine: function(sourceID, line, newContent, callback)
     362        return !!InspectorBackend.editScriptSource;
     363    },
     364
     365    editScriptSource: function(sourceID, newContent, line, linesCountToShift, callback)
    366366    {
    367367        if (!this.canEditScripts())
     
    377377        }
    378378
    379         var linesCountToShift = newContent.split("\n").length - 1;
    380379        function mycallback(newBody)
    381380        {
     
    389388        };
    390389        var callbackId = WebInspector.Callback.wrap(mycallback.bind(this))
    391         InspectorBackend.editScriptLine(callbackId, sourceID, line, newContent);
     390        InspectorBackend.editScriptSource(callbackId, sourceID, newContent);
    392391    },
    393392
     
    10051004WebInspector.ScriptsPanel.prototype.__proto__ = WebInspector.Panel.prototype;
    10061005
    1007 WebInspector.didEditScriptLine = WebInspector.Callback.processCallback;
     1006WebInspector.didEditScriptSource = WebInspector.Callback.processCallback;
  • trunk/WebCore/inspector/front-end/SourceFrame.js

    r58252 r58477  
    153153    },
    154154
     155    get textModel()
     156    {
     157        return this._textModel;
     158    },
     159
    155160    highlightLine: function(line)
    156161    {
  • trunk/WebCore/inspector/front-end/SourceView.js

    r56444 r58477  
    3333    this.element.addStyleClass("source");
    3434
    35     this.sourceFrame = new WebInspector.SourceFrame(this.contentElement, this._addBreakpoint.bind(this), this._removeBreakpoint.bind(this));
     35    var canEditScripts = WebInspector.panels.scripts.canEditScripts() && resource.type === WebInspector.Resource.Type.Script;
     36    this.sourceFrame = new WebInspector.SourceFrame(this.contentElement, this._addBreakpoint.bind(this), this._removeBreakpoint.bind(this), canEditScripts ? this._editLine.bind(this) : null);
    3637    resource.addEventListener("finished", this._resourceLoadingFinished, this);
    3738    this._frameNeedsSetup = true;
     
    105106
    106107    _addBreakpoint: function(line)
     108    {
     109        var sourceID = this._sourceIDForLine(line);
     110        if (WebInspector.panels.scripts) {
     111            var breakpoint = new WebInspector.Breakpoint(this.resource.url, line, sourceID);
     112            WebInspector.panels.scripts.addBreakpoint(breakpoint);
     113        }
     114    },
     115
     116    _removeBreakpoint: function(breakpoint)
     117    {
     118        if (WebInspector.panels.scripts)
     119            WebInspector.panels.scripts.removeBreakpoint(breakpoint);
     120    },
     121
     122    _editLine: function(line, newContent)
     123    {
     124        var lines = [];
     125        var textModel = this.sourceFrame.textModel;
     126        for (var i = 0; i < textModel.linesCount; ++i) {
     127            if (i === line)
     128                lines.push(newContent);
     129            else
     130                lines.push(textModel.line(i));
     131        }
     132
     133        var linesCountToShift = newContent.split("\n").length - 1;
     134        WebInspector.panels.scripts.editScriptSource(this._sourceIDForLine(line), lines.join("\n"), line, linesCountToShift, this._editLineComplete.bind(this));
     135    },
     136
     137    _editLineComplete: function(newBody)
     138    {
     139        this.sourceFrame.updateContent(newBody);
     140    },
     141
     142    _sourceIDForLine: function(line)
    107143    {
    108144        var sourceID = null;
     
    116152            }
    117153        }
    118 
    119         if (WebInspector.panels.scripts) {
    120             var breakpoint = new WebInspector.Breakpoint(this.resource.url, line, sourceID);
    121             WebInspector.panels.scripts.addBreakpoint(breakpoint);
    122         }
    123     },
    124 
    125     _removeBreakpoint: function(breakpoint)
    126     {
    127         if (WebInspector.panels.scripts)
    128             WebInspector.panels.scripts.removeBreakpoint(breakpoint);
     154        return sourceID;
    129155    },
    130156
  • trunk/WebKit/chromium/ChangeLog

    r58425 r58477  
     12010-04-28  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: Allow editing script resources when resource tracking is enabled.
     6
     7        http://bugs.webkit.org/show_bug.cgi?id=38269
     8 
     9        * src/js/DebuggerAgent.js:
     10        * src/js/InspectorControllerImpl.js:
     11        (.devtools.InspectorBackendImpl.prototype.setBreakpoint):
     12        (.devtools.InspectorBackendImpl.prototype.editScriptSource):
     13
    1142010-04-28  Darin Fisher  <darin@chromium.org>
    215
  • trunk/WebKit/chromium/src/js/DebuggerAgent.js

    r58312 r58477  
    310310 * Changes given line of the script.
    311311 */
    312 devtools.DebuggerAgent.prototype.editScriptLine = function(sourceId, line, newContent, callback)
    313 {
    314     var script = this.parsedScripts_[sourceId];
    315     if (!script || !script.source)
    316         return;
    317 
    318     var lines = script.source.split("\n");
    319     lines[line] = newContent;
    320 
     312devtools.DebuggerAgent.prototype.editScriptSource = function(sourceId, newContent, callback)
     313{
    321314    var commandArguments = {
    322315        "script_id": sourceId,
    323         "new_source": lines.join("\n")
     316        "new_source": newContent
    324317    };
    325318
  • trunk/WebKit/chromium/src/js/InspectorControllerImpl.js

    r58413 r58477  
    139139
    140140
    141 devtools.InspectorBackendImpl.prototype.editScriptLine = function(callID, sourceID, line, newContent)
    142 {
    143     devtools.tools.getDebuggerAgent().editScriptLine(sourceID, line, newContent, function(newFullBody) {
    144         WebInspector.didEditScriptLine(callID, newFullBody);
     141devtools.InspectorBackendImpl.prototype.editScriptSource = function(callID, sourceID, newContent)
     142{
     143    devtools.tools.getDebuggerAgent().editScriptSource(sourceID, newContent, function(newFullBody) {
     144        WebInspector.didEditScriptSource(callID, newFullBody);
    145145    });
    146146};
Note: See TracChangeset for help on using the changeset viewer.