Changeset 70045 in webkit


Ignore:
Timestamp:
Oct 19, 2010 3:35:21 AM (14 years ago)
Author:
pfeldman@chromium.org
Message:

2010-10-19 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: do not access ResourcePanel from resources directly.
https://bugs.webkit.org/show_bug.cgi?id=47892

Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r70043 r70045  
     12010-10-19  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: do not access ResourcePanel from resources directly.
     6        https://bugs.webkit.org/show_bug.cgi?id=47892
     7
     8        * inspector/front-end/Resource.js:
     9        (WebInspector.Resource.prototype.set documentURL):
     10        (WebInspector.Resource.prototype.set startTime):
     11        (WebInspector.Resource.prototype.set responseReceivedTime):
     12        (WebInspector.Resource.prototype.set endTime):
     13        (WebInspector.Resource.prototype.set resourceSize):
     14        (WebInspector.Resource.prototype.set expectedContentLength):
     15        (WebInspector.Resource.prototype.set category):
     16        (WebInspector.Resource.prototype.set cached):
     17        (WebInspector.Resource.prototype.set mimeType):
     18        (WebInspector.Resource.prototype.get requestHeaders):
     19        (WebInspector.Resource.prototype.set requestHeaders):
     20        (WebInspector.Resource.prototype.get responseHeaders):
     21        (WebInspector.Resource.prototype.set responseHeaders):
     22        * inspector/front-end/ResourcesPanel.js:
     23        (WebInspector.ResourcesPanel.prototype.addResource):
     24        (WebInspector.ResourcesPanel.prototype.refreshResource):
     25        (WebInspector.ResourcesPanel.prototype._recreateViewForResourceIfNeeded):
     26        (WebInspector.ResourcesPanel.prototype._resourceViewIsConsistentWithCategory):
     27        (WebInspector.ResourceGraph):
     28        (WebInspector.ResourceGraph.prototype.refresh):
     29        * inspector/front-end/inspector.js:
     30        (WebInspector.updateResource):
     31
    1322010-10-19  Yuta Kitamura  <yutak@chromium.org>
    233
  • trunk/WebCore/inspector/front-end/Resource.js

    r69948 r70045  
    120120    set documentURL(x)
    121121    {
    122         if (this._documentURL === x)
    123             return;
    124122        this._documentURL = x;
    125123    },
     
    154152    set startTime(x)
    155153    {
    156         if (this._startTime === x)
    157             return;
    158 
    159154        this._startTime = x;
    160 
    161         if (WebInspector.panels.resources)
    162             WebInspector.panels.resources.refreshResource(this);
    163155    },
    164156
     
    175167    set responseReceivedTime(x)
    176168    {
    177         if (this._responseReceivedTime === x)
    178             return;
    179 
    180169        this._responseReceivedTime = x;
    181 
    182         if (WebInspector.panels.resources)
    183             WebInspector.panels.resources.refreshResource(this);
    184170    },
    185171
     
    197183            this.responseReceivedTime = x;
    198184
    199         if (this._endTime === x)
    200             return;
    201 
    202185        this._endTime = x;
    203 
    204         if (WebInspector.panels.resources)
    205             WebInspector.panels.resources.refreshResource(this);
    206186    },
    207187
     
    234214    set resourceSize(x)
    235215    {
    236         if (this._resourceSize === x)
    237             return;
    238 
    239216        this._resourceSize = x;
    240 
    241         if (WebInspector.panels.resources)
    242             WebInspector.panels.resources.refreshResource(this);
    243217    },
    244218
     
    256230    set expectedContentLength(x)
    257231    {
    258         if (this._expectedContentLength === x)
    259             return;
    260232        this._expectedContentLength = x;
    261233    },
     
    307279        if (this._category)
    308280            this._category.addResource(this);
    309 
    310         if (WebInspector.panels.resources) {
    311             WebInspector.panels.resources.refreshResource(this);
    312             WebInspector.panels.resources.recreateViewForResourceIfNeeded(this);
    313         }
    314281    },
    315282
     
    322289    {
    323290        this._cached = x;
    324         this.dispatchEventToListeners("cached changed");
    325291    },
    326292
     
    332298    set mimeType(x)
    333299    {
    334         if (this._mimeType === x)
    335             return;
    336 
    337300        this._mimeType = x;
    338301    },
     
    381344    get requestHeaders()
    382345    {
    383         if (this._requestHeaders === undefined)
    384             this._requestHeaders = {};
    385         return this._requestHeaders;
     346        return this._requestHeaders || {};
    386347    },
    387348
    388349    set requestHeaders(x)
    389350    {
    390         if (this._requestHeaders === x)
    391             return;
    392 
    393351        this._requestHeaders = x;
    394352        delete this._sortedRequestHeaders;
     
    428386    get responseHeaders()
    429387    {
    430         if (this._responseHeaders === undefined)
    431             this._responseHeaders = {};
    432         return this._responseHeaders;
     388        return this._responseHeaders || {};
    433389    },
    434390
    435391    set responseHeaders(x)
    436392    {
    437         if (this._responseHeaders === x)
    438             return;
    439 
    440393        this._responseHeaders = x;
    441394        delete this._sortedResponseHeaders;
  • trunk/WebCore/inspector/front-end/ResourcesPanel.js

    r69948 r70045  
    758758    {
    759759        this._resources.push(resource);
    760         this.refreshResource(resource);
    761760    },
    762761
     
    816815    refreshResource: function(resource)
    817816    {
     817        this._recreateViewForResourceIfNeeded(resource);
    818818        this.refreshItem(resource);
    819819    },
    820820
    821     recreateViewForResourceIfNeeded: function(resource)
     821    _recreateViewForResourceIfNeeded: function(resource)
    822822    {
    823823        if (!resource || !resource._resourcesView)
    824824            return;
    825825
     826        if (this._resourceViewIsConsistentWithCategory(resource, resource._resourcesView))
     827            return;
     828
    826829        var newView = this._createResourceView(resource);
    827         if (newView.__proto__ === resource._resourcesView.__proto__)
    828             return;
    829 
    830830        if (!this.currentQuery && resource._itemsTreeElement)
    831831            resource._itemsTreeElement.updateErrorsAndWarnings();
     
    10671067        this.sortingFunction = selectedOption.sortingFunction;
    10681068        this.calculator = this.summaryBar.calculator = selectedOption.calculator;
     1069    },
     1070
     1071    _resourceViewIsConsistentWithCategory: function(resource, resourceView)
     1072    {
     1073        switch (resource.category) {
     1074            case WebInspector.resourceCategories.documents:
     1075            case WebInspector.resourceCategories.stylesheets:
     1076            case WebInspector.resourceCategories.scripts:
     1077            case WebInspector.resourceCategories.xhr:
     1078                return resourceView.__proto__ === WebInspector.SourceView.prototype;
     1079            case WebInspector.resourceCategories.images:
     1080                return resourceView.__proto__ === WebInspector.ImageView.prototype;
     1081            case WebInspector.resourceCategories.fonts:
     1082                return resourceView.__proto__ === WebInspector.FontView.prototype;
     1083            default:
     1084                return resourceView.__proto__ === WebInspector.ResourceView.prototype;
     1085        }
    10691086    },
    10701087
     
    18201837    this._graphElement.addEventListener("mouseover", this.refreshLabelPositions.bind(this), false);
    18211838
    1822     this._cachedChanged();
     1839    if (this.resource.cached)
     1840        this._graphElement.addStyleClass("resource-cached");
    18231841
    18241842    this._barAreaElement = document.createElement("div");
     
    18441862
    18451863    this._graphElement.addStyleClass("resources-category-" + resource.category.name);
    1846 
    1847     resource.addEventListener("cached changed", this._cachedChanged, this);
    18481864}
    18491865
     
    19691985        this._labelRightElement.title = tooltip;
    19701986        this._barRightElement.title = tooltip;
    1971     },
    1972 
    1973     _cachedChanged: function()
    1974     {
    1975         if (this.resource.cached)
     1987
     1988        if (this.resource.cached && !this._graphElement.hasStyleClass("resource-cached"))
    19761989            this._graphElement.addStyleClass("resource-cached");
    19771990    }
  • trunk/WebCore/inspector/front-end/inspector.js

    r69976 r70045  
    12821282            resource.endTime = payload.endTime;
    12831283    }
     1284    this.panels.resources.refreshResource(resource);
    12841285}
    12851286
Note: See TracChangeset for help on using the changeset viewer.