Commit 66d4804d authored by pfeldman@chromium.org's avatar pfeldman@chromium.org
Browse files

2011-01-25 Pavel Feldman <pfeldman@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: bind resources to URLs upon adding them into the tree.
        https://bugs.webkit.org/show_bug.cgi?id=53013

        * inspector/debugger-scripts-expected.txt:
        * inspector/debugger-scripts.html:
2011-01-25  Pavel Feldman  <pfeldman@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: bind resources to URLs upon adding them into the tree.
        https://bugs.webkit.org/show_bug.cgi?id=53013

        * inspector/front-end/AuditRules.js:
        (WebInspector.AuditRules.UnusedCssRule.prototype.doRun.evalCallback.selectorsCallback):
        * inspector/front-end/CSSStyleModel.js:
        (WebInspector.CSSStyleModel.prototype._styleSheetChanged.callback):
        (WebInspector.CSSStyleModel.prototype._styleSheetChanged):
        * inspector/front-end/DebuggerModel.js:
        (WebInspector.DebuggerModel.prototype._parsedScriptSource):
        * inspector/front-end/NetworkManager.js:
        (WebInspector.NetworkManager.prototype._processCachedResources):
        (WebInspector.NetworkManager.prototype.inflightResourceForURL):
        (WebInspector.NetworkDispatcher):
        (WebInspector.NetworkDispatcher.prototype.willSendRequest):
        (WebInspector.NetworkDispatcher.prototype.markResourceAsCached):
        (WebInspector.NetworkDispatcher.prototype.didReceiveResponse):
        (WebInspector.NetworkDispatcher.prototype.didReceiveContentLength):
        (WebInspector.NetworkDispatcher.prototype.didFinishLoading):
        (WebInspector.NetworkDispatcher.prototype.didFailLoading):
        (WebInspector.NetworkDispatcher.prototype.willSendWebSocketHandshakeRequest):
        (WebInspector.NetworkDispatcher.prototype.didReceiveWebSocketHandshakeResponse):
        (WebInspector.NetworkDispatcher.prototype.didCloseWebSocket):
        (WebInspector.NetworkDispatcher.prototype._appendRedirect):
        (WebInspector.NetworkDispatcher.prototype._startResource):
        (WebInspector.NetworkDispatcher.prototype._finishResource):
        (WebInspector.NetworkDispatcher.prototype._createResource):
        * inspector/front-end/ResourceTreeModel.js:
        (WebInspector.ResourceTreeModel.prototype.addResourceToFrame):
        (WebInspector.ResourceTreeModel.prototype._bindResourceURL):
        (WebInspector.ResourceTreeModel.prototype._clearResources):
        (WebInspector.ResourceTreeModel.prototype._unbindResourceURL):
        * inspector/front-end/ResourcesPanel.js:
        (WebInspector.ResourcesPanel.prototype.canShowSourceLine):
        (WebInspector.ResourcesPanel.prototype.showSourceLine):
        * inspector/front-end/ScriptsPanel.js:
        (WebInspector.ScriptsPanel.prototype._parsedScriptSource):
        (WebInspector.ScriptsPanel.prototype._addScript):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76587 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 95ccc61b
2011-01-25 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Yury Semikhatsky.
Web Inspector: bind resources to URLs upon adding them into the tree.
https://bugs.webkit.org/show_bug.cgi?id=53013
* inspector/debugger-scripts-expected.txt:
* inspector/debugger-scripts.html:
2011-01-25 Nikolas Zimmermann <nzimmermann@rim.com>
 
Reviewed by Dirk Schulze.
......
......@@ -3,7 +3,7 @@ Tests that valid parsed script notifications are received by front-end. Bug 5272
Debugger was enabled.
script 1:
offset: 5:8
length: 1096
length: 1050
script 2:
offset: 38:21
length: 50
......
......@@ -17,7 +17,7 @@ var test = function()
function step2(event)
{
var script = WebInspector.debuggerModel.scriptForSourceID(event.data);
var script = event.data;
if (script.sourceURL !== WebInspector.mainResource.url)
return;
scripts.push(script);
......
2011-01-25 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Yury Semikhatsky.
Web Inspector: bind resources to URLs upon adding them into the tree.
https://bugs.webkit.org/show_bug.cgi?id=53013
* inspector/front-end/AuditRules.js:
(WebInspector.AuditRules.UnusedCssRule.prototype.doRun.evalCallback.selectorsCallback):
* inspector/front-end/CSSStyleModel.js:
(WebInspector.CSSStyleModel.prototype._styleSheetChanged.callback):
(WebInspector.CSSStyleModel.prototype._styleSheetChanged):
* inspector/front-end/DebuggerModel.js:
(WebInspector.DebuggerModel.prototype._parsedScriptSource):
* inspector/front-end/NetworkManager.js:
(WebInspector.NetworkManager.prototype._processCachedResources):
(WebInspector.NetworkManager.prototype.inflightResourceForURL):
(WebInspector.NetworkDispatcher):
(WebInspector.NetworkDispatcher.prototype.willSendRequest):
(WebInspector.NetworkDispatcher.prototype.markResourceAsCached):
(WebInspector.NetworkDispatcher.prototype.didReceiveResponse):
(WebInspector.NetworkDispatcher.prototype.didReceiveContentLength):
(WebInspector.NetworkDispatcher.prototype.didFinishLoading):
(WebInspector.NetworkDispatcher.prototype.didFailLoading):
(WebInspector.NetworkDispatcher.prototype.willSendWebSocketHandshakeRequest):
(WebInspector.NetworkDispatcher.prototype.didReceiveWebSocketHandshakeResponse):
(WebInspector.NetworkDispatcher.prototype.didCloseWebSocket):
(WebInspector.NetworkDispatcher.prototype._appendRedirect):
(WebInspector.NetworkDispatcher.prototype._startResource):
(WebInspector.NetworkDispatcher.prototype._finishResource):
(WebInspector.NetworkDispatcher.prototype._createResource):
* inspector/front-end/ResourceTreeModel.js:
(WebInspector.ResourceTreeModel.prototype.addResourceToFrame):
(WebInspector.ResourceTreeModel.prototype._bindResourceURL):
(WebInspector.ResourceTreeModel.prototype._clearResources):
(WebInspector.ResourceTreeModel.prototype._unbindResourceURL):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.ResourcesPanel.prototype.canShowSourceLine):
(WebInspector.ResourcesPanel.prototype.showSourceLine):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype._parsedScriptSource):
(WebInspector.ScriptsPanel.prototype._addScript):
2011-01-25 Nikolas Zimmermann <nzimmermann@rim.com>
 
Reviewed by Dirk Schulze.
......@@ -326,7 +326,7 @@ WebInspector.AuditRules.UnusedCssRule.prototype = {
if (!unusedRules.length)
continue;
var resource = WebInspector.resourceTreeModel.resourceForURL(styleSheet.sourceURL);
var resource = WebInspector.resourceForURL(styleSheet.sourceURL);
var isInlineBlock = resource && resource.type == WebInspector.Resource.Type.Document;
var url = !isInlineBlock ? WebInspector.AuditRuleResult.linkifyDisplayName(styleSheet.sourceURL) : String.sprintf("Inline block #%d", ++inlineBlockOrdinal);
var pctUnused = Math.round(100 * unusedStylesheetSize / stylesheetSize);
......
......@@ -162,7 +162,7 @@ WebInspector.CSSStyleModel.prototype = {
function callback(href, content)
{
var resource = WebInspector.resourceTreeModel.resourceForURL(href);
var resource = WebInspector.resourceForURL(href);
if (resource && resource.type === WebInspector.Resource.Type.Stylesheet)
resource.setContent(content, this._onRevert.bind(this, styleSheetId));
}
......
......@@ -247,7 +247,7 @@ WebInspector.DebuggerModel.prototype = {
{
var script = new WebInspector.Script(sourceID, sourceURL, "", lineOffset, columnOffset, length, undefined, undefined, scriptWorldType);
this._scripts[sourceID] = script;
this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedScriptSource, sourceID);
this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedScriptSource, script);
},
_failedToParseScriptSource: function(sourceURL, source, startingLine, errorLine, errorMessage)
......
......@@ -61,6 +61,11 @@ WebInspector.NetworkManager.prototype = {
var mainResource = this._dispatcher._addFramesRecursively(mainFramePayload);
WebInspector.mainResource = mainResource;
mainResource.isMainResource = true;
},
inflightResourceForURL: function(url)
{
return this._dispatcher._inflightResourcesByURL[url];
}
}
......@@ -69,7 +74,8 @@ WebInspector.NetworkManager.prototype.__proto__ = WebInspector.Object.prototype;
WebInspector.NetworkDispatcher = function(resourceTreeModel, manager)
{
this._manager = manager;
this._inflightResources = {};
this._inflightResourcesById = {};
this._inflightResourcesByURL = {};
this._resourceTreeModel = resourceTreeModel;
this._lastIdentifierForCachedResource = 0;
InspectorBackend.registerDomainDispatcher("Network", this);
......@@ -128,7 +134,7 @@ WebInspector.NetworkDispatcher.prototype = {
willSendRequest: function(identifier, time, request, redirectResponse)
{
var resource = this._inflightResources[identifier];
var resource = this._inflightResourcesById[identifier];
if (!resource)
return;
......@@ -151,7 +157,7 @@ WebInspector.NetworkDispatcher.prototype = {
markResourceAsCached: function(identifier)
{
var resource = this._inflightResources[identifier];
var resource = this._inflightResourcesById[identifier];
if (!resource)
return;
......@@ -161,7 +167,7 @@ WebInspector.NetworkDispatcher.prototype = {
didReceiveResponse: function(identifier, time, resourceType, response)
{
var resource = this._inflightResources[identifier];
var resource = this._inflightResourcesById[identifier];
if (!resource)
return;
......@@ -176,7 +182,7 @@ WebInspector.NetworkDispatcher.prototype = {
didReceiveContentLength: function(identifier, time, lengthReceived)
{
var resource = this._inflightResources[identifier];
var resource = this._inflightResourcesById[identifier];
if (!resource)
return;
......@@ -188,7 +194,7 @@ WebInspector.NetworkDispatcher.prototype = {
didFinishLoading: function(identifier, finishTime)
{
var resource = this._inflightResources[identifier];
var resource = this._inflightResourcesById[identifier];
if (!resource)
return;
......@@ -197,7 +203,7 @@ WebInspector.NetworkDispatcher.prototype = {
didFailLoading: function(identifier, time, localizedDescription)
{
var resource = this._inflightResources[identifier];
var resource = this._inflightResourcesById[identifier];
if (!resource)
return;
......@@ -256,7 +262,7 @@ WebInspector.NetworkDispatcher.prototype = {
willSendWebSocketHandshakeRequest: function(identifier, time, request)
{
var resource = this._inflightResources[identifier];
var resource = this._inflightResourcesById[identifier];
if (!resource)
return;
......@@ -270,7 +276,7 @@ WebInspector.NetworkDispatcher.prototype = {
didReceiveWebSocketHandshakeResponse: function(identifier, time, response)
{
var resource = this._inflightResources[identifier];
var resource = this._inflightResourcesById[identifier];
if (!resource)
return;
......@@ -285,7 +291,7 @@ WebInspector.NetworkDispatcher.prototype = {
didCloseWebSocket: function(identifier, time)
{
var resource = this._inflightResources[identifier];
var resource = this._inflightResourcesById[identifier];
if (!resource)
return;
this._finishResource(resource, time);
......@@ -293,17 +299,11 @@ WebInspector.NetworkDispatcher.prototype = {
_appendRedirect: function(identifier, time, redirectURL)
{
var originalResource = this._inflightResources[identifier];
var originalResource = this._inflightResourcesById[identifier];
var previousRedirects = originalResource.redirects || [];
originalResource.identifier = "redirected:" + identifier + "." + previousRedirects.length;
delete originalResource.redirects;
this._finishResource(originalResource, time);
// We bound resource early, but it happened to be a redirect and won't make it through to
// the resource tree -- so unbind it.
// FIXME: we should bind upon adding to the tree only (encapsulated into ResourceTreeModel),
// Script debugger should do explicit late binding on its own.
this._resourceTreeModel.unbindResourceURL(originalResource);
var newResource = this._createResource(identifier, redirectURL, originalResource.loader, originalResource.stackTrace);
newResource.redirects = previousRedirects.concat(originalResource);
return newResource;
......@@ -311,7 +311,8 @@ WebInspector.NetworkDispatcher.prototype = {
_startResource: function(resource)
{
this._inflightResources[resource.identifier] = resource;
this._inflightResourcesById[resource.identifier] = resource;
this._inflightResourcesByURL[resource.url] = resource;
this._dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceStarted, resource);
},
......@@ -325,7 +326,8 @@ WebInspector.NetworkDispatcher.prototype = {
resource.endTime = finishTime;
resource.finished = true;
this._dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceFinished, resource);
delete this._inflightResources[resource.identifier];
delete this._inflightResourcesById[resource.identifier];
delete this._inflightResourcesByURL[resource.url];
},
_addFramesRecursively: function(framePayload)
......@@ -364,10 +366,8 @@ WebInspector.NetworkDispatcher.prototype = {
{
var resource = new WebInspector.Resource(identifier, url);
resource.loader = loader;
if (loader) {
if (loader)
resource.documentURL = loader.url;
this._resourceTreeModel.bindResourceURL(resource);
}
resource.stackTrace = stackTrace;
return resource;
}
......
......@@ -82,6 +82,7 @@ WebInspector.ResourceTreeModel.prototype = {
this._resourcesByFrameId[frameId] = resourcesForFrame;
}
resourcesForFrame.push(resource);
this._bindResourceURL(resource);
WebInspector.panels.resources.addResourceToFrame(frameId, resource);
},
......@@ -129,7 +130,7 @@ WebInspector.ResourceTreeModel.prototype = {
return entry;
},
bindResourceURL: function(resource)
_bindResourceURL: function(resource)
{
var resourceForURL = this._resourcesByURL[resource.url];
if (!resourceForURL)
......@@ -169,7 +170,7 @@ WebInspector.ResourceTreeModel.prototype = {
preservedResourcesForFrame.push(resource);
continue;
}
this.unbindResourceURL(resource);
this._unbindResourceURL(resource);
}
delete this._resourcesByFrameId[frameId];
......@@ -195,7 +196,7 @@ WebInspector.ResourceTreeModel.prototype = {
return false;
},
unbindResourceURL: function(resource)
_unbindResourceURL: function(resource)
{
var resourceForURL = this._resourcesByURL[resource.url];
if (!resourceForURL)
......
......@@ -338,12 +338,12 @@ WebInspector.ResourcesPanel.prototype = {
canShowSourceLine: function(url, line)
{
return !!WebInspector.resourceTreeModel.resourceForURL(url);
return !!WebInspector.resourceForURL(url);
},
showSourceLine: function(url, line)
{
var resource = WebInspector.resourceTreeModel.resourceForURL(url);
var resource = WebInspector.resourceForURL(url);
if (resource.type === WebInspector.Resource.Type.XHR) {
// Show XHRs in the network panel only.
if (WebInspector.panels.network && WebInspector.panels.network.canShowSourceLine(url, line)) {
......@@ -352,7 +352,7 @@ WebInspector.ResourcesPanel.prototype = {
}
return;
}
this.showResource(WebInspector.resourceTreeModel.resourceForURL(url), line);
this.showResource(WebInspector.resourceForURL(url), line);
},
showResource: function(resource, line)
......
......@@ -242,9 +242,7 @@ WebInspector.ScriptsPanel.prototype = {
_parsedScriptSource: function(event)
{
var sourceID = event.data;
var script = WebInspector.debuggerModel.scriptForSourceID(sourceID);
this._addScript(script);
this._addScript(event.data);
},
_failedToParseScriptSource: function(event)
......@@ -275,7 +273,7 @@ WebInspector.ScriptsPanel.prototype = {
_addScript: function(script)
{
var resource = WebInspector.resourceForURL(script.sourceURL);
var resource = WebInspector.networkManager.inflightResourceForURL(script.sourceURL) || WebInspector.resourceForURL(script.sourceURL);
if (resource) {
if (resource.finished) {
// Resource is finished, bind the script right away.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment