Changeset 85320 in webkit


Ignore:
Timestamp:
Apr 29, 2011 6:06:01 AM (13 years ago)
Author:
podivilov@chromium.org
Message:

2011-04-28 Pavel Podivilov <podivilov@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: include script end line:column in scriptParsed parameters.
https://bugs.webkit.org/show_bug.cgi?id=59717

  • inspector/debugger/debugger-scripts-expected.txt:
  • inspector/debugger/debugger-scripts.html:

2011-04-28 Pavel Podivilov <podivilov@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: include script end line:column in scriptParsed parameters.
https://bugs.webkit.org/show_bug.cgi?id=59717

  • bindings/js/ScriptDebugServer.cpp: (WebCore::ScriptDebugServer::dispatchDidParseSource):
  • bindings/v8/DebuggerScript.js: ():
  • bindings/v8/ScriptDebugServer.cpp: (WebCore::ScriptDebugServer::dispatchDidParseSource):
  • inspector/Inspector.json:
  • inspector/InspectorDebuggerAgent.cpp: (WebCore::InspectorDebuggerAgent::resolveBreakpoint): (WebCore::InspectorDebuggerAgent::didParseSource):
  • inspector/InspectorDebuggerAgent.h: (WebCore::InspectorDebuggerAgent::Script::Script):
  • inspector/ScriptDebugListener.h:
  • inspector/front-end/DebuggerModel.js: (WebInspector.DebuggerModel.prototype._parsedScriptSource): (WebInspector.DebuggerModel.prototype._failedToParseScriptSource): (WebInspector.DebuggerDispatcher.prototype.scriptParsed):
  • inspector/front-end/Script.js: (WebInspector.Script):
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r85319 r85320  
     12011-04-28  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: include script end line:column in scriptParsed parameters.
     6        https://bugs.webkit.org/show_bug.cgi?id=59717
     7
     8        * inspector/debugger/debugger-scripts-expected.txt:
     9        * inspector/debugger/debugger-scripts.html:
     10
    1112011-04-28  Yury Semikhatsky  <yurys@chromium.org>
    212
  • trunk/LayoutTests/inspector/debugger/debugger-scripts-expected.txt

    r78535 r85320  
    33Debugger was enabled.
    44script 1:
    5     offset: 5:8
    6     length: 1041
     5    start: 5:8
     6    end: 37:2
    77script 2:
    8     offset: 38:21
    9     length: 50
     8    start: 38:21
     9    end: 43:24
     10script 3:
     11    start: 45:11
     12    end: 45:32
     13script 4:
     14    start: 46:11
     15    end: 46:28
     16script 5:
     17    start: 48:11
     18    end: 49:20
    1019Debugger was disabled.
    1120
  • trunk/LayoutTests/inspector/debugger/debugger-scripts.html

    r78535 r85320  
    2222            return;
    2323        scripts.push(script);
    24         if (scripts.length === 2)
     24        if (scripts.length === 5)
    2525            step3();
    2626    }
     
    3131        for (var i = 0; i < scripts.length; ++i) {
    3232            InspectorTest.addResult("script " + (i + 1) + ":");
    33             InspectorTest.addResult("    offset: " + scripts[i].lineOffset + ":" + scripts[i].columnOffset);
    34             InspectorTest.addResult("    length: " + scripts[i].length);
     33            InspectorTest.addResult("    start: " + scripts[i].lineOffset + ":" + scripts[i].columnOffset);
     34            InspectorTest.addResult("    end: " + scripts[i].endLine + ":" + scripts[i].endColumn);
    3535        }
    3636        InspectorTest.completeDebuggerTest();
     
    3838}
    3939</script>    <script>
    40 function doStuff()
     40function f1()
    4141{
    4242}
    4343
    44 window.onload = runTest;
     44window.onload = runTest;</script>
     45
     46   <script> function f2() {}    </script>
     47   <script>function f3() {}
     48</script>
     49   <script>
     50   function f4() {}
    4551</script>
    4652
  • trunk/Source/WebCore/ChangeLog

    r85319 r85320  
     12011-04-28  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: include script end line:column in scriptParsed parameters.
     6        https://bugs.webkit.org/show_bug.cgi?id=59717
     7
     8        * bindings/js/ScriptDebugServer.cpp:
     9        (WebCore::ScriptDebugServer::dispatchDidParseSource):
     10        * bindings/v8/DebuggerScript.js:
     11        ():
     12        * bindings/v8/ScriptDebugServer.cpp:
     13        (WebCore::ScriptDebugServer::dispatchDidParseSource):
     14        * inspector/Inspector.json:
     15        * inspector/InspectorDebuggerAgent.cpp:
     16        (WebCore::InspectorDebuggerAgent::resolveBreakpoint):
     17        (WebCore::InspectorDebuggerAgent::didParseSource):
     18        * inspector/InspectorDebuggerAgent.h:
     19        (WebCore::InspectorDebuggerAgent::Script::Script):
     20        * inspector/ScriptDebugListener.h:
     21        * inspector/front-end/DebuggerModel.js:
     22        (WebInspector.DebuggerModel.prototype._parsedScriptSource):
     23        (WebInspector.DebuggerModel.prototype._failedToParseScriptSource):
     24        (WebInspector.DebuggerDispatcher.prototype.scriptParsed):
     25        * inspector/front-end/Script.js:
     26        (WebInspector.Script):
     27
    1282011-04-28  Yury Semikhatsky  <yurys@chromium.org>
    229
  • trunk/Source/WebCore/bindings/js/ScriptDebugServer.cpp

    r85035 r85320  
    226226    int columnOffset = sourceProvider->startPosition().m_column.convertAsZeroBasedInt();
    227227
     228    int lineCount = 1;
     229    int lastLineStart = 0;
     230    for (size_t i = 0; i < data.length() - 1; ++i) {
     231        if (data[i] == '\n') {
     232            lineCount += 1;
     233            lastLineStart = i + 1;
     234        }
     235    }
     236
     237    int endLine = lineOffset + lineCount - 1;
     238    int endColumn;
     239    if (lineCount == 1)
     240        endColumn = data.length() + columnOffset;
     241    else
     242        endColumn = data.length() - lastLineStart;
     243
    228244    Vector<ScriptDebugListener*> copy;
    229245    copyToVector(listeners, copy);
    230246    for (size_t i = 0; i < copy.size(); ++i)
    231         copy[i]->didParseSource(sourceID, url, data, lineOffset, columnOffset, isContentScript);
     247        copy[i]->didParseSource(sourceID, url, data, lineOffset, columnOffset, endLine, endColumn, isContentScript);
    232248}
    233249
  • trunk/Source/WebCore/bindings/v8/DebuggerScript.js

    r83874 r85320  
    8787DebuggerScript._formatScript = function(script)
    8888{
     89    var lineEnds = script.line_ends;
     90    var lineCount = lineEnds.length;
     91    var endLine = script.line_offset + lineCount - 1;
     92    var endColumn;
     93    if (lineCount === 1)
     94        endColumn = script.source.length + script.column_offset;
     95    else
     96        endColumn = script.source.length - (script.line_ends[lineCount - 2] + 1);
     97
    8998    return {
    9099        id: script.id,
    91100        name: script.nameOrSourceURL(),
    92101        source: script.source,
    93         lineOffset: script.line_offset,
    94         columnOffset: script.column_offset,
     102        startLine: script.line_offset,
     103        startColumn: script.column_offset,
     104        endLine: endLine,
     105        endColumn: endColumn,
    95106        isContentScript: !!script.context_data && script.context_data.indexOf("injected") == 0
    96107    };
  • trunk/Source/WebCore/bindings/v8/ScriptDebugServer.cpp

    r85035 r85320  
    357357        toWebCoreStringWithNullOrUndefinedCheck(object->Get(v8::String::New("name"))),
    358358        toWebCoreStringWithNullOrUndefinedCheck(object->Get(v8::String::New("source"))),
    359         object->Get(v8::String::New("lineOffset"))->ToInteger()->Value(),
    360         object->Get(v8::String::New("columnOffset"))->ToInteger()->Value(),
     359        object->Get(v8::String::New("startLine"))->ToInteger()->Value(),
     360        object->Get(v8::String::New("startColumn"))->ToInteger()->Value(),
     361        object->Get(v8::String::New("endLine"))->ToInteger()->Value(),
     362        object->Get(v8::String::New("endColumn"))->ToInteger()->Value(),
    361363        object->Get(v8::String::New("isContentScript"))->ToBoolean()->Value());
    362364}
  • trunk/Source/WebCore/inspector/Inspector.json

    r85319 r85320  
    14731473                    { "name": "sourceID", "type": "string", "description": "Identifier of the script parsed." },
    14741474                    { "name": "url", "type": "string", "description": "URL of the script parsed (if any)." },
    1475                     { "name": "lineOffset", "type": "integer", "description": "Line offset of the script within the resource with given URL (for script tags)." },
    1476                     { "name": "columnOffset", "type": "integer", "description": "Column offset of the script within the resource with given URL." },
    1477                     { "name": "length", "type": "integer", "description": "Length of the script" },
     1475                    { "name": "startLine", "type": "integer", "description": "Line offset of the script within the resource with given URL (for script tags)." },
     1476                    { "name": "startColumn", "type": "integer", "description": "Column offset of the script within the resource with given URL." },
     1477                    { "name": "endLine", "type": "integer", "description": "Last line of the script." },
     1478                    { "name": "endColumn", "type": "integer", "description": "Length of the last line of the script." },
    14781479                    { "name": "isContentScript", "type": "boolean", "optional": true, "description": "Determines whether this script is a user extension script." }
    14791480                ],
  • trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp

    r85319 r85320  
    249249        return 0;
    250250    Script& script = scriptIterator->second;
    251     if (breakpoint.lineNumber < script.lineOffset)
    252         return 0;
    253     if (!script.linesCount) {
    254         script.linesCount = 1;
    255         for (size_t i = 0; i < script.data.length(); ++i) {
    256             if (script.data[i] == '\n')
    257                 script.linesCount += 1;
    258         }
    259     }
    260     if (breakpoint.lineNumber >= script.lineOffset + script.linesCount)
     251    if (breakpoint.lineNumber < script.startLine || script.endLine <= breakpoint.lineNumber)
    261252        return 0;
    262253
     
    377368// JavaScriptDebugListener functions
    378369
    379 void InspectorDebuggerAgent::didParseSource(const String& sourceID, const String& url, const String& data, int lineOffset, int columnOffset, bool isContentScript)
     370void InspectorDebuggerAgent::didParseSource(const String& sourceID, const String& url, const String& data, int startLine, int startColumn, int endLine, int endColumn, bool isContentScript)
    380371{
    381372    // Don't send script content to the front end until it's really needed.
    382     m_frontend->scriptParsed(sourceID, url, lineOffset, columnOffset, data.length(), isContentScript);
    383 
    384     m_scripts.set(sourceID, Script(url, data, lineOffset, columnOffset));
     373    m_frontend->scriptParsed(sourceID, url, startLine, startColumn, endLine, endColumn, isContentScript);
     374
     375    m_scripts.set(sourceID, Script(url, data, startLine, startColumn, endLine, endColumn));
    385376
    386377    if (url.isEmpty())
  • trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h

    r85319 r85320  
    121121    PassRefPtr<InspectorArray> currentCallFrames();
    122122
    123     virtual void didParseSource(const String& sourceID, const String& url, const String& data, int lineOffset, int columnOffset, bool isContentScript);
     123    virtual void didParseSource(const String& sourceID, const String& url, const String& data,  int startLine, int startColumn, int endLine, int endColumn, bool isContentScript);
    124124    virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage);
    125125    virtual void didPause(ScriptState*, const ScriptValue& callFrames, const ScriptValue& exception);
     
    132132    public:
    133133        Script()
    134             : lineOffset(0)
    135             , columnOffset(0)
    136             , linesCount(0)
     134            : startLine(0)
     135            , startColumn(0)
     136            , endLine(0)
     137            , endColumn(0)
    137138        {
    138139        }
    139140
    140         Script(const String& url, const String& data, int lineOffset, int columnOffset)
     141        Script(const String& url, const String& data, int startLine, int startColumn, int endLine, int endColumn)
    141142            : url(url)
    142143            , data(data)
    143             , lineOffset(lineOffset)
    144             , columnOffset(columnOffset)
    145             , linesCount(0)
     144            , startLine(startLine)
     145            , startColumn(startColumn)
     146            , endLine(endLine)
     147            , endColumn(endColumn)
    146148        {
    147149        }
     
    149151        String url;
    150152        String data;
    151         int lineOffset;
    152         int columnOffset;
     153        int startLine;
     154        int startColumn;
     155        int endLine;
     156        int endColumn;
    153157        int linesCount;
    154158    };
  • trunk/Source/WebCore/inspector/ScriptDebugListener.h

    r85035 r85320  
    4343    virtual ~ScriptDebugListener() { }
    4444
    45     virtual void didParseSource(const String&  sourceID, const String& url, const String& data, int lineOffset, int columnOffset, bool isContentScript) = 0;
     45    virtual void didParseSource(const String&  sourceID, const String& url, const String& data,  int startLine, int startColumn, int endLine, int endColumn, bool isContentScript) = 0;
    4646    virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage) = 0;
    4747    virtual void didPause(ScriptState*, const ScriptValue& callFrames, const ScriptValue& exception) = 0;
  • trunk/Source/WebCore/inspector/front-end/DebuggerModel.js

    r83601 r85320  
    180180    },
    181181
    182     _parsedScriptSource: function(sourceID, sourceURL, lineOffset, columnOffset, length, isContentScript)
    183     {
    184         var script = new WebInspector.Script(sourceID, sourceURL, lineOffset, columnOffset, length, undefined, undefined, isContentScript);
     182    _parsedScriptSource: function(sourceID, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript)
     183    {
     184        var script = new WebInspector.Script(sourceID, sourceURL, startLine, startColumn, endLine, endColumn, undefined, undefined, isContentScript);
    185185        this._scripts[sourceID] = script;
    186186        this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedScriptSource, script);
     
    189189    _failedToParseScriptSource: function(sourceURL, source, startingLine, errorLine, errorMessage)
    190190    {
    191         var script = new WebInspector.Script(null, sourceURL, startingLine, errorLine, errorMessage, undefined);
     191        var script = new WebInspector.Script(null, sourceURL, startingLine, 0, 0, 0, errorLine, errorMessage, undefined);
    192192        this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.FailedToParseScriptSource, script);
    193193    }
     
    228228    },
    229229
    230     scriptParsed: function(sourceID, sourceURL, lineOffset, columnOffset, length, isContentScript)
    231     {
    232         this._debuggerModel._parsedScriptSource(sourceID, sourceURL, lineOffset, columnOffset, length, isContentScript);
     230    scriptParsed: function(sourceID, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript)
     231    {
     232        this._debuggerModel._parsedScriptSource(sourceID, sourceURL, startLine, startColumn, endLine, endColumn, isContentScript);
    233233    },
    234234
  • trunk/Source/WebCore/inspector/front-end/Script.js

    r83601 r85320  
    2424 */
    2525
    26 WebInspector.Script = function(sourceID, sourceURL, lineOffset, columnOffset, length, errorLine, errorMessage, isContentScript)
     26WebInspector.Script = function(sourceID, sourceURL, startLine, startColumn, endLine, endColumn, errorLine, errorMessage, isContentScript)
    2727{
    2828    this.sourceID = sourceID;
    2929    this.sourceURL = sourceURL;
    30     this.lineOffset = lineOffset;
    31     this.columnOffset = columnOffset;
    32     this.length = length;
     30    this.lineOffset = startLine;
     31    this.columnOffset = startColumn;
     32    this.endLine = endLine;
     33    this.endColumn = endColumn;
    3334    this.errorLine = errorLine;
    3435    this.errorMessage = errorMessage;
Note: See TracChangeset for help on using the changeset viewer.