Skip to content
Permalink
Browse files
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

        * inspector/front-end/Resource.js:
        (WebInspector.Resource.prototype.set documentURL):
        (WebInspector.Resource.prototype.set startTime):
        (WebInspector.Resource.prototype.set responseReceivedTime):
        (WebInspector.Resource.prototype.set endTime):
        (WebInspector.Resource.prototype.set resourceSize):
        (WebInspector.Resource.prototype.set expectedContentLength):
        (WebInspector.Resource.prototype.set category):
        (WebInspector.Resource.prototype.set cached):
        (WebInspector.Resource.prototype.set mimeType):
        (WebInspector.Resource.prototype.get requestHeaders):
        (WebInspector.Resource.prototype.set requestHeaders):
        (WebInspector.Resource.prototype.get responseHeaders):
        (WebInspector.Resource.prototype.set responseHeaders):
        * inspector/front-end/ResourcesPanel.js:
        (WebInspector.ResourcesPanel.prototype.addResource):
        (WebInspector.ResourcesPanel.prototype.refreshResource):
        (WebInspector.ResourcesPanel.prototype._recreateViewForResourceIfNeeded):
        (WebInspector.ResourcesPanel.prototype._resourceViewIsConsistentWithCategory):
        (WebInspector.ResourceGraph):
        (WebInspector.ResourceGraph.prototype.refresh):
        * inspector/front-end/inspector.js:
        (WebInspector.updateResource):

Canonical link: https://commits.webkit.org/60608@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@70045 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
pavelfeldman committed Oct 19, 2010
1 parent 11a1344 commit cd440edf039e4be66c61e2064976dc48352ab3a3
Showing 4 changed files with 58 additions and 60 deletions.
@@ -1,3 +1,34 @@
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

* inspector/front-end/Resource.js:
(WebInspector.Resource.prototype.set documentURL):
(WebInspector.Resource.prototype.set startTime):
(WebInspector.Resource.prototype.set responseReceivedTime):
(WebInspector.Resource.prototype.set endTime):
(WebInspector.Resource.prototype.set resourceSize):
(WebInspector.Resource.prototype.set expectedContentLength):
(WebInspector.Resource.prototype.set category):
(WebInspector.Resource.prototype.set cached):
(WebInspector.Resource.prototype.set mimeType):
(WebInspector.Resource.prototype.get requestHeaders):
(WebInspector.Resource.prototype.set requestHeaders):
(WebInspector.Resource.prototype.get responseHeaders):
(WebInspector.Resource.prototype.set responseHeaders):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.ResourcesPanel.prototype.addResource):
(WebInspector.ResourcesPanel.prototype.refreshResource):
(WebInspector.ResourcesPanel.prototype._recreateViewForResourceIfNeeded):
(WebInspector.ResourcesPanel.prototype._resourceViewIsConsistentWithCategory):
(WebInspector.ResourceGraph):
(WebInspector.ResourceGraph.prototype.refresh):
* inspector/front-end/inspector.js:
(WebInspector.updateResource):

2010-10-19 Yuta Kitamura <yutak@chromium.org>

Reviewed by Pavel Feldman.
@@ -119,8 +119,6 @@ WebInspector.Resource.prototype = {

set documentURL(x)
{
if (this._documentURL === x)
return;
this._documentURL = x;
},

@@ -153,13 +151,7 @@ WebInspector.Resource.prototype = {

set startTime(x)
{
if (this._startTime === x)
return;

this._startTime = x;

if (WebInspector.panels.resources)
WebInspector.panels.resources.refreshResource(this);
},

get responseReceivedTime()
@@ -174,13 +166,7 @@ WebInspector.Resource.prototype = {

set responseReceivedTime(x)
{
if (this._responseReceivedTime === x)
return;

this._responseReceivedTime = x;

if (WebInspector.panels.resources)
WebInspector.panels.resources.refreshResource(this);
},

get endTime()
@@ -196,13 +182,7 @@ WebInspector.Resource.prototype = {
if (x < this.responseReceivedTime)
this.responseReceivedTime = x;

if (this._endTime === x)
return;

this._endTime = x;

if (WebInspector.panels.resources)
WebInspector.panels.resources.refreshResource(this);
},

get duration()
@@ -233,13 +213,7 @@ WebInspector.Resource.prototype = {

set resourceSize(x)
{
if (this._resourceSize === x)
return;

this._resourceSize = x;

if (WebInspector.panels.resources)
WebInspector.panels.resources.refreshResource(this);
},

get transferSize()
@@ -255,8 +229,6 @@ WebInspector.Resource.prototype = {

set expectedContentLength(x)
{
if (this._expectedContentLength === x)
return;
this._expectedContentLength = x;
},

@@ -306,11 +278,6 @@ WebInspector.Resource.prototype = {

if (this._category)
this._category.addResource(this);

if (WebInspector.panels.resources) {
WebInspector.panels.resources.refreshResource(this);
WebInspector.panels.resources.recreateViewForResourceIfNeeded(this);
}
},

get cached()
@@ -321,7 +288,6 @@ WebInspector.Resource.prototype = {
set cached(x)
{
this._cached = x;
this.dispatchEventToListeners("cached changed");
},

get mimeType()
@@ -331,9 +297,6 @@ WebInspector.Resource.prototype = {

set mimeType(x)
{
if (this._mimeType === x)
return;

this._mimeType = x;
},

@@ -380,16 +343,11 @@ WebInspector.Resource.prototype = {

get requestHeaders()
{
if (this._requestHeaders === undefined)
this._requestHeaders = {};
return this._requestHeaders;
return this._requestHeaders || {};
},

set requestHeaders(x)
{
if (this._requestHeaders === x)
return;

this._requestHeaders = x;
delete this._sortedRequestHeaders;

@@ -427,16 +385,11 @@ WebInspector.Resource.prototype = {

get responseHeaders()
{
if (this._responseHeaders === undefined)
this._responseHeaders = {};
return this._responseHeaders;
return this._responseHeaders || {};
},

set responseHeaders(x)
{
if (this._responseHeaders === x)
return;

this._responseHeaders = x;
delete this._sortedResponseHeaders;

@@ -757,7 +757,6 @@ WebInspector.ResourcesPanel.prototype = {
addResource: function(resource)
{
this._resources.push(resource);
this.refreshResource(resource);
},

removeResource: function(resource)
@@ -815,18 +814,19 @@ WebInspector.ResourcesPanel.prototype = {

refreshResource: function(resource)
{
this._recreateViewForResourceIfNeeded(resource);
this.refreshItem(resource);
},

recreateViewForResourceIfNeeded: function(resource)
_recreateViewForResourceIfNeeded: function(resource)
{
if (!resource || !resource._resourcesView)
return;

var newView = this._createResourceView(resource);
if (newView.__proto__ === resource._resourcesView.__proto__)
if (this._resourceViewIsConsistentWithCategory(resource, resource._resourcesView))
return;

var newView = this._createResourceView(resource);
if (!this.currentQuery && resource._itemsTreeElement)
resource._itemsTreeElement.updateErrorsAndWarnings();

@@ -1068,6 +1068,23 @@ WebInspector.ResourcesPanel.prototype = {
this.calculator = this.summaryBar.calculator = selectedOption.calculator;
},

_resourceViewIsConsistentWithCategory: function(resource, resourceView)
{
switch (resource.category) {
case WebInspector.resourceCategories.documents:
case WebInspector.resourceCategories.stylesheets:
case WebInspector.resourceCategories.scripts:
case WebInspector.resourceCategories.xhr:
return resourceView.__proto__ === WebInspector.SourceView.prototype;
case WebInspector.resourceCategories.images:
return resourceView.__proto__ === WebInspector.ImageView.prototype;
case WebInspector.resourceCategories.fonts:
return resourceView.__proto__ === WebInspector.FontView.prototype;
default:
return resourceView.__proto__ === WebInspector.ResourceView.prototype;
}
},

_createResourceView: function(resource)
{
switch (resource.category) {
@@ -1819,7 +1836,8 @@ WebInspector.ResourceGraph = function(resource)
this._graphElement.className = "resources-graph-side";
this._graphElement.addEventListener("mouseover", this.refreshLabelPositions.bind(this), false);

this._cachedChanged();
if (this.resource.cached)
this._graphElement.addStyleClass("resource-cached");

this._barAreaElement = document.createElement("div");
this._barAreaElement.className = "resources-graph-bar-area hidden";
@@ -1843,8 +1861,6 @@ WebInspector.ResourceGraph = function(resource)
this._barAreaElement.appendChild(this._labelRightElement);

this._graphElement.addStyleClass("resources-category-" + resource.category.name);

resource.addEventListener("cached changed", this._cachedChanged, this);
}

WebInspector.ResourceGraph.prototype = {
@@ -1968,11 +1984,8 @@ WebInspector.ResourceGraph.prototype = {
this._labelLeftElement.title = tooltip;
this._labelRightElement.title = tooltip;
this._barRightElement.title = tooltip;
},

_cachedChanged: function()
{
if (this.resource.cached)
if (this.resource.cached && !this._graphElement.hasStyleClass("resource-cached"))
this._graphElement.addStyleClass("resource-cached");
}
}
@@ -1281,6 +1281,7 @@ WebInspector.updateResource = function(payload)
if (payload.endTime)
resource.endTime = payload.endTime;
}
this.panels.resources.refreshResource(resource);
}

WebInspector.domContentEventFired = function(time)

0 comments on commit cd440ed

Please sign in to comment.