Changeset 93977 in webkit


Ignore:
Timestamp:
Aug 29, 2011, 8:14:07 AM (14 years ago)
Author:
podivilov@chromium.org
Message:

Web Inspector: rename sourceFile to (raw|ui)SourceCode in DebuggerPresentationModel.
https://bugs.webkit.org/show_bug.cgi?id=66769

Reviewed by Pavel Feldman.

Source/WebCore:

  • inspector/front-end/DebuggerPresentationModel.js:

(WebInspector.DebuggerPresentationModel):
(WebInspector.DebuggerPresentationModel.prototype.uiSourceCode):
(WebInspector.DebuggerPresentationModel.prototype._scriptLocationToUILocation.didCreateSourceMapping):
(WebInspector.DebuggerPresentationModel.prototype._scriptLocationToUILocation):
(WebInspector.DebuggerPresentationModel.prototype._uiLocationToScriptLocation.didCreateSourceMapping):
(WebInspector.DebuggerPresentationModel.prototype._uiLocationToScriptLocation):
(WebInspector.DebuggerPresentationModel.prototype.linkifyLocation.updateAnchor.didGetLocation):
(WebInspector.DebuggerPresentationModel.prototype.linkifyLocation.updateAnchor):
(WebInspector.DebuggerPresentationModel.prototype.linkifyLocation):
(WebInspector.DebuggerPresentationModel.prototype._addScript.didCreateSourceMapping):
(WebInspector.DebuggerPresentationModel.prototype._addScript):
(WebInspector.DebuggerPresentationModel.prototype._uiSourceCodeReplaced):
(WebInspector.DebuggerPresentationModel.prototype.canEditScriptSource):
(WebInspector.DebuggerPresentationModel.prototype.setScriptSource.didEditScriptSource):
(WebInspector.DebuggerPresentationModel.prototype.setScriptSource):
(WebInspector.DebuggerPresentationModel.prototype._updateBreakpointsAfterLiveEdit):
(WebInspector.DebuggerPresentationModel.prototype.setFormatSourceFiles):
(WebInspector.DebuggerPresentationModel.prototype._addConsoleMessage.didGetUILocation):
(WebInspector.DebuggerPresentationModel.prototype._addConsoleMessage):
(WebInspector.DebuggerPresentationModel.prototype._consoleCleared):
(WebInspector.DebuggerPresentationModel.prototype.continueToLine):
(WebInspector.DebuggerPresentationModel.prototype.breakpointsForSourceFileId):
(WebInspector.DebuggerPresentationModel.prototype.setBreakpoint):
(WebInspector.DebuggerPresentationModel.prototype.setBreakpointEnabled):
(WebInspector.DebuggerPresentationModel.prototype.updateBreakpoint):
(WebInspector.DebuggerPresentationModel.prototype.removeBreakpoint):
(WebInspector.DebuggerPresentationModel.prototype.findBreakpoint):
(WebInspector.DebuggerPresentationModel.prototype._breakpointAdded):
(WebInspector.DebuggerPresentationModel.prototype._breakpointRemoved):
(WebInspector.DebuggerPresentationModel.prototype._debuggerPaused):
(WebInspector.DebuggerPresentationModel.prototype._rawSourceCodeForScript):
(WebInspector.DebuggerPresentationModel.prototype._scriptForRawSourceCode):
(WebInspector.DebuggerPresentationModel.prototype._createRawSourceCodeId):
(WebInspector.DebuggerPresentationModel.prototype._debuggerReset):
(WebInspector.PresentationBreakpoint):
(WebInspector.PresenationCallFrame.prototype.sourceLine.didGetUILocation):
(WebInspector.PresenationCallFrame.prototype.sourceLine):
(WebInspector.DebuggerPresentationModelResourceBinding.prototype.canSetContent):
(WebInspector.DebuggerPresentationModelResourceBinding.prototype.setContent):
(WebInspector.DebuggerPresentationModelResourceBinding.prototype._setContentWithInitialContent):

  • inspector/front-end/ScriptsPanel.js:

(WebInspector.ScriptsPanel.prototype.canShowAnchorLocation):
(WebInspector.ScriptsPanel.prototype._createSourceFrame):
(WebInspector.ScriptsPanel.prototype._sourceFrameLoaded):
(WebInspector.ScriptsPanel.prototype._callFrameSelected.didGetSourceLocation):
(WebInspector.ScriptsPanel.prototype._callFrameSelected):
(WebInspector.SourceFrameDelegateForScriptsPanel.prototype.requestContent):
(WebInspector.SourceFrameDelegateForScriptsPanel.prototype.suggestedFileName):

  • inspector/front-end/SourceFile.js:

(WebInspector.RawSourceCode.prototype.rawLocationToUILocation):
(WebInspector.UILocation):

LayoutTests:

  • inspector/debugger/scripts-panel.html:
  • inspector/debugger/source-file.html:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r93976 r93977  
     12011-08-25  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Web Inspector: rename sourceFile to (raw|ui)SourceCode in DebuggerPresentationModel.
     4        https://bugs.webkit.org/show_bug.cgi?id=66769
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * inspector/debugger/scripts-panel.html:
     9        * inspector/debugger/source-file.html:
     10
    1112011-08-29  Gabor Loki  <loki@webkit.org>
    212
  • trunk/LayoutTests/inspector/debugger/scripts-panel.html

    r92838 r93977  
    154154            model._addScript(createMockScript("foo.js", "1"));
    155155            model._addScript(createMockScript("bar.js", "2"));
    156             var sourceFile = model._sourceFileForScript("bar.js");
     156            var sourceFile = model._rawSourceCodeForScript("bar.js");
    157157            panel._sourceFileReplaced({ data: { oldSourceCode: sourceFile, sourceCode: sourceFile }});
    158158            showSourceFrame(panel, "bar.js");
  • trunk/LayoutTests/inspector/debugger/source-file.html

    r93963 r93977  
    4444    }
    4545
    46     function checkUILocation(sourceFile, lineNumber, columnNumber, location)
     46    function checkUILocation(rawSourceCode, lineNumber, columnNumber, location)
    4747    {
    48         InspectorTest.assertEquals(sourceFile, location.sourceFile);
     48        InspectorTest.assertEquals(rawSourceCode.uiSourceCode, location.uiSourceCode);
    4949        InspectorTest.assertEquals(lineNumber, location.lineNumber);
    5050        InspectorTest.assertEquals(columnNumber, location.columnNumber);
     
    5555        {
    5656            var script = new WebInspector.Script("1", "foo.js", 0, 0, 20, 80, undefined, undefined, false);
    57             var sourceFile = new WebInspector.RawSourceCode("id", script);
     57            var rawSourceCode = new WebInspector.RawSourceCode("id", script);
    5858
    59             checkUILocation(sourceFile, 10, 20, sourceFile.rawLocationToUILocation(rl(10, 20)));
    60             checkRawLocation(script, 30, 40, sourceFile.uiLocationToRawLocation(30, 40));
     59            checkUILocation(rawSourceCode, 10, 20, rawSourceCode.rawLocationToUILocation(rl(10, 20)));
     60            checkRawLocation(script, 30, 40, rawSourceCode.uiLocationToRawLocation(30, 40));
    6161
    6262            next();
     
    6767            var script1 = new WebInspector.Script("1", "foo.js", 10, 20, 30, 40, undefined, undefined, false);
    6868            var script2 = new WebInspector.Script("2", "foo.js", 50, 60, 70, 80, undefined, undefined, false);
    69             var sourceFile = new WebInspector.RawSourceCode("id", script1);
    70             sourceFile.addScript(script2);
     69            var rawSourceCode = new WebInspector.RawSourceCode("id", script1);
     70            rawSourceCode.addScript(script2);
    7171
    72             checkUILocation(sourceFile, 20, 0, sourceFile.rawLocationToUILocation(rl(20, 0)));
     72            checkUILocation(rawSourceCode, 20, 0, rawSourceCode.rawLocationToUILocation(rl(20, 0)));
    7373
    74             checkRawLocation(script1, 0, 40, sourceFile.uiLocationToRawLocation(0, 40));
    75             checkRawLocation(script1, 20, 0, sourceFile.uiLocationToRawLocation(20, 0));
    76             checkRawLocation(script2, 50, 60, sourceFile.uiLocationToRawLocation(50, 60));
     74            checkRawLocation(script1, 0, 40, rawSourceCode.uiLocationToRawLocation(0, 40));
     75            checkRawLocation(script1, 20, 0, rawSourceCode.uiLocationToRawLocation(20, 0));
     76            checkRawLocation(script2, 50, 60, rawSourceCode.uiLocationToRawLocation(50, 60));
    7777
    7878            next();
     
    8282        {
    8383            var script = new WebInspector.Script("1", "foo.js", 0, 0, 20, 80, undefined, undefined, false);
    84             var sourceFile = new WebInspector.RawSourceCode("id", script, mockScriptFormatter, true);
     84            var rawSourceCode = new WebInspector.RawSourceCode("id", script, mockScriptFormatter, true);
    8585
    8686            function didCreateSourceMapping()
    8787            {
    88                 checkUILocation(sourceFile, 22, 40, sourceFile.rawLocationToUILocation(rl(11, 20)));
    89                 checkRawLocation(script, 7, 9, sourceFile.uiLocationToRawLocation(14, 19));
     88                checkUILocation(rawSourceCode, 22, 40, rawSourceCode.rawLocationToUILocation(rl(11, 20)));
     89                checkRawLocation(script, 7, 9, rawSourceCode.uiLocationToRawLocation(14, 19));
    9090                next();
    9191            }
    92             sourceFile.createSourceMappingIfNeeded(didCreateSourceMapping);
     92            rawSourceCode.createSourceMappingIfNeeded(didCreateSourceMapping);
    9393        },
    9494
     
    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 sourceFile = new WebInspector.RawSourceCode("id", script1, mockScriptFormatter, true);
    100             sourceFile.addScript(script2);
     99            var rawSourceCode = new WebInspector.RawSourceCode("id", script1, mockScriptFormatter, true);
     100            rawSourceCode.addScript(script2);
    101101
    102102            function didCreateSourceMapping()
    103103            {
    104                 checkUILocation(sourceFile, 22, 60, sourceFile.rawLocationToUILocation(rl(11, 30)));
    105                 checkRawLocation(script1, 12, 10, sourceFile.uiLocationToRawLocation(24, 20));
    106                 checkRawLocation(script2, 60, 19, sourceFile.uiLocationToRawLocation(121, 38));
     104                checkUILocation(rawSourceCode, 22, 60, rawSourceCode.rawLocationToUILocation(rl(11, 30)));
     105                checkRawLocation(script1, 12, 10, rawSourceCode.uiLocationToRawLocation(24, 20));
     106                checkRawLocation(script2, 60, 19, rawSourceCode.uiLocationToRawLocation(121, 38));
    107107                next();
    108108            }
    109             sourceFile.createSourceMappingIfNeeded(didCreateSourceMapping);
     109            rawSourceCode.createSourceMappingIfNeeded(didCreateSourceMapping);
    110110        },
    111111
     
    113113        {
    114114            var script = new WebInspector.Script("1", "foo.js", 0, 0, 20, 80, undefined, undefined, false);
    115             var sourceFile = new WebInspector.RawSourceCode("id", script);
     115            var rawSourceCode = new WebInspector.RawSourceCode("id", script);
    116116            function uiSourceCodeAdded(event)
    117117            {
    118118                InspectorTest.assertEquals("foo.js", event.data.url);
    119119            }
    120             sourceFile.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeAdded, uiSourceCodeAdded, this);
     120            rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeAdded, uiSourceCodeAdded, this);
    121121
    122122            next();
  • trunk/Source/WebCore/ChangeLog

    r93974 r93977  
     12011-08-25  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Web Inspector: rename sourceFile to (raw|ui)SourceCode in DebuggerPresentationModel.
     4        https://bugs.webkit.org/show_bug.cgi?id=66769
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * inspector/front-end/DebuggerPresentationModel.js:
     9        (WebInspector.DebuggerPresentationModel):
     10        (WebInspector.DebuggerPresentationModel.prototype.uiSourceCode):
     11        (WebInspector.DebuggerPresentationModel.prototype._scriptLocationToUILocation.didCreateSourceMapping):
     12        (WebInspector.DebuggerPresentationModel.prototype._scriptLocationToUILocation):
     13        (WebInspector.DebuggerPresentationModel.prototype._uiLocationToScriptLocation.didCreateSourceMapping):
     14        (WebInspector.DebuggerPresentationModel.prototype._uiLocationToScriptLocation):
     15        (WebInspector.DebuggerPresentationModel.prototype.linkifyLocation.updateAnchor.didGetLocation):
     16        (WebInspector.DebuggerPresentationModel.prototype.linkifyLocation.updateAnchor):
     17        (WebInspector.DebuggerPresentationModel.prototype.linkifyLocation):
     18        (WebInspector.DebuggerPresentationModel.prototype._addScript.didCreateSourceMapping):
     19        (WebInspector.DebuggerPresentationModel.prototype._addScript):
     20        (WebInspector.DebuggerPresentationModel.prototype._uiSourceCodeReplaced):
     21        (WebInspector.DebuggerPresentationModel.prototype.canEditScriptSource):
     22        (WebInspector.DebuggerPresentationModel.prototype.setScriptSource.didEditScriptSource):
     23        (WebInspector.DebuggerPresentationModel.prototype.setScriptSource):
     24        (WebInspector.DebuggerPresentationModel.prototype._updateBreakpointsAfterLiveEdit):
     25        (WebInspector.DebuggerPresentationModel.prototype.setFormatSourceFiles):
     26        (WebInspector.DebuggerPresentationModel.prototype._addConsoleMessage.didGetUILocation):
     27        (WebInspector.DebuggerPresentationModel.prototype._addConsoleMessage):
     28        (WebInspector.DebuggerPresentationModel.prototype._consoleCleared):
     29        (WebInspector.DebuggerPresentationModel.prototype.continueToLine):
     30        (WebInspector.DebuggerPresentationModel.prototype.breakpointsForSourceFileId):
     31        (WebInspector.DebuggerPresentationModel.prototype.setBreakpoint):
     32        (WebInspector.DebuggerPresentationModel.prototype.setBreakpointEnabled):
     33        (WebInspector.DebuggerPresentationModel.prototype.updateBreakpoint):
     34        (WebInspector.DebuggerPresentationModel.prototype.removeBreakpoint):
     35        (WebInspector.DebuggerPresentationModel.prototype.findBreakpoint):
     36        (WebInspector.DebuggerPresentationModel.prototype._breakpointAdded):
     37        (WebInspector.DebuggerPresentationModel.prototype._breakpointRemoved):
     38        (WebInspector.DebuggerPresentationModel.prototype._debuggerPaused):
     39        (WebInspector.DebuggerPresentationModel.prototype._rawSourceCodeForScript):
     40        (WebInspector.DebuggerPresentationModel.prototype._scriptForRawSourceCode):
     41        (WebInspector.DebuggerPresentationModel.prototype._createRawSourceCodeId):
     42        (WebInspector.DebuggerPresentationModel.prototype._debuggerReset):
     43        (WebInspector.PresentationBreakpoint):
     44        (WebInspector.PresenationCallFrame.prototype.sourceLine.didGetUILocation):
     45        (WebInspector.PresenationCallFrame.prototype.sourceLine):
     46        (WebInspector.DebuggerPresentationModelResourceBinding.prototype.canSetContent):
     47        (WebInspector.DebuggerPresentationModelResourceBinding.prototype.setContent):
     48        (WebInspector.DebuggerPresentationModelResourceBinding.prototype._setContentWithInitialContent):
     49        * inspector/front-end/ScriptsPanel.js:
     50        (WebInspector.ScriptsPanel.prototype.canShowAnchorLocation):
     51        (WebInspector.ScriptsPanel.prototype._createSourceFrame):
     52        (WebInspector.ScriptsPanel.prototype._sourceFrameLoaded):
     53        (WebInspector.ScriptsPanel.prototype._callFrameSelected.didGetSourceLocation):
     54        (WebInspector.ScriptsPanel.prototype._callFrameSelected):
     55        (WebInspector.SourceFrameDelegateForScriptsPanel.prototype.requestContent):
     56        (WebInspector.SourceFrameDelegateForScriptsPanel.prototype.suggestedFileName):
     57        * inspector/front-end/SourceFile.js:
     58        (WebInspector.RawSourceCode.prototype.rawLocationToUILocation):
     59        (WebInspector.UILocation):
     60
    1612011-08-29  Ilya Tikhonovsky  <loislo@chromium.org>
    262
  • trunk/Source/WebCore/inspector/front-end/DebuggerPresentationModel.js

    r93963 r93977  
    3636    // FIXME: apply formatter from outside as a generic mapping.
    3737    this._formatter = new WebInspector.ScriptFormatter();
    38     this._sourceFiles = {};
     38    this._rawSourceCode = {};
    3939    this._messages = [];
    4040    // FIXME: move this to RawSourceCode when it's not re-created in pretty-print mode.
     
    7171
    7272WebInspector.DebuggerPresentationModel.prototype = {
    73     sourceFile: function(sourceFileId)
    74     {
    75         return this._sourceFiles[sourceFileId];
    76     },
    77 
    78     sourceFileForScriptURL: function(scriptURL)
    79     {
    80         return this._sourceFiles[this._createSourceFileId(scriptURL)];
     73    uiSourceCode: function(uiSourceCodeId)
     74    {
     75        // FIXME: get rid of uiSourceCodeId (currently uiSourceCodeId == rawSourceCodeId).
     76        var rawSourceCode = this._rawSourceCode[uiSourceCodeId];
     77        return rawSourceCode && rawSourceCode.uiSourceCode;
    8178    },
    8279
    8380    _scriptLocationToUILocation: function(sourceURL, scriptId, lineNumber, columnNumber, callback)
    8481    {
    85         var sourceFile = this._sourceFileForScript(sourceURL, scriptId);
     82        var rawSourceCode = this._rawSourceCodeForScript(sourceURL, scriptId);
    8683
    8784        function didCreateSourceMapping()
    8885        {
    89             var uiLocation = sourceFile.rawLocationToUILocation({ lineNumber: lineNumber, columnNumber: columnNumber });
    90             callback(uiLocation.sourceFile.id, uiLocation.lineNumber);
     86            var uiLocation = rawSourceCode.rawLocationToUILocation({ lineNumber: lineNumber, columnNumber: columnNumber });
     87            callback(uiLocation.uiSourceCode, uiLocation.lineNumber);
    9188        }
    9289        // FIXME: force source formatting if needed. This will go away once formatting
    9390        // is fully encapsulated in RawSourceCode class.
    94         sourceFile.createSourceMappingIfNeeded(didCreateSourceMapping);
    95     },
    96 
    97     _uiLocationToScriptLocation: function(sourceFileId, lineNumber, callback)
    98     {
    99         var sourceFile = this._sourceFiles[sourceFileId];
     91        rawSourceCode.createSourceMappingIfNeeded(didCreateSourceMapping);
     92    },
     93
     94    _uiLocationToScriptLocation: function(uiSourceCodeId, lineNumber, callback)
     95    {
     96        var rawSourceCode = this.uiSourceCode(uiSourceCodeId).rawSourceCode;
    10097
    10198        function didCreateSourceMapping()
    10299        {
    103             var rawLocation = sourceFile.uiLocationToRawLocation(lineNumber, 0);
     100            var rawLocation = rawSourceCode.uiLocationToRawLocation(lineNumber, 0);
    104101            callback(rawLocation);
    105102        }
    106103        // FIXME: force source formatting if needed. This will go away once formatting
    107104        // is fully encapsulated in RawSourceCode class.
    108         sourceFile.createSourceMappingIfNeeded(didCreateSourceMapping);
    109     },
    110 
    111     requestSourceFileContent: function(sourceFileId, callback)
    112     {
    113         this._sourceFiles[sourceFileId].requestContent(callback);
     105        rawSourceCode.createSourceMappingIfNeeded(didCreateSourceMapping);
    114106    },
    115107
     
    129121        var anchor = WebInspector.linkifyURLAsNode(sourceURL, linkText, classes, false);
    130122
    131         var sourceFile = this._sourceFileForScript(sourceURL);
    132         if (!sourceFile) {
     123        var rawSourceCode = this._rawSourceCodeForScript(sourceURL);
     124        if (!rawSourceCode) {
    133125            anchor.setAttribute("preferred_panel", "resources");
    134126            anchor.setAttribute("line_number", lineNumber);
     
    138130        function updateAnchor()
    139131        {
    140             function didGetLocation(sourceFileId, lineNumber)
     132            function didGetLocation(uiSourceCode, lineNumber)
    141133            {
    142                 anchor.textContent = WebInspector.formatLinkText(sourceFile.url, lineNumber);
     134                anchor.textContent = WebInspector.formatLinkText(uiSourceCode.url, lineNumber);
    143135                anchor.setAttribute("preferred_panel", "scripts");
    144                 anchor.setAttribute("source_file_id", sourceFileId);
     136                anchor.setAttribute("source_file_id", uiSourceCode.id);
    145137                anchor.setAttribute("line_number", lineNumber);
    146138            }
     
    164156    _addScript: function(script)
    165157    {
    166         var sourceFileId = this._createSourceFileId(script.sourceURL, script.scriptId);
    167         var sourceFile = this._sourceFiles[sourceFileId];
    168         if (sourceFile) {
    169             sourceFile.addScript(script);
    170             return;
    171         }
    172 
    173         sourceFile = new WebInspector.RawSourceCode(sourceFileId, script, this._formatter, this._formatSourceFiles);
    174         this._sourceFiles[sourceFileId] = sourceFile;
    175         sourceFile.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeReplaced, this._uiSourceCodeReplaced, this);
     158        var rawSourceCodeId = this._createRawSourceCodeId(script.sourceURL, script.scriptId);
     159        var rawSourceCode = this._rawSourceCode[rawSourceCodeId];
     160        if (rawSourceCode) {
     161            rawSourceCode.addScript(script);
     162            return;
     163        }
     164
     165        rawSourceCode = new WebInspector.RawSourceCode(rawSourceCodeId, script, this._formatter, this._formatSource);
     166        this._rawSourceCode[rawSourceCodeId] = rawSourceCode;
     167        rawSourceCode.addEventListener(WebInspector.RawSourceCode.Events.UISourceCodeReplaced, this._uiSourceCodeReplaced, this);
    176168
    177169        function didCreateSourceMapping()
    178170        {
    179             this._breakpointManager.uiSourceCodeAdded(sourceFile);
    180             var breakpoints = this._breakpointManager.breakpointsForUISourceCode(sourceFileId);
     171            this._breakpointManager.uiSourceCodeAdded(rawSourceCode.uiSourceCode);
     172            var breakpoints = this._breakpointManager.breakpointsForUISourceCode(rawSourceCode.uiSourceCode.id);
    181173            for (var lineNumber in breakpoints) {
    182174                var breakpoint = breakpoints[lineNumber];
     
    186178        // FIXME: force source formatting if needed. This will go away once formatting
    187179        // is fully encapsulated in RawSourceCode class.
    188         sourceFile.createSourceMappingIfNeeded(didCreateSourceMapping.bind(this));
    189 
    190         this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.SourceFileAdded, sourceFile.uiSourceCode);
     180        rawSourceCode.createSourceMappingIfNeeded(didCreateSourceMapping.bind(this));
     181
     182        var uiSourceCode = rawSourceCode.uiSourceCode;
     183        this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.SourceFileAdded, uiSourceCode);
    191184    },
    192185
    193186    _uiSourceCodeReplaced: function(event)
    194187    {
    195         var oldUISourceCode = event.data.oldSourceCode;
    196         var newUISourceCode = event.data.sourceCode;
    197 
    198         delete this._sourceFiles[oldUISourceCode.id];
    199         this._sourceFiles[newUISourceCode.id] = newUISourceCode;
    200 
    201188        // FIXME: restore breakpoints in new source code (currently we just recreate everything when switching to pretty-print mode).
    202189        this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.SourceFileReplaced, event.data);
    203190    },
    204191
    205     canEditScriptSource: function(sourceFileId)
    206     {
    207         if (!Preferences.canEditScriptSource || this._formatSourceFiles)
     192    canEditScriptSource: function(uiSourceCodeId)
     193    {
     194        if (!Preferences.canEditScriptSource || this._formatSource)
    208195            return false;
    209         var script = this._scriptForSourceFileId(sourceFileId);
     196        var rawSourceCode = this.uiSourceCode(uiSourceCodeId).rawSourceCode;
     197        var script = this._scriptForRawSourceCode(rawSourceCode);
    210198        return !script.lineOffset && !script.columnOffset;
    211199    },
    212200
    213     setScriptSource: function(sourceFileId, newSource, callback)
    214     {
    215         var script = this._scriptForSourceFileId(sourceFileId);
    216         var sourceFile = this._sourceFiles[sourceFileId];
    217 
    218         function didEditScriptSource(oldSource, error)
     201    setScriptSource: function(uiSourceCodeId, newSource, callback)
     202    {
     203        var rawSourceCode = this.uiSourceCode(uiSourceCodeId).rawSourceCode;
     204        var script = this._scriptForRawSourceCode(rawSourceCode);
     205
     206        function didEditScriptSource(error)
    219207        {
    220208            if (!error) {
    221                 sourceFile.content = newSource;
    222 
    223                 var resource = WebInspector.resourceForURL(sourceFile.url);
     209                rawSourceCode.content = newSource;
     210
     211                var resource = WebInspector.resourceForURL(rawSourceCode.url);
    224212                if (resource)
    225213                    resource.addRevision(newSource);
     
    231219                this._debuggerPaused();
    232220        }
    233 
    234         var oldSource = sourceFile.requestContent(didReceiveSource.bind(this));
    235         function didReceiveSource(oldSource)
    236         {
    237             WebInspector.debuggerModel.setScriptSource(script.scriptId, newSource, didEditScriptSource.bind(this, oldSource));
    238         }
    239     },
    240 
    241     _updateBreakpointsAfterLiveEdit: function(sourceFileId, oldSource, newSource)
    242     {
    243         var sourceFile = this._sourceFiles[sourceFileId];
     221        WebInspector.debuggerModel.setScriptSource(script.scriptId, newSource, didEditScriptSource.bind(this));
     222    },
     223
     224    _updateBreakpointsAfterLiveEdit: function(uiSourceCodeId, oldSource, newSource)
     225    {
     226        var breakpoints = this._breakpointManager.breakpointsForUISourceCode(uiSourceCodeId);
    244227
    245228        // Clear and re-create breakpoints according to text diff.
    246229        var diff = Array.diff(oldSource.split("\n"), newSource.split("\n"));
    247         for (var lineNumber in sourceFile.breakpoints) {
    248             var breakpoint = sourceFile.breakpoints[lineNumber];
    249 
    250             var lineNumber = breakpoint.lineNumber;
    251             this.removeBreakpoint(sourceFileId, lineNumber);
     230        for (var lineNumber in breakpoints) {
     231            var breakpoint = breakpoints[lineNumber];
     232
     233            this.removeBreakpoint(uiSourceCodeId, lineNumber);
    252234
    253235            var newLineNumber = diff.left[lineNumber].row;
     
    266248            }
    267249            if (newLineNumber !== undefined)
    268                 this.setBreakpoint(sourceFileId, newLineNumber, breakpoint.condition, breakpoint.enabled);
    269         }
    270     },
    271 
    272     setFormatSourceFiles: function(formatSourceFiles)
    273     {
    274         if (this._formatSourceFiles === formatSourceFiles)
    275             return;
    276 
    277         this._formatSourceFiles = formatSourceFiles;
     250                this.setBreakpoint(uiSourceCodeId, newLineNumber, breakpoint.condition, breakpoint.enabled);
     251        }
     252    },
     253
     254    setFormatSourceFiles: function(formatSource)
     255    {
     256        if (this._formatSource === formatSource)
     257            return;
     258
     259        this._formatSource = formatSource;
    278260
    279261        this._breakpointManager.reset();
    280         this._sourceFiles = {};
     262        this._rawSourceCode = {};
    281263        var messages = this._messages;
    282264        this._messages = [];
     
    308290        this._messages.push(message);
    309291
    310         var sourceFile = this._sourceFileForScript(message.url);
    311         if (!sourceFile)
    312             return;
    313 
    314         function didGetUILocation(sourceFileId, lineNumber)
     292        var rawSourceCode = this._rawSourceCodeForScript(message.url);
     293        if (!rawSourceCode)
     294            return;
     295
     296        function didGetUILocation(uiSourceCode, lineNumber)
    315297        {
    316298            var presentationMessage = {};
    317             presentationMessage.sourceFileId = sourceFileId;
     299            presentationMessage.sourceFileId = uiSourceCode.id;
    318300            presentationMessage.lineNumber = lineNumber;
    319301            presentationMessage.originalMessage = message;
    320             sourceFile.messages.push(presentationMessage);
     302            uiSourceCode.messages.push(presentationMessage);
    321303            this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.ConsoleMessageAdded, presentationMessage);
    322304        }
     
    330312    {
    331313        this._messages = [];
    332         for (var id in this._sourceFiles)
    333             this._sourceFiles[id].messages = [];
     314        for (var id in this._rawSourceCode)
     315            this._rawSourceCode[id].messages = [];
    334316        this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.ConsoleMessagesCleared);
    335317    },
    336318
    337     continueToLine: function(sourceFileId, lineNumber)
     319    continueToLine: function(uiSourceCodeId, lineNumber)
    338320    {
    339321        function didGetScriptLocation(location)
     
    341323            WebInspector.debuggerModel.continueToLocation(location);
    342324        }
    343         this._uiLocationToScriptLocation(sourceFileId, lineNumber, didGetScriptLocation);
    344     },
    345 
    346     breakpointsForSourceFileId: function(sourceFileId)
    347     {
    348         var breakpointsMap = this._breakpointManager.breakpointsForUISourceCode(sourceFileId);
     325        this._uiLocationToScriptLocation(uiSourceCodeId, lineNumber, didGetScriptLocation);
     326    },
     327
     328    breakpointsForSourceFileId: function(uiSourceCodeId)
     329    {
     330        var breakpointsMap = this._breakpointManager.breakpointsForUISourceCode(uiSourceCodeId);
    349331        var breakpointsList = [];
    350332        for (var lineNumber in breakpointsMap)
     
    353335    },
    354336
    355     setBreakpoint: function(sourceFileId, lineNumber, condition, enabled)
    356     {
    357         this._breakpointManager.setBreakpoint(this._sourceFiles[sourceFileId], lineNumber, condition, enabled);
    358     },
    359 
    360     setBreakpointEnabled: function(sourceFileId, lineNumber, enabled)
    361     {
    362         var breakpoint = this.findBreakpoint(sourceFileId, lineNumber);
     337    setBreakpoint: function(uiSourceCodeId, lineNumber, condition, enabled)
     338    {
     339        this._breakpointManager.setBreakpoint(this.uiSourceCode(uiSourceCodeId), lineNumber, condition, enabled);
     340    },
     341
     342    setBreakpointEnabled: function(uiSourceCodeId, lineNumber, enabled)
     343    {
     344        var breakpoint = this.findBreakpoint(uiSourceCodeId, lineNumber);
    363345        if (!breakpoint)
    364346            return;
    365         this._breakpointManager.removeBreakpoint(sourceFileId, lineNumber);
    366         this._breakpointManager.setBreakpoint(this._sourceFiles[sourceFileId], lineNumber, breakpoint.condition, enabled);
    367     },
    368 
    369     updateBreakpoint: function(sourceFileId, lineNumber, condition, enabled)
    370     {
    371         this._breakpointManager.removeBreakpoint(sourceFileId, lineNumber);
    372         this._breakpointManager.setBreakpoint(this._sourceFiles[sourceFileId], lineNumber, condition, enabled);
    373     },
    374 
    375     removeBreakpoint: function(sourceFileId, lineNumber)
    376     {
    377         this._breakpointManager.removeBreakpoint(sourceFileId, lineNumber);
    378     },
    379 
    380     findBreakpoint: function(sourceFileId, lineNumber)
    381     {
    382         return this._breakpointManager.breakpointsForUISourceCode(sourceFileId)[lineNumber];
    383     },
    384 
    385     _breakpointAdded: function(sourceFileId, lineNumber, condition, enabled)
    386     {
    387         var sourceFile = this._sourceFiles[sourceFileId];
    388         if (!sourceFile)
    389             return;
    390         var presentationBreakpoint = new WebInspector.PresentationBreakpoint(sourceFile, lineNumber, condition, enabled);
     347        this._breakpointManager.removeBreakpoint(uiSourceCodeId, lineNumber);
     348        this._breakpointManager.setBreakpoint(this.uiSourceCode(uiSourceCodeId), lineNumber, breakpoint.condition, enabled);
     349    },
     350
     351    updateBreakpoint: function(uiSourceCodeId, lineNumber, condition, enabled)
     352    {
     353        this._breakpointManager.removeBreakpoint(uiSourceCodeId, lineNumber);
     354        this._breakpointManager.setBreakpoint(this.uiSourceCode(uiSourceCodeId), lineNumber, condition, enabled);
     355    },
     356
     357    removeBreakpoint: function(uiSourceCodeId, lineNumber)
     358    {
     359        this._breakpointManager.removeBreakpoint(uiSourceCodeId, lineNumber);
     360    },
     361
     362    findBreakpoint: function(uiSourceCodeId, lineNumber)
     363    {
     364        return this._breakpointManager.breakpointsForUISourceCode(uiSourceCodeId)[lineNumber];
     365    },
     366
     367    _breakpointAdded: function(uiSourceCodeId, lineNumber, condition, enabled)
     368    {
     369        var uiSourceCode = this.uiSourceCode(uiSourceCodeId);
     370        if (!uiSourceCode)
     371            return;
     372        var presentationBreakpoint = new WebInspector.PresentationBreakpoint(uiSourceCode, lineNumber, condition, enabled);
    391373        this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.BreakpointAdded, presentationBreakpoint);
    392374    },
    393375
    394     _breakpointRemoved: function(sourceFileId, lineNumber)
    395     {
    396         this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.BreakpointRemoved, { sourceFileId: sourceFileId, lineNumber: lineNumber });
     376    _breakpointRemoved: function(uiSourceCodeId, lineNumber)
     377    {
     378        this.dispatchEventToListeners(WebInspector.DebuggerPresentationModel.Events.BreakpointRemoved, { sourceFileId: uiSourceCodeId, lineNumber: lineNumber });
    397379    },
    398380
     
    403385        for (var i = 0; i < callFrames.length; ++i) {
    404386            var callFrame = callFrames[i];
    405             var sourceFile;
     387            var rawSourceCode;
    406388            var script = WebInspector.debuggerModel.scriptForSourceID(callFrame.location.scriptId);
    407389            if (script)
    408                 sourceFile = this._sourceFileForScript(script.sourceURL, script.scriptId);
    409             this._presentationCallFrames.push(new WebInspector.PresenationCallFrame(callFrame, i, this, sourceFile));
     390                rawSourceCode = this._rawSourceCodeForScript(script.sourceURL, script.scriptId);
     391            this._presentationCallFrames.push(new WebInspector.PresenationCallFrame(callFrame, i, this, rawSourceCode));
    410392        }
    411393        var details = WebInspector.debuggerModel.debuggerPausedDetails;
     
    434416    },
    435417
    436     _sourceFileForScript: function(sourceURL, scriptId)
     418    _rawSourceCodeForScript: function(sourceURL, scriptId)
    437419    {
    438420        if (!sourceURL) {
     
    442424            sourceURL = script.sourceURL;
    443425        }
    444         return this._sourceFiles[this._createSourceFileId(sourceURL, scriptId)];
    445     },
    446 
    447     _scriptForSourceFileId: function(sourceFileId)
     426        return this._rawSourceCode[this._createRawSourceCodeId(sourceURL, scriptId)];
     427    },
     428
     429    _scriptForRawSourceCode: function(rawSourceCode)
    448430    {
    449431        function filter(script)
    450432        {
    451             return this._createSourceFileId(script.sourceURL, script.scriptId) === sourceFileId;
     433            return this._createRawSourceCodeId(script.sourceURL, script.scriptId) === rawSourceCode.id;
    452434        }
    453435        return WebInspector.debuggerModel.queryScripts(filter.bind(this))[0];
    454436    },
    455437
    456     _createSourceFileId: function(sourceURL, scriptId)
    457     {
    458         var prefix = this._formatSourceFiles ? "deobfuscated:" : "";
     438    _createRawSourceCodeId: function(sourceURL, scriptId)
     439    {
     440        var prefix = this._formatSource ? "deobfuscated:" : "";
    459441        return prefix + (sourceURL || scriptId);
    460442    },
     
    462444    _debuggerReset: function()
    463445    {
    464         this._sourceFiles = {};
     446        this._rawSourceCode = {};
    465447        this._messages = [];
    466448        this._sourceMappingListeners = [];
     
    476458 * @constructor
    477459 */
    478 WebInspector.PresentationBreakpoint = function(sourceFile, lineNumber, condition, enabled)
     460WebInspector.PresentationBreakpoint = function(uiSourceCode, lineNumber, condition, enabled)
    479461{
    480     this.sourceFile = sourceFile;
    481     this.sourceFileId = sourceFile.id;
     462    this.sourceFile = uiSourceCode;
     463    this.sourceFileId = uiSourceCode.id;
    482464    this.lineNumber = lineNumber;
    483465    this.condition = condition;
     
    590572    {
    591573        var location = this._callFrame.location;
    592         if (!this.isInternalScript)
    593             this._model._scriptLocationToUILocation(null, location.scriptId, location.lineNumber, location.columnNumber, callback);
    594         else
     574        if (!this.isInternalScript) {
     575            function didGetUILocation(uiSourceCode, lineNumber)
     576            {
     577                callback(uiSourceCode.id, lineNumber);
     578            }
     579            this._model._scriptLocationToUILocation(null, location.scriptId, location.lineNumber, location.columnNumber, didGetUILocation);
     580        } else
    595581            callback(undefined, location.lineNumber);
    596582    }
     
    610596    canSetContent: function(resource)
    611597    {
    612         var sourceFile = this._presentationModel._sourceFileForScript(resource.url)
    613         if (!sourceFile)
     598        var rawSourceCode = this._presentationModel._rawSourceCodeForScript(resource.url)
     599        if (!rawSourceCode)
    614600            return false;
    615         return this._presentationModel.canEditScriptSource(sourceFile.id);
     601        return this._presentationModel.canEditScriptSource(rawSourceCode.id);
    616602    },
    617603
     
    621607            return;
    622608
    623         var sourceFile = this._presentationModel._sourceFileForScript(resource.url);
    624         if (!sourceFile) {
     609        var rawSourceCode = this._presentationModel._rawSourceCodeForScript(resource.url);
     610        if (!rawSourceCode) {
    625611            userCallback("Resource is not editable");
    626612            return;
    627613        }
    628614
    629         resource.requestContent(this._setContentWithInitialContent.bind(this, sourceFile, content, userCallback));
    630     },
    631 
    632     _setContentWithInitialContent: function(sourceFile, content, userCallback, oldContent)
     615        resource.requestContent(this._setContentWithInitialContent.bind(this, rawSourceCode, content, userCallback));
     616    },
     617
     618    _setContentWithInitialContent: function(rawSourceCode, content, userCallback, oldContent)
    633619    {
    634620        function callback(error)
     
    637623                userCallback(error);
    638624            if (!error) {
    639                 this._presentationModel._updateBreakpointsAfterLiveEdit(sourceFile.id, oldContent, content);
    640                 sourceFile.reload();
     625                this._presentationModel._updateBreakpointsAfterLiveEdit(rawSourceCode.id, oldContent, content);
     626                rawSourceCode.reload();
    641627            }
    642628        }
    643         this._presentationModel.setScriptSource(sourceFile.id, content, callback.bind(this));
     629        this._presentationModel.setScriptSource(rawSourceCode.id, content, callback.bind(this));
    644630    }
    645631}
  • trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js

    r93701 r93977  
    598598    canShowAnchorLocation: function(anchor)
    599599    {
    600         return this._debuggerEnabled && this._presentationModel.sourceFileForScriptURL(anchor.href);
     600        return this._debuggerEnabled && WebInspector.debuggerModel.scriptsForURL(anchor.href).length;
    601601    },
    602602
     
    645645        this.visibleView = sourceFrame;
    646646
    647         var sourceFile = this._presentationModel.sourceFile(sourceFileId);
     647        var sourceFile = this._presentationModel.uiSourceCode(sourceFileId);
    648648        if (sourceFile.url)
    649649            WebInspector.settings.lastViewedScriptFile.set(sourceFile.url);
     
    660660    _createSourceFrame: function(sourceFileId)
    661661    {
    662         var sourceFile = this._presentationModel.sourceFile(sourceFileId);
     662        var sourceFile = this._presentationModel.uiSourceCode(sourceFileId);
    663663        var delegate = new WebInspector.SourceFrameDelegateForScriptsPanel(this._presentationModel, sourceFileId);
    664664        var sourceFrame = new WebInspector.SourceFrame(delegate, sourceFile.url);
     
    701701        var sourceFrame = event.target;
    702702        var sourceFileId = sourceFrame._sourceFileId;
    703         var sourceFile = this._presentationModel.sourceFile(sourceFileId);
     703        var sourceFile = this._presentationModel.uiSourceCode(sourceFileId);
    704704
    705705        var messages = sourceFile.messages;
     
    743743            if (!(sourceFileId in this._sourceFileIdToFilesSelectOption)) {
    744744                // Anonymous scripts are not added to files select by default.
    745                 var sourceFile = this._presentationModel.sourceFile(sourceFileId);
     745                var sourceFile = this._presentationModel.uiSourceCode(sourceFileId);
    746746                this._addOptionToFilesSelect(sourceFile);
    747747            }
     
    11891189    requestContent: function(callback)
    11901190    {
    1191         this._model.requestSourceFileContent(this._sourceFileId, callback);
     1191        this._model.uiSourceCode(this._sourceFileId).requestContent(callback);
    11921192    },
    11931193
     
    12571257    suggestedFileName: function()
    12581258    {
    1259         var sourceFile = this._model.sourceFile(this._sourceFileId);
     1259        var sourceFile = this._model.uiSourceCode(this._sourceFileId);
    12601260        var names = WebInspector.panels.scripts._folderAndDisplayNameForScriptURL(sourceFile.url);
    12611261        return names.displayName || "untitled.js";
  • trunk/Source/WebCore/inspector/front-end/SourceFile.js

    r93972 r93977  
    7979    rawLocationToUILocation: function(rawLocation)
    8080    {
    81         var uiLocation = this._mapping ? this._mapping.originalToFormatted(rawLocation) : rawLocation;
    82         uiLocation.sourceFile = this;
    83         return uiLocation;
     81        var location = this._mapping ? this._mapping.originalToFormatted(rawLocation) : rawLocation;
     82        return new WebInspector.UILocation(this, location.lineNumber, location.columnNumber);
    8483    },
    8584
     
    244243
    245244WebInspector.RawSourceCode.prototype.__proto__ = WebInspector.Object.prototype;
     245
     246
     247/**
     248 * @constructor
     249 */
     250WebInspector.UILocation = function(uiSourceCode, lineNumber, columnNumber)
     251{
     252    this.uiSourceCode = uiSourceCode;
     253    this.lineNumber = lineNumber;
     254    this.columnNumber = columnNumber;
     255}
    246256
    247257
Note: See TracChangeset for help on using the changeset viewer.