Changeset 83151 in webkit


Ignore:
Timestamp:
Apr 7, 2011 1:39:45 AM (13 years ago)
Author:
podivilov@chromium.org
Message:

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

Reviewed by Pavel Feldman.

Web Inspector: build mapping for formatted scripts based on keywords positions.
https://bugs.webkit.org/show_bug.cgi?id=57936

Mapping based on [\$\.\w]+ was not accurate because string literals representation
may be different in original and formatted scripts.

  • inspector/front-end/ScriptFormatterWorker.js: (buildMapping.regexp.b): (buildMapping):
Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r83145 r83151  
     12011-04-07  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: build mapping for formatted scripts based on keywords positions.
     6        https://bugs.webkit.org/show_bug.cgi?id=57936
     7
     8        Mapping based on [\$\.\w]+ was not accurate because string literals representation
     9        may be different in original and formatted scripts.
     10
     11        * inspector/front-end/ScriptFormatterWorker.js:
     12        (buildMapping.regexp.b):
     13        (buildMapping):
     14
    1152011-04-07  Kent Tamura  <tkent@chromium.org>
    216
  • trunk/Source/WebCore/inspector/front-end/ScriptFormatterWorker.js

    r82666 r83151  
    5151{
    5252    var mapping = { original: [], formatted: [] };
    53     var lastCodePosition = 0;
    54     var regexp = /[\$\.\w]+|{|}/g;
     53    var lastFormattedPosition = 0;
     54    var regexp = /\b(?:function|var|const|try|catch|throw|new|switch|break|continue|if|for|while|do|return|with|null|undefined)\b/g;
    5555    while (true) {
    56         var match = regexp.exec(formattedSource);
     56        var match = regexp.exec(source);
    5757        if (!match)
    5858            break;
    59         var position = source.indexOf(match[0], lastCodePosition);
    60         if (position === -1)
    61             continue;
    62         mapping.original.push(position);
    63         mapping.formatted.push(match.index);
    64         lastCodePosition = position + match[0].length;
     59        var formattedPosition = formattedSource.indexOf(match[0], lastFormattedPosition);
     60        mapping.original.push(match.index);
     61        mapping.formatted.push(formattedPosition);
     62        lastFormattedPosition = formattedPosition + match[0].length;
    6563    }
    6664    return mapping;
Note: See TracChangeset for help on using the changeset viewer.