Changeset 87071 in webkit


Ignore:
Timestamp:
May 23, 2011 6:41:24 AM (13 years ago)
Author:
podivilov@chromium.org
Message:

2011-05-18 Pavel Podivilov <podivilov@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: source mapping for pretty-printed scripts is sometimes inaccurate after indented comments.
https://bugs.webkit.org/show_bug.cgi?id=61037

  • http/tests/inspector/inspector-test.js: (initialize_InspectorTest):
  • inspector/debugger/resources/obfuscated.js: (withComments):
  • inspector/debugger/script-formatter.html:

2011-05-18 Pavel Podivilov <podivilov@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: source mapping for pretty-printed scripts is sometimes inaccurate after indented comments.
https://bugs.webkit.org/show_bug.cgi?id=61037

  • inspector/front-end/JavaScriptFormatter.js: (FormattedContentBuilder.prototype.addToken): (FormattedContentBuilder.prototype._addComment): (FormattedContentBuilder.prototype._addText): (FormattedContentBuilder.prototype._addMappingIfNeeded):
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r87070 r87071  
     12011-05-18  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: source mapping for pretty-printed scripts is sometimes inaccurate after indented comments.
     6        https://bugs.webkit.org/show_bug.cgi?id=61037
     7
     8        * http/tests/inspector/inspector-test.js:
     9        (initialize_InspectorTest):
     10        * inspector/debugger/resources/obfuscated.js:
     11        (withComments):
     12        * inspector/debugger/script-formatter.html:
     13
    1142011-05-23  Mike West  <mkwst@chromium.org>
    215
  • trunk/LayoutTests/http/tests/inspector/inspector-test.js

    r86959 r87071  
    236236}
    237237
     238InspectorTest.assertTrue = function(found, message)
     239{
     240    InspectorTest.assertEquals(true, !!found);
     241}
     242
    238243InspectorTest.safeWrap = function(func, onexception)
    239244{
  • trunk/LayoutTests/inspector/debugger/resources/obfuscated.js

    r86443 r87071  
    22{
    33    var variable1 = 0;
     4}
     5
     6function withComments()
     7{
     8// comment
     9    return "functionWithComments";
    410}
    511
  • trunk/LayoutTests/inspector/debugger/script-formatter.html

    r86443 r87071  
    6060                function testMapping(string)
    6161                {
    62                     var originalLocation = WebInspector.ScriptFormatter.positionToLocation(source.lineEndings(), source.indexOf(string));
     62                    var originalPosition = source.indexOf(string);
     63                    InspectorTest.assertTrue(originalPosition !== -1);
     64                    var originalLocation = WebInspector.ScriptFormatter.positionToLocation(source.lineEndings(), originalPosition);
    6365                    var formattedLocation = mapping.originalToFormatted(originalLocation);
    6466                    var formattedPosition = WebInspector.ScriptFormatter.locationToPosition(formattedSource.lineEndings(), formattedLocation);
    6567                    var expectedFormattedPosition = formattedSource.indexOf(string);
    66                     InspectorTest.assertEquals(expectedFormattedPosition, formattedPosition);
     68                    InspectorTest.assertEquals(expectedFormattedPosition, formattedPosition, "wrong mapping for <" + string + ">");
    6769                }
    6870
     
    7072                testMapping("formatted1");
    7173                testMapping("variable1");
     74
     75                testMapping("    return \"functionWithComments\"");
    7276
    7377                testMapping("onmessage");
  • trunk/Source/WebCore/ChangeLog

    r87070 r87071  
     12011-05-18  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: source mapping for pretty-printed scripts is sometimes inaccurate after indented comments.
     6        https://bugs.webkit.org/show_bug.cgi?id=61037
     7
     8        * inspector/front-end/JavaScriptFormatter.js:
     9        (FormattedContentBuilder.prototype.addToken):
     10        (FormattedContentBuilder.prototype._addComment):
     11        (FormattedContentBuilder.prototype._addText):
     12        (FormattedContentBuilder.prototype._addMappingIfNeeded):
     13
    1142011-05-23  Mike West  <mkwst@chromium.org>
    215
  • trunk/Source/WebCore/inspector/front-end/JavaScriptFormatter.js

    r84625 r87071  
    6565        }
    6666
    67         if (token.pos - this._lastOriginalPosition !== this._formattedContentLength - this._lastFormattedPosition) {
    68             this._mapping.original.push(this._originalOffset + token.pos);
    69             this._lastOriginalPosition = token.pos;
    70             this._mapping.formatted.push(this._formattedOffset + this._formattedContentLength);
    71             this._lastFormattedPosition = this._formattedContentLength;
    72         }
    73 
     67        this._addMappingIfNeeded(token.pos);
    7468        this._addText(this._originalContent.substring(token.pos, token.endPos));
    7569        this._lineNumber = token.endLine;
     
    123117            this.addSpace();
    124118
     119        this._addMappingIfNeeded(comment.pos);
    125120        if (comment.type === "comment1")
    126121            this._addText("//");
     
    142137        this._formattedContent.push(text);
    143138        this._formattedContentLength += text.length;
     139    },
     140
     141    _addMappingIfNeeded: function(originalPosition)
     142    {
     143        if (originalPosition - this._lastOriginalPosition === this._formattedContentLength - this._lastFormattedPosition)
     144            return;
     145        this._mapping.original.push(this._originalOffset + originalPosition);
     146        this._lastOriginalPosition = originalPosition;
     147        this._mapping.formatted.push(this._formattedOffset + this._formattedContentLength);
     148        this._lastFormattedPosition = this._formattedContentLength;
    144149    }
    145150}
Note: See TracChangeset for help on using the changeset viewer.