Changeset 95522 in webkit


Ignore:
Timestamp:
Sep 20, 2011 2:28:50 AM (13 years ago)
Author:
podivilov@chromium.org
Message:

Web Inspector: extract RawSourceCode source mapping logic to helper classes.
https://bugs.webkit.org/show_bug.cgi?id=67789

Reviewed by Pavel Feldman.

  • inspector/front-end/SourceFile.js:

(WebInspector.RawSourceCode.prototype.get uiSourceCode):
(WebInspector.RawSourceCode.prototype.rawLocationToUILocation):
(WebInspector.RawSourceCode.prototype.uiLocationToRawLocation):
(WebInspector.RawSourceCode.prototype._createSourceMapping.didRequestContent.didFormatContent):
(WebInspector.RawSourceCode.prototype._createSourceMapping.didRequestContent):
(WebInspector.RawSourceCode.prototype._createSourceMapping):
(WebInspector.RawSourceCode.prototype._saveSourceMapping):
(WebInspector.RawSourceCode.PlainSourceMapping):
(WebInspector.RawSourceCode.PlainSourceMapping.prototype.rawLocationToUILocation):
(WebInspector.RawSourceCode.PlainSourceMapping.prototype.uiLocationToRawLocation):
(WebInspector.RawSourceCode.PlainSourceMapping.prototype.get uiSourceCode):
(WebInspector.RawSourceCode.FormattedSourceMapping):
(WebInspector.RawSourceCode.FormattedSourceMapping.prototype.rawLocationToUILocation):
(WebInspector.RawSourceCode.FormattedSourceMapping.prototype.uiLocationToRawLocation):
(WebInspector.RawSourceCode.FormattedSourceMapping.prototype.get uiSourceCode):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r95521 r95522  
     12011-09-08  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Web Inspector: extract RawSourceCode source mapping logic to helper classes.
     4        https://bugs.webkit.org/show_bug.cgi?id=67789
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * inspector/front-end/SourceFile.js:
     9        (WebInspector.RawSourceCode.prototype.get uiSourceCode):
     10        (WebInspector.RawSourceCode.prototype.rawLocationToUILocation):
     11        (WebInspector.RawSourceCode.prototype.uiLocationToRawLocation):
     12        (WebInspector.RawSourceCode.prototype._createSourceMapping.didRequestContent.didFormatContent):
     13        (WebInspector.RawSourceCode.prototype._createSourceMapping.didRequestContent):
     14        (WebInspector.RawSourceCode.prototype._createSourceMapping):
     15        (WebInspector.RawSourceCode.prototype._saveSourceMapping):
     16        (WebInspector.RawSourceCode.PlainSourceMapping):
     17        (WebInspector.RawSourceCode.PlainSourceMapping.prototype.rawLocationToUILocation):
     18        (WebInspector.RawSourceCode.PlainSourceMapping.prototype.uiLocationToRawLocation):
     19        (WebInspector.RawSourceCode.PlainSourceMapping.prototype.get uiSourceCode):
     20        (WebInspector.RawSourceCode.FormattedSourceMapping):
     21        (WebInspector.RawSourceCode.FormattedSourceMapping.prototype.rawLocationToUILocation):
     22        (WebInspector.RawSourceCode.FormattedSourceMapping.prototype.uiLocationToRawLocation):
     23        (WebInspector.RawSourceCode.FormattedSourceMapping.prototype.get uiSourceCode):
     24
    1252011-09-20  Carlos Garcia Campos  <cgarcia@igalia.com>
    226
  • trunk/Source/WebCore/inspector/front-end/SourceFile.js

    r94762 r95522  
    6868    get uiSourceCode()
    6969    {
    70         return this._uiSourceCode;
     70        // FIXME: clients should use sourceMapping directly.
     71        return this._sourceMapping && this._sourceMapping.uiSourceCode;
    7172    },
    7273
     
    9293    rawLocationToUILocation: function(rawLocation)
    9394    {
    94         var location = this._mapping ? this._mapping.originalToFormatted(rawLocation) : rawLocation;
    95         return new WebInspector.UILocation(this.uiSourceCode, location.lineNumber, location.columnNumber);
     95        // FIXME: clients should use sourceMapping directly.
     96        return this._sourceMapping.rawLocationToUILocation(rawLocation);
    9697    },
    9798
    9899    uiLocationToRawLocation: function(lineNumber, columnNumber)
    99100    {
    100         var rawLocation = { lineNumber: lineNumber, columnNumber: columnNumber };
    101         if (this._mapping)
    102             rawLocation = this._mapping.formattedToOriginal(rawLocation);
    103         rawLocation.scriptId = this._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId;
    104         return rawLocation;
     101        // FIXME: clients should use sourceMapping directly.
     102        return this._sourceMapping.uiLocationToRawLocation(lineNumber, columnNumber);
    105103    },
    106104
     
    161159    {
    162160        if (!this._formatted) {
    163             callback(originalContentProvider, null);
     161            var uiSourceCode = new WebInspector.UISourceCode(this.id, this.url, this.isContentScript, this, originalContentProvider);
     162            var sourceMapping = new WebInspector.RawSourceCode.PlainSourceMapping(this, uiSourceCode);
     163            callback(sourceMapping);
    164164            return;
    165165        }
     
    170170            {
    171171                var contentProvider = new WebInspector.StaticContentProvider(mimeType, formattedContent)
    172                 callback(contentProvider, mapping);
     172                var uiSourceCode = new WebInspector.UISourceCode("deobfuscated:" + this.id, this.url, this.isContentScript, this, contentProvider);
     173                var sourceMapping = new WebInspector.RawSourceCode.FormattedSourceMapping(this, uiSourceCode, mapping);
     174                callback(sourceMapping);
    173175            }
    174176            this._formatter.formatContent(mimeType, content, didFormatContent.bind(this));
     
    177179    },
    178180
    179     _saveSourceMapping: function(contentProvider, mapping)
    180     {
    181         var oldUISourceCode = this._uiSourceCode;
    182         var uiSourceCodeId = (this._formatted ? "deobfuscated:" : "") + (this._scripts[0].sourceURL || this._scripts[0].scriptId);
    183         this._uiSourceCode = new WebInspector.UISourceCode(uiSourceCodeId, this.url, this.isContentScript, this, contentProvider);
    184         this._mapping = mapping;
     181    _saveSourceMapping: function(sourceMapping)
     182    {
     183        var oldUISourceCode;
     184        if (this._sourceMapping)
     185            oldUISourceCode = this._sourceMapping.uiSourceCode;
     186        this._sourceMapping = sourceMapping;
    185187        this.dispatchEventToListeners(WebInspector.RawSourceCode.Events.SourceMappingUpdated, { oldUISourceCode: oldUISourceCode });
    186188    }
     
    188190
    189191WebInspector.RawSourceCode.prototype.__proto__ = WebInspector.Object.prototype;
     192
     193
     194/**
     195 * @constructor
     196 */
     197WebInspector.RawSourceCode.PlainSourceMapping = function(rawSourceCode, uiSourceCode)
     198{
     199    this._rawSourceCode = rawSourceCode;
     200    this._uiSourceCode = uiSourceCode;
     201}
     202
     203WebInspector.RawSourceCode.PlainSourceMapping.prototype = {
     204    rawLocationToUILocation: function(rawLocation)
     205    {
     206        return new WebInspector.UILocation(this._uiSourceCode, rawLocation.lineNumber, rawLocation.columnNumber);
     207    },
     208
     209    uiLocationToRawLocation: function(lineNumber, columnNumber)
     210    {
     211        var rawLocation = { lineNumber: lineNumber, columnNumber: columnNumber };
     212        rawLocation.scriptId = this._rawSourceCode._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId;
     213        return rawLocation;
     214    },
     215
     216    get uiSourceCode()
     217    {
     218        return this._uiSourceCode;
     219    }
     220}
     221
     222/**
     223 * @constructor
     224 */
     225WebInspector.RawSourceCode.FormattedSourceMapping = function(rawSourceCode, uiSourceCode, mapping)
     226{
     227    this._rawSourceCode = rawSourceCode;
     228    this._uiSourceCode = uiSourceCode;
     229    this._mapping = mapping;
     230}
     231
     232WebInspector.RawSourceCode.FormattedSourceMapping.prototype = {
     233    rawLocationToUILocation: function(rawLocation)
     234    {
     235        var location = this._mapping.originalToFormatted(rawLocation);
     236        return new WebInspector.UILocation(this._uiSourceCode, location.lineNumber, location.columnNumber);
     237    },
     238
     239    uiLocationToRawLocation: function(lineNumber, columnNumber)
     240    {
     241        var rawLocation = this._mapping.formattedToOriginal({ lineNumber: lineNumber, columnNumber: columnNumber });
     242        rawLocation.scriptId = this._rawSourceCode._scriptForRawLocation(rawLocation.lineNumber, rawLocation.columnNumber).scriptId;
     243        return rawLocation;
     244    },
     245
     246    get uiSourceCode()
     247    {
     248        return this._uiSourceCode;
     249    }
     250}
    190251
    191252
Note: See TracChangeset for help on using the changeset viewer.