Changeset 94674 in webkit


Ignore:
Timestamp:
Sep 7, 2011 9:42:00 AM (13 years ago)
Author:
podivilov@chromium.org
Message:

Web Inspector: do not re-create RawSourceCode when toggling pretty-print mode.
https://bugs.webkit.org/show_bug.cgi?id=67647

1) Implement RawSourceCode.setFormatted that allows toggling pretty-print mode on the fly without resetting everything.
2) Add RawSourceCode unit tests.
3) Remove source mapping listeners and console messages from presentation model (they live in RawSourceCode now).

Reviewed by Yury Semikhatsky.

Source/WebCore:

Test: inspector/debugger/raw-source-code.html

  • inspector/front-end/DebuggerPresentationModel.js:

(WebInspector.DebuggerPresentationModel):
(WebInspector.DebuggerPresentationModel.prototype.linkifyLocation):
(WebInspector.DebuggerPresentationModel.prototype._addScript):
(WebInspector.DebuggerPresentationModel.prototype._sourceMappingUpdated):
(WebInspector.DebuggerPresentationModel.prototype.setFormatSource):
(WebInspector.DebuggerPresentationModel.prototype._createRawSourceCodeId):
(WebInspector.DebuggerPresentationModel.prototype._debuggerReset):

  • inspector/front-end/ScriptsPanel.js:

(WebInspector.ScriptsPanel.prototype._toggleFormatSource):

  • inspector/front-end/SourceFile.js:

(WebInspector.RawSourceCode):
(WebInspector.RawSourceCode.prototype.get uiSourceCode):
(WebInspector.RawSourceCode.prototype.setFormatted):
(WebInspector.RawSourceCode.prototype.rawLocationToUILocation):
(WebInspector.RawSourceCode.prototype._saveSourceMapping):

LayoutTests:

  • inspector/debugger/raw-source-code-expected.txt: Added.
  • inspector/debugger/raw-source-code.html: Added.
  • inspector/debugger/script-formatter.html:
  • inspector/debugger/source-file.html:
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r94671 r94674  
     12011-09-06  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Web Inspector: do not re-create RawSourceCode when toggling pretty-print mode.
     4        https://bugs.webkit.org/show_bug.cgi?id=67647
     5
     6        1) Implement RawSourceCode.setFormatted that allows toggling pretty-print mode on the fly without resetting everything.
     7        2) Add RawSourceCode unit tests.
     8        3) Remove source mapping listeners and console messages from presentation model (they live in RawSourceCode now).
     9
     10        Reviewed by Yury Semikhatsky.
     11
     12        * inspector/debugger/raw-source-code-expected.txt: Added.
     13        * inspector/debugger/raw-source-code.html: Added.
     14        * inspector/debugger/script-formatter.html:
     15        * inspector/debugger/source-file.html:
     16
    1172011-09-07  Alexander Pavlov  <apavlov@chromium.org>
    218
  • trunk/LayoutTests/inspector/debugger/script-formatter.html

    r94571 r94674  
    186186            {
    187187                dumpConsoleMessageURLs();
    188                 panel._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.UISourceCodeAdded,  uiSourceCodeReplaced);
     188                panel._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.UISourceCodeReplaced,  uiSourceCodeReplaced);
    189189                panel._toggleFormatSource();
    190190            }
  • trunk/LayoutTests/inspector/debugger/source-file.html

    r93977 r94674  
    8282        {
    8383            var script = new WebInspector.Script("1", "foo.js", 0, 0, 20, 80, undefined, undefined, false);
    84             var rawSourceCode = new WebInspector.RawSourceCode("id", script, mockScriptFormatter, true);
     84            var rawSourceCode = new WebInspector.RawSourceCode("id", script, null, mockScriptFormatter, true);
    8585
    8686            function didCreateSourceMapping()
     
    9797            var script1 = new WebInspector.Script("1", "foo.js", 10, 20, 30, 40, undefined, undefined, false);
    9898            var script2 = new WebInspector.Script("2", "foo.js", 50, 60, 70, 80, undefined, undefined, false);
    99             var rawSourceCode = new WebInspector.RawSourceCode("id", script1, mockScriptFormatter, true);
     99            var rawSourceCode = new WebInspector.RawSourceCode("id", script1, null, mockScriptFormatter, true);
    100100            rawSourceCode.addScript(script2);
    101101
  • trunk/Source/WebCore/ChangeLog

    r94671 r94674  
     12011-09-06  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Web Inspector: do not re-create RawSourceCode when toggling pretty-print mode.
     4        https://bugs.webkit.org/show_bug.cgi?id=67647
     5
     6        1) Implement RawSourceCode.setFormatted that allows toggling pretty-print mode on the fly without resetting everything.
     7        2) Add RawSourceCode unit tests.
     8        3) Remove source mapping listeners and console messages from presentation model (they live in RawSourceCode now).
     9
     10        Reviewed by Yury Semikhatsky.
     11
     12        Test: inspector/debugger/raw-source-code.html
     13
     14        * inspector/front-end/DebuggerPresentationModel.js:
     15        (WebInspector.DebuggerPresentationModel):
     16        (WebInspector.DebuggerPresentationModel.prototype.linkifyLocation):
     17        (WebInspector.DebuggerPresentationModel.prototype._addScript):
     18        (WebInspector.DebuggerPresentationModel.prototype._sourceMappingUpdated):
     19        (WebInspector.DebuggerPresentationModel.prototype.setFormatSource):
     20        (WebInspector.DebuggerPresentationModel.prototype._createRawSourceCodeId):
     21        (WebInspector.DebuggerPresentationModel.prototype._debuggerReset):
     22        * inspector/front-end/ScriptsPanel.js:
     23        (WebInspector.ScriptsPanel.prototype._toggleFormatSource):
     24        * inspector/front-end/SourceFile.js:
     25        (WebInspector.RawSourceCode):
     26        (WebInspector.RawSourceCode.prototype.get uiSourceCode):
     27        (WebInspector.RawSourceCode.prototype.setFormatted):
     28        (WebInspector.RawSourceCode.prototype.rawLocationToUILocation):
     29        (WebInspector.RawSourceCode.prototype._saveSourceMapping):
     30
    1312011-09-07  Alexander Pavlov  <apavlov@chromium.org>
    232
  • trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js

    r94571 r94674  
    3838    this._rawSourceCode = {};
    3939    this._messages = [];
    40     // FIXME: move this to RawSourceCode when it's not re-created in pretty-print mode.
    41     this._sourceMappingListeners = [];
    4240
    4341    this._presentationCallFrames = [];
     
    9997    },
    10098
    101     addSourceMappingListener: function(sourceURL, scriptId, listener)
    102     {
    103         this._sourceMappingListeners.push(listener);
    104     },
    105 
    106     removeSourceMappingListener: function(sourceURL, scriptId, listener)
    107     {
    108         // FIXME: implement this.
    109     },
    110 
    11199    linkifyLocation: function(sourceURL, lineNumber, columnNumber, classes)
    112100    {
     
    133121        }
    134122        updateAnchor.call(this);
    135         this.addSourceMappingListener(sourceURL, null, updateAnchor.bind(this));
     123        rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, updateAnchor, this);
    136124        return anchor;
    137125    },
     
    156144        }
    157145
    158         rawSourceCode = new WebInspector.RawSourceCode(rawSourceCodeId, script, this._formatter, this._formatSource);
     146        var resource;
     147        if (script.sourceURL)
     148            resource = WebInspector.networkManager.inflightResourceForURL(script.sourceURL) || WebInspector.resourceForURL(script.sourceURL);
     149        rawSourceCode = new WebInspector.RawSourceCode(rawSourceCodeId, script, resource, this._formatter, this._formatSource);
    159150        this._rawSourceCode[rawSourceCodeId] = rawSourceCode;
     151        if (rawSourceCode.uiSourceCode)
     152            this._updateSourceMapping(rawSourceCode, null);
    160153        rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, this._sourceMappingUpdated, this);
    161154    },
     
    163156    _sourceMappingUpdated: function(event)
    164157    {
    165         for (var i = 0; i < this._sourceMappingListeners.length; ++i)
    166             this._sourceMappingListeners[i]();
    167 
    168158        var rawSourceCode = event.target;
    169159        var oldUISourceCode = event.data.oldUISourceCode;
     160        this._updateSourceMapping(rawSourceCode, oldUISourceCode);
     161    },
     162
     163    _updateSourceMapping: function(rawSourceCode, oldUISourceCode)
     164    {
    170165        var uiSourceCode = rawSourceCode.uiSourceCode;
    171166
     
    182177            this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.UISourceCodeReplaced, eventData);
    183178        }
    184         this._restoreBreakpoints(uiSourceCode);
    185     },
    186 
    187     _restoreBreakpoints: function(uiSourceCode)
    188     {
     179
    189180        this._breakpointManager.uiSourceCodeAdded(uiSourceCode);
    190181        var breakpoints = this._breakpointManager.breakpointsForUISourceCode(uiSourceCode);
     
    263254
    264255        this._breakpointManager.reset();
    265         for (var id in this._rawSourceCode)
    266             this._rawSourceCode[id].removeEventListener(WebInspector.RawSourceCode.Events.SourceMappingUpdated, this._sourceMappingUpdated, this);
    267         this._rawSourceCode = {};
     256
     257        for (var id in this._rawSourceCode) {
     258            this._rawSourceCode[id].messages = [];
     259            this._rawSourceCode[id].setFormatted(this._formatSource);
     260        }
     261
    268262        var messages = this._messages;
    269263        this._messages = [];
    270 
    271         var scripts = WebInspector.debuggerModel.scripts;
    272         for (var id in scripts)
    273             this._addScript(scripts[id]);
    274 
    275264        for (var i = 0; i < messages.length; ++i)
    276265            this._addConsoleMessage(messages[i]);
    277 
    278         // FIXME: move this to RawSourceCode.
    279         for (var i = 0; i < this._sourceMappingListeners.length; ++i)
    280             this._sourceMappingListeners[i]();
    281266
    282267        if (WebInspector.debuggerModel.callFrames)
     
    447432    _createRawSourceCodeId: function(sourceURL, scriptId)
    448433    {
    449         var prefix = this._formatSource ? "deobfuscated:" : "";
    450         return prefix + (sourceURL || scriptId);
     434        return sourceURL || scriptId;
    451435    },
    452436
     
    455439        this._rawSourceCode = {};
    456440        this._messages = [];
    457         this._sourceMappingListeners = [];
    458441        this._presentationCallFrames = [];
    459442        this._selectedCallFrameIndex = 0;
  • trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js

    r94571 r94674  
    11331133    _toggleFormatSource: function()
    11341134    {
    1135         WebInspector.panels.scripts.reset();
    11361135        this._toggleFormatSourceButton.toggled = !this._toggleFormatSourceButton.toggled;
    11371136        this._presentationModel.setFormatSource(this._toggleFormatSourceButton.toggled);
  • trunk/Source/WebCore/inspector/front-end/SourceFile.js

    r94571 r94674  
    3636 * @extends {WebInspector.Object}
    3737 */
    38 WebInspector.RawSourceCode = function(id, script, formatter, formatted)
    39 {
     38WebInspector.RawSourceCode = function(id, script, resource, formatter, formatted)
     39{
     40    this.id = id;
     41    this.url = script.sourceURL;
     42    this.isContentScript = script.isContentScript;
    4043    this._scripts = [script];
    4144    this._formatter = formatter;
    4245    this._formatted = formatted;
    43 
    44     if (script.sourceURL)
    45         this._resource = WebInspector.networkManager.inflightResourceForURL(script.sourceURL) || WebInspector.resourceForURL(script.sourceURL);
    46 
    47     this.id = id;
    48     this.url = script.sourceURL;
    49     this.isContentScript = script.isContentScript;
     46    this._resource = resource;
    5047    this.messages = [];
    5148
     
    7168    get uiSourceCode()
    7269    {
    73         // FIXME: extract UISourceCode from RawSourceCode (currently RawSourceCode implements methods from both interfaces).
    74         return this;
    75     },
    76 
    77     get rawSourceCode()
    78     {
    79         // FIXME: extract UISourceCode from RawSourceCode (currently RawSourceCode implements methods from both interfaces).
    80         return this;
     70        return this._uiSourceCode;
     71    },
     72
     73    setFormatted: function(formatted)
     74    {
     75        if (this._formatted === formatted)
     76            return;
     77        this._formatted = formatted;
     78        this._updateSourceMapping();
    8179    },
    8280
     
    9593    {
    9694        var location = this._mapping ? this._mapping.originalToFormatted(rawLocation) : rawLocation;
    97         return new WebInspector.UILocation(this, location.lineNumber, location.columnNumber);
     95        return new WebInspector.UILocation(this.uiSourceCode, location.lineNumber, location.columnNumber);
    9896    },
    9997
     
    121119    },
    122120
    123     requestContent: function(callback)
    124     {
    125         // FIXME: remove this.
    126         this._uiSourceCode.requestContent(callback);
    127     },
    128 
    129121    createSourceMappingIfNeeded: function(callback)
    130122    {
     
    185177    {
    186178        if (!this._formatted) {
    187             setTimeout(callback.bind(null, originalContentProvider, null), 0);
     179            callback(originalContentProvider, null);
    188180            return;
    189181        }
     
    203195    _saveSourceMapping: function(contentProvider, mapping)
    204196    {
    205         var oldUISourceCode;
    206         if (this._uiSourceCode)
    207             oldUISourceCode = this;
     197        var oldUISourceCode = this._uiSourceCode;
    208198        var uiSourceCodeId = (this._formatted ? "deobfuscated:" : "") + (this._scripts[0].sourceURL || this._scripts[0].scriptId);
    209199        this._uiSourceCode = new WebInspector.UISourceCode(uiSourceCodeId, this.url, this.isContentScript, this, contentProvider);
Note: See TracChangeset for help on using the changeset viewer.