Changeset 87383 in webkit


Ignore:
Timestamp:
May 26, 2011 7:28:04 AM (13 years ago)
Author:
yurys@chromium.org
Message:

2011-05-26 Vsevolod Vlasov <vsevik@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: Use different SourceFrame instances for ResourcesPanel and NetworkPanel
https://bugs.webkit.org/show_bug.cgi?id=59193

  • inspector/debugger/source-frame.html:

2011-05-26 Vsevolod Vlasov <vsevik@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: Use different SourceFrame instances for ResourcesPanel and NetworkPanel
https://bugs.webkit.org/show_bug.cgi?id=59193

  • inspector/front-end/NetworkItemView.js: (WebInspector.NetworkItemView): (WebInspector.NetworkItemView._contentViewForResource):
  • inspector/front-end/NetworkPanel.js: (WebInspector.NetworkPanel.prototype._refreshResource):
  • inspector/front-end/Resource.js: (WebInspector.Resource.prototype.get messages): (WebInspector.Resource.prototype.addMessage): (WebInspector.Resource.prototype.set errors): (WebInspector.Resource.prototype.set warnings): (WebInspector.Resource.prototype.clearErrorsAndWarnings):
  • inspector/front-end/ResourceTreeModel.js: (WebInspector.ResourceTreeModel.prototype._consoleMessageAdded):
  • inspector/front-end/ResourceView.js: (WebInspector.ResourceView.hasTextContent): (WebInspector.ResourceView.nonSourceViewForResource): (WebInspector.ResourceSourceFrame): (WebInspector.ResourceSourceFrame.mimeTypeForResource): (WebInspector.ResourceSourceFrame.prototype.requestContent): (WebInspector.ResourceSourceFrame.prototype.suggestedFileName): (WebInspector.EditableResourceSourceFrame): (WebInspector.EditableResourceSourceFrame.prototype.doubleClick): (WebInspector.EditableResourceSourceFrame.prototype.editContent): (WebInspector.EditableResourceSourceFrame.prototype.cancelEditing): (WebInspector.EditableResourceSourceFrame.prototype.afterTextChanged): (WebInspector.EditableResourceSourceFrame.prototype._clearIncrementalUpdateTimer): (WebInspector.ResourceRevisionSourceFrame): (WebInspector.ResourceRevisionSourceFrame.prototype.requestContent):
  • inspector/front-end/ResourcesPanel.js: (WebInspector.ResourcesPanel.prototype.showResource): (WebInspector.ResourcesPanel.prototype._showResourceView): (WebInspector.ResourcesPanel.prototype._resourceViewForResource): (WebInspector.ResourcesPanel.prototype._showRevisionView): (WebInspector.ResourcesPanel.prototype._sourceViewForRevision): (WebInspector.ResourcesPanel.prototype.searchCanceled): (WebInspector.ResourcesPanel.prototype._findTreeElementForRevision): (WebInspector.ResourcesPanel.prototype._findTreeElementForRevision.getParent): (WebInspector.FrameResourceTreeElement): (WebInspector.FrameResourceTreeElement.prototype.onattach): (WebInspector.FrameResourceTreeElement.prototype._updateErrorsAndWarningsBubbles): (WebInspector.FrameResourceTreeElement.prototype._errorsWarningsCleared): (WebInspector.FrameResourceTreeElement.prototype._errorsWarningsMessageAdded): (WebInspector.FrameResourceTreeElement.prototype._appendRevision): (WebInspector.FrameResourceTreeElement.prototype.sourceView): (WebInspector.FrameResourceTreeElement.prototype._createSourceView): (WebInspector.FrameResourceTreeElement.prototype._recreateSourceView): (WebInspector.ResourceRevisionTreeElement): (WebInspector.ResourceRevisionTreeElement.prototype._handleContextMenuEvent): (WebInspector.ResourceRevisionTreeElement.prototype.sourceView):
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r87382 r87383  
     12011-05-26  Vsevolod Vlasov  <vsevik@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: Use different SourceFrame instances for ResourcesPanel and NetworkPanel
     6        https://bugs.webkit.org/show_bug.cgi?id=59193
     7
     8        * inspector/debugger/source-frame.html:
     9
    1102011-05-26  Philippe Normand  <pnormand@igalia.com>
    211
  • trunk/LayoutTests/inspector/debugger/source-frame.html

    r83577 r87383  
    3434        function testConsoleMessage(next)
    3535        {
    36               InspectorTest.addSniffer(WebInspector.SourceFrame.prototype, "addMessage", didAddMessage);
     36              InspectorTest.addSniffer(WebInspector.Resource.prototype, "addMessage", didAddMessage);
    3737              InspectorTest.evaluateInPage("addErrorToConsole()");
    3838
  • trunk/Source/WebCore/ChangeLog

    r87374 r87383  
     12011-05-26  Vsevolod Vlasov  <vsevik@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: Use different SourceFrame instances for ResourcesPanel and NetworkPanel
     6        https://bugs.webkit.org/show_bug.cgi?id=59193
     7
     8        * inspector/front-end/NetworkItemView.js:
     9        (WebInspector.NetworkItemView):
     10        (WebInspector.NetworkItemView._contentViewForResource):
     11        * inspector/front-end/NetworkPanel.js:
     12        (WebInspector.NetworkPanel.prototype._refreshResource):
     13        * inspector/front-end/Resource.js:
     14        (WebInspector.Resource.prototype.get messages):
     15        (WebInspector.Resource.prototype.addMessage):
     16        (WebInspector.Resource.prototype.set errors):
     17        (WebInspector.Resource.prototype.set warnings):
     18        (WebInspector.Resource.prototype.clearErrorsAndWarnings):
     19        * inspector/front-end/ResourceTreeModel.js:
     20        (WebInspector.ResourceTreeModel.prototype._consoleMessageAdded):
     21        * inspector/front-end/ResourceView.js:
     22        (WebInspector.ResourceView.hasTextContent):
     23        (WebInspector.ResourceView.nonSourceViewForResource):
     24        (WebInspector.ResourceSourceFrame):
     25        (WebInspector.ResourceSourceFrame.mimeTypeForResource):
     26        (WebInspector.ResourceSourceFrame.prototype.requestContent):
     27        (WebInspector.ResourceSourceFrame.prototype.suggestedFileName):
     28        (WebInspector.EditableResourceSourceFrame):
     29        (WebInspector.EditableResourceSourceFrame.prototype.doubleClick):
     30        (WebInspector.EditableResourceSourceFrame.prototype.editContent):
     31        (WebInspector.EditableResourceSourceFrame.prototype.cancelEditing):
     32        (WebInspector.EditableResourceSourceFrame.prototype.afterTextChanged):
     33        (WebInspector.EditableResourceSourceFrame.prototype._clearIncrementalUpdateTimer):
     34        (WebInspector.ResourceRevisionSourceFrame):
     35        (WebInspector.ResourceRevisionSourceFrame.prototype.requestContent):
     36        * inspector/front-end/ResourcesPanel.js:
     37        (WebInspector.ResourcesPanel.prototype.showResource):
     38        (WebInspector.ResourcesPanel.prototype._showResourceView):
     39        (WebInspector.ResourcesPanel.prototype._resourceViewForResource):
     40        (WebInspector.ResourcesPanel.prototype._showRevisionView):
     41        (WebInspector.ResourcesPanel.prototype._sourceViewForRevision):
     42        (WebInspector.ResourcesPanel.prototype.searchCanceled):
     43        (WebInspector.ResourcesPanel.prototype._findTreeElementForRevision):
     44        (WebInspector.ResourcesPanel.prototype._findTreeElementForRevision.getParent):
     45        (WebInspector.FrameResourceTreeElement):
     46        (WebInspector.FrameResourceTreeElement.prototype.onattach):
     47        (WebInspector.FrameResourceTreeElement.prototype._updateErrorsAndWarningsBubbles):
     48        (WebInspector.FrameResourceTreeElement.prototype._errorsWarningsCleared):
     49        (WebInspector.FrameResourceTreeElement.prototype._errorsWarningsMessageAdded):
     50        (WebInspector.FrameResourceTreeElement.prototype._appendRevision):
     51        (WebInspector.FrameResourceTreeElement.prototype.sourceView):
     52        (WebInspector.FrameResourceTreeElement.prototype._createSourceView):
     53        (WebInspector.FrameResourceTreeElement.prototype._recreateSourceView):
     54        (WebInspector.ResourceRevisionTreeElement):
     55        (WebInspector.ResourceRevisionTreeElement.prototype._handleContextMenuEvent):
     56        (WebInspector.ResourceRevisionTreeElement.prototype.sourceView):
     57
    1582011-05-26  Andreas Kling  <kling@webkit.org>
    259
  • trunk/Source/WebCore/inspector/front-end/NetworkItemView.js

    r84492 r87383  
    3636
    3737    this._headersView = new WebInspector.ResourceHeadersView(resource);
    38     // Do not store reference to content view - it can be recreated.
    39     var contentView = WebInspector.ResourceView.resourceViewForResource(resource);
    40 
    4138    this._tabbedPane = new WebInspector.TabbedPane(this.element);
    4239    this._tabbedPane.appendTab("headers", WebInspector.UIString("Headers"), this._headersView);
    4340
    44     if (contentView.hasContent()) {
    45         // Reusing this view, so hide it at first.
    46         contentView.visible = false;
     41    var contentView = WebInspector.NetworkItemView._contentViewForResource(resource);
     42    if (contentView.hasContent())
    4743        this._tabbedPane.appendTab("content", WebInspector.UIString("Content"), contentView);
    48     }
    4944
    5045    if (resource.type === WebInspector.Resource.Type.XHR && resource.content) {
     
    6762
    6863    this._tabbedPane.addEventListener("tab-selected", this._tabSelected, this);
     64}
     65
     66WebInspector.NetworkItemView._contentViewForResource = function(resource)
     67{
     68    if (WebInspector.ResourceView.hasTextContent(resource))
     69        return new WebInspector.ResourceSourceFrame(resource)
     70    return WebInspector.ResourceView.nonSourceViewForResource(resource);
    6971}
    7072
  • trunk/Source/WebCore/inspector/front-end/NetworkPanel.js

    r86959 r87383  
    792792        this._staleResources.push(resource);
    793793        this._scheduleRefresh();
    794 
    795         var oldView = WebInspector.ResourceView.existingResourceViewForResource(resource);
    796         if (!oldView)
    797             return;
    798 
    799         if (WebInspector.ResourceView.resourceViewTypeMatchesResource(resource))
    800             return;
    801 
    802         var newView = WebInspector.ResourceView.recreateResourceView(resource);
    803         if (this.visibleView === oldView)
    804             this.visibleView = newView;
    805794    },
    806795
  • trunk/Source/WebCore/inspector/front-end/Resource.js

    r87073 r87383  
    694694    },
    695695
     696    get messages()
     697    {
     698        return this._messages || [];
     699    },
     700
     701    addMessage: function(msg)
     702    {
     703        if (!msg.isErrorOrWarning() || !msg.message)
     704            return;
     705
     706        if (!this._messages)
     707            this._messages = [];
     708        this._messages.push(msg);
     709        this.dispatchEventToListeners("errors-warnings-message-added", msg);
     710    },
     711
    696712    get errors()
    697713    {
     
    702718    {
    703719        this._errors = x;
    704         this.dispatchEventToListeners("errors-warnings-updated");
    705720    },
    706721
     
    713728    {
    714729        this._warnings = x;
    715         this.dispatchEventToListeners("errors-warnings-updated");
    716730    },
    717731
    718732    clearErrorsAndWarnings: function()
    719733    {
     734        this._messages = [];
    720735        this._warnings = 0;
    721736        this._errors = 0;
    722         this.dispatchEventToListeners("errors-warnings-updated");
     737        this.dispatchEventToListeners("errors-warnings-cleared");
    723738    },
    724739
  • trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js

    r86760 r87383  
    232232            break;
    233233        }
    234 
    235         var view = WebInspector.ResourceView.resourceViewForResource(resource);
    236         if (view.addMessage && msg.isErrorOrWarning() && msg.message)
    237             view.addMessage(msg);
     234        resource.addMessage(msg);
    238235    },
    239236
  • trunk/Source/WebCore/inspector/front-end/ResourceView.js

    r86552 r87383  
    4444WebInspector.ResourceView.prototype.__proto__ = WebInspector.View.prototype;
    4545
    46 WebInspector.ResourceView.createResourceView = function(resource)
     46WebInspector.ResourceView.hasTextContent = function(resource)
    4747{
    4848    switch (resource.category) {
     
    5151    case WebInspector.resourceCategories.xhr:
    5252    case WebInspector.resourceCategories.stylesheets:
    53         return new WebInspector.ResourceSourceFrame(resource);
     53        return true;
     54    default:
     55        return false;
     56    }
     57}
     58
     59WebInspector.ResourceView.nonSourceViewForResource = function(resource)
     60{
     61    switch (resource.category) {
    5462    case WebInspector.resourceCategories.images:
    5563        return new WebInspector.ImageView(resource);
     
    6169}
    6270
    63 WebInspector.ResourceView.resourceViewTypeMatchesResource = function(resource)
    64 {
    65     var resourceView = resource._resourceView;
    66     switch (resource.category) {
    67     case WebInspector.resourceCategories.documents:
    68     case WebInspector.resourceCategories.scripts:
    69     case WebInspector.resourceCategories.xhr:
    70     case WebInspector.resourceCategories.stylesheets:
    71         return resourceView.__proto__ === WebInspector.ResourceSourceFrame.prototype;
    72     case WebInspector.resourceCategories.images:
    73         return resourceView.__proto__ === WebInspector.ImageView.prototype;
    74     case WebInspector.resourceCategories.fonts:
    75         return resourceView.__proto__ === WebInspector.FontView.prototype;
    76     default:
    77         return resourceView.__proto__ === WebInspector.ResourceView.prototype;
    78     }
    79 }
    80 
    81 WebInspector.ResourceView.resourceViewForResource = function(resource)
    82 {
    83     if (!resource)
    84         return null;
    85     if (!resource._resourceView)
    86         resource._resourceView = WebInspector.ResourceView.createResourceView(resource);
    87     return resource._resourceView;
    88 }
    89 
    90 WebInspector.ResourceView.recreateResourceView = function(resource)
    91 {
    92     var newView = WebInspector.ResourceView.createResourceView(resource);
    93 
    94     var oldView = resource._resourceView;
    95     var oldViewParentNode = oldView.visible ? oldView.element.parentNode : null;
    96     var scrollTop = oldView.scrollTop;
    97 
    98     resource._resourceView.detach();
    99     delete resource._resourceView;
    100 
    101     resource._resourceView = newView;
    102 
    103     if (oldViewParentNode)
    104         newView.show(oldViewParentNode);
    105     if (scrollTop)
    106         newView.scrollTop = scrollTop;
    107 
    108     return newView;
    109 }
    110 
    111 WebInspector.ResourceView.existingResourceViewForResource = function(resource)
    112 {
    113     if (!resource)
    114         return null;
    115     return resource._resourceView;
    116 }
    117 
    118 
    11971WebInspector.ResourceSourceFrame = function(resource)
    12072{
    121     WebInspector.SourceFrame.call(this, new WebInspector.SourceFrameDelegate(), resource.url);
     73    WebInspector.SourceFrame.call(this, new WebInspector.SourceFrameDelegate(resource), resource.url);
    12274    this._resource = resource;
    12375}
     
    13183}
    13284
     85WebInspector.ResourceSourceFrame.mimeTypeForResource = function(resource) {
     86    return WebInspector.ResourceSourceFrame.DefaultMIMETypeForResourceType[resource.type] || resource.mimeType;
     87}
     88
    13389WebInspector.ResourceSourceFrame.prototype = {
    13490    get resource()
     
    13793    },
    13894
     95    requestContent: function(callback)
     96    {
     97        function contentLoaded(text)
     98        {
     99            var mimeType = WebInspector.ResourceSourceFrame.mimeTypeForResource(this.resource);
     100            callback(mimeType, text);
     101        }
     102       
     103        this.resource.requestContent(contentLoaded.bind(this));
     104    },
     105
     106    suggestedFileName: function()
     107    {
     108        return this.resource.displayName;
     109    }
     110}
     111
     112WebInspector.ResourceSourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype;
     113
     114WebInspector.EditableResourceSourceFrame = function(resource)
     115{
     116    WebInspector.ResourceSourceFrame.call(this, resource);
     117}
     118
     119WebInspector.EditableResourceSourceFrame.prototype = {
    139120    doubleClick: function(lineNumber)
    140121    {
    141         if (!this._resource.isEditable())
     122        if (!this.resource.isEditable())
    142123            return;
    143124
     
    153134        this._clearIncrementalUpdateTimer();
    154135        var majorChange = true;
    155         this._resource.setContent(newText, majorChange, callback);
     136        this.resource.setContent(newText, majorChange, callback);
    156137    },
    157138
     
    160141        this._clearIncrementalUpdateTimer();
    161142        const majorChange = false;
    162         this._resource.setContent(this._viewerState.textModelContent, majorChange);
     143        this.resource.setContent(this._viewerState.textModelContent, majorChange);
    163144        WebInspector.SourceFrame.prototype.cancelEditing.call(this);
    164145    },
     
    169150        {
    170151            var majorChange = false;
    171             this._resource.setContent(this._textModel.text, majorChange, function() {});
     152            this.resource.setContent(this._textModel.text, majorChange, function() {});
    172153        }
    173154        const updateTimeout = 200;
     
    181162        delete this._incrementalUpdateTimer;
    182163    },
    183 
    184     requestContent: function(callback)
    185     {
    186         function contentLoaded(text)
    187         {
    188             var mimeType = WebInspector.ResourceSourceFrame.DefaultMIMETypeForResourceType[this._resource.type] || this._resource.mimeType;
    189             callback(mimeType, text);
    190         }
    191         this._resource.requestContent(contentLoaded.bind(this));
    192     },
    193 
    194     suggestedFileName: function()
    195     {
    196         return this._resource.displayName;
    197     }
    198164}
    199165
    200 WebInspector.ResourceSourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype;
     166WebInspector.EditableResourceSourceFrame.prototype.__proto__ = WebInspector.ResourceSourceFrame.prototype;
    201167
    202 WebInspector.RevisionSourceFrame = function(revision)
     168WebInspector.ResourceRevisionSourceFrame = function(revision)
    203169{
    204     WebInspector.SourceFrame.call(this, new WebInspector.SourceFrameDelegate(), revision.resource.url);
     170    WebInspector.ResourceSourceFrame.call(this, revision.resource);
    205171    this._revision = revision;
    206172}
    207173
    208 WebInspector.RevisionSourceFrame.prototype = {
     174WebInspector.ResourceRevisionSourceFrame.prototype = {
    209175    get resource()
    210176    {
    211177        return this._revision.resource;
    212     },
    213 
    214     doubleClick: function(lineNumber)
    215     {
    216178    },
    217179
     
    220182        function contentLoaded(text)
    221183        {
    222             var mimeType = WebInspector.ResourceSourceFrame.DefaultMIMETypeForResourceType[this._revision.resource.type] || this._revision.resource.mimeType;
     184            var mimeType = WebInspector.ResourceSourceFrame.mimeTypeForResource(this.resource);
    223185            callback(mimeType, text);
    224186        }
     187
    225188        this._revision.requestContent(contentLoaded.bind(this));
    226189    },
    227 
    228     suggestedFileName: function()
    229     {
    230         return this._revision.resource.displayName;
    231     }
    232190}
    233191
    234 WebInspector.RevisionSourceFrame.prototype.__proto__ = WebInspector.SourceFrame.prototype;
     192WebInspector.ResourceRevisionSourceFrame.prototype.__proto__ = WebInspector.ResourceSourceFrame.prototype;
  • trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js

    r86745 r87383  
    364364
    365365        if (line !== undefined) {
    366             var view = WebInspector.ResourceView.resourceViewForResource(resource);
     366            var view = this._resourceViewForResource(resource);
    367367            if (view.highlightLine)
    368368                view.highlightLine(line);
     
    373373    _showResourceView: function(resource)
    374374    {
    375         var view = WebInspector.ResourceView.resourceViewForResource(resource);
    376         // FIXME: This could be removed once we stop caching SourceFrames.       
     375        var view = this._resourceViewForResource(resource);
     376        if (!view) {
     377            this.visibleView.hide();
     378            return;
     379        }
    377380        if (view.searchCanceled)
    378381            view.searchCanceled();
     
    381384    },
    382385
     386    _resourceViewForResource: function(resource)
     387    {
     388        if (WebInspector.ResourceView.hasTextContent(resource)) {
     389            var treeElement = this._findTreeElementForResource(resource);
     390            if (!treeElement)
     391                return null;
     392            return treeElement.sourceView();
     393        }
     394        return WebInspector.ResourceView.nonSourceViewForResource(resource);
     395    },
     396
    383397    _showRevisionView: function(revision)
    384398    {
    385         if (!revision._view)
    386             revision._view = new WebInspector.RevisionSourceFrame(revision);
    387         var view = revision._view;
     399        var view = this._sourceViewForRevision(revision);
    388400        this._fetchAndApplyDiffMarkup(view, revision.resource, revision);
    389401        this._innerShowView(view);
     402    },
     403
     404    _sourceViewForRevision: function(revision)
     405    {
     406        var treeElement = this._findTreeElementForRevision(revision);
     407        return treeElement.sourceView();
    390408    },
    391409
     
    789807    searchCanceled: function()
    790808    {
     809        function callback(resourceTreeElement)
     810        {
     811            resourceTreeElement._updateErrorsAndWarningsBubbles();
     812        }
     813
    791814        WebInspector.searchController.updateSearchMatchesCount(0, this);
    792815        this._resetSearchResults();
     816        this._forAllResourceTreeElements(callback);
    793817    },
    794818
     
    835859
    836860        return this.sidebarTree.findTreeElement(resource, isAncestor, getParent);
     861    },
     862
     863    _findTreeElementForRevision: function(revision)
     864    {
     865        function isAncestor(ancestor, object)
     866        {
     867            return false;
     868        }
     869
     870        function getParent(object)
     871        {
     872            return null;
     873        }
     874
     875        return this.sidebarTree.findTreeElement(revision, isAncestor, getParent);
    837876    },
    838877
     
    11481187    WebInspector.BaseStorageTreeElement.call(this, storagePanel, resource, resource.displayName, ["resource-sidebar-tree-item", "resources-category-" + resource.category.name]);
    11491188    this._resource = resource;
    1150     this._resource.addEventListener("errors-warnings-updated", this._errorsWarningsUpdated, this);
     1189    this._resource.addEventListener("errors-warnings-cleared", this._errorsWarningsCleared, this);
     1190    this._resource.addEventListener("errors-warnings-message-added", this._errorsWarningsMessageAdded, this);
    11511191    this._resource.addEventListener(WebInspector.Resource.Events.RevisionAdded, this._revisionAdded, this);
    11521192    this.tooltip = resource.url;
     
    11921232        this.listItemElement.addEventListener("dragstart", this._ondragstart.bind(this), false);
    11931233        this.listItemElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
     1234
     1235        this._updateErrorsAndWarningsBubbles();
    11941236    },
    11951237
     
    12781320    },
    12791321
    1280     _errorsWarningsUpdated: function()
    1281     {
    1282         // FIXME: move to the SourceFrame.
    1283         if (!this._resource.warnings && !this._resource.errors) {
    1284             var view = WebInspector.ResourceView.existingResourceViewForResource(this._resource);
    1285             if (view && view.clearMessages)
    1286                 view.clearMessages();
    1287         }
    1288 
     1322    _updateErrorsAndWarningsBubbles: function()
     1323    {
    12891324        if (this._storagePanel.currentQuery)
    12901325            return;
     
    13011336            this._bubbleElement.addStyleClass("error");
    13021337    },
     1338   
     1339    _errorsWarningsCleared: function()
     1340    {
     1341        // FIXME: move to the SourceFrame.
     1342        if (this._sourceView)
     1343            this._sourceView.clearMessages();
     1344       
     1345        this._updateErrorsAndWarningsBubbles();
     1346    },
     1347   
     1348    _errorsWarningsMessageAdded: function(event)
     1349    {
     1350        var msg = event.data;
     1351
     1352        if (this._sourceView)
     1353            this._sourceView.addMessage(msg);
     1354       
     1355        this._updateErrorsAndWarningsBubbles();
     1356    },
    13031357
    13041358    _populateRevisions: function()
     
    13161370    {
    13171371        this.insertChild(new WebInspector.ResourceRevisionTreeElement(this._storagePanel, revision), 0);
    1318         var oldView = WebInspector.ResourceView.existingResourceViewForResource(this._resource);
     1372        var oldView = this._sourceView;
    13191373        if (oldView) {
    1320             var newView = WebInspector.ResourceView.recreateResourceView(this._resource);
     1374            // This is needed when resource content was changed from scripts panel.
     1375            var newView = this._recreateSourceView();
    13211376            if (oldView === this._storagePanel.visibleView)
    13221377                this._storagePanel._showResourceView(this._resource);
    13231378        }
    1324     }
     1379    },
     1380
     1381    sourceView: function()
     1382    {
     1383        if (!this._sourceView) {
     1384            this._sourceView = this._createSourceView();
     1385            if (this._resource.messages) {
     1386                for (var i = 0; i < this._resource.messages.length; i++)
     1387                    this._sourceView.addMessage(this._resource.messages[i]);
     1388            }
     1389        }
     1390        return this._sourceView;
     1391    },
     1392
     1393    _createSourceView: function()
     1394    {
     1395        return new WebInspector.EditableResourceSourceFrame(this._resource);
     1396    },
     1397
     1398    _recreateSourceView: function()
     1399    {
     1400        var oldView = this._sourceView;
     1401        var newView = this._createSourceView();
     1402
     1403        var oldViewParentNode = oldView.visible ? oldView.element.parentNode : null;
     1404        var scrollTop = oldView.scrollTop;
     1405
     1406        this._sourceView.detach();
     1407        this._sourceView = newView;
     1408
     1409        if (oldViewParentNode)
     1410            newView.show(oldViewParentNode);
     1411        if (scrollTop)
     1412            newView.scrollTop = scrollTop;
     1413
     1414        return newView;
     1415    }   
    13251416}
    13261417
     
    14521543{
    14531544    var title = revision.timestamp ? revision.timestamp.toLocaleTimeString() : WebInspector.UIString("(original)");
    1454     WebInspector.BaseStorageTreeElement.call(this, storagePanel, null, title, ["resource-sidebar-tree-item", "resources-category-" + revision.resource.category.name]);
     1545    WebInspector.BaseStorageTreeElement.call(this, storagePanel, revision, title, ["resource-sidebar-tree-item", "resources-category-" + revision.resource.category.name]);
    14551546    if (revision.timestamp)
    14561547        this.tooltip = revision.timestamp.toLocaleString();
     
    15031594
    15041595        contextMenu.show(event);
     1596    },
     1597
     1598    sourceView: function()
     1599    {
     1600        if (!this._sourceView)
     1601            this._sourceView = new WebInspector.ResourceRevisionSourceFrame(this._revision);
     1602        return this._sourceView;
    15051603    }
    15061604}
Note: See TracChangeset for help on using the changeset viewer.