Changeset 76587 in webkit


Ignore:
Timestamp:
Jan 25, 2011 5:32:33 AM (13 years ago)
Author:
pfeldman@chromium.org
Message:

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):
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r76586 r76587  
     12011-01-25  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: bind resources to URLs upon adding them into the tree.
     6        https://bugs.webkit.org/show_bug.cgi?id=53013
     7
     8        * inspector/debugger-scripts-expected.txt:
     9        * inspector/debugger-scripts.html:
     10
    1112011-01-25  Nikolas Zimmermann  <nzimmermann@rim.com>
    212
  • trunk/LayoutTests/inspector/debugger-scripts-expected.txt

    r76129 r76587  
    44script 1:
    55    offset: 5:8
    6     length: 1096
     6    length: 1050
    77script 2:
    88    offset: 38:21
  • trunk/LayoutTests/inspector/debugger-scripts.html

    r76129 r76587  
    1818    function step2(event)
    1919    {
    20         var script = WebInspector.debuggerModel.scriptForSourceID(event.data);
     20        var script = event.data;
    2121        if (script.sourceURL !== WebInspector.mainResource.url)
    2222            return;
  • trunk/Source/WebCore/ChangeLog

    r76586 r76587  
     12011-01-25  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: bind resources to URLs upon adding them into the tree.
     6        https://bugs.webkit.org/show_bug.cgi?id=53013
     7
     8        * inspector/front-end/AuditRules.js:
     9        (WebInspector.AuditRules.UnusedCssRule.prototype.doRun.evalCallback.selectorsCallback):
     10        * inspector/front-end/CSSStyleModel.js:
     11        (WebInspector.CSSStyleModel.prototype._styleSheetChanged.callback):
     12        (WebInspector.CSSStyleModel.prototype._styleSheetChanged):
     13        * inspector/front-end/DebuggerModel.js:
     14        (WebInspector.DebuggerModel.prototype._parsedScriptSource):
     15        * inspector/front-end/NetworkManager.js:
     16        (WebInspector.NetworkManager.prototype._processCachedResources):
     17        (WebInspector.NetworkManager.prototype.inflightResourceForURL):
     18        (WebInspector.NetworkDispatcher):
     19        (WebInspector.NetworkDispatcher.prototype.willSendRequest):
     20        (WebInspector.NetworkDispatcher.prototype.markResourceAsCached):
     21        (WebInspector.NetworkDispatcher.prototype.didReceiveResponse):
     22        (WebInspector.NetworkDispatcher.prototype.didReceiveContentLength):
     23        (WebInspector.NetworkDispatcher.prototype.didFinishLoading):
     24        (WebInspector.NetworkDispatcher.prototype.didFailLoading):
     25        (WebInspector.NetworkDispatcher.prototype.willSendWebSocketHandshakeRequest):
     26        (WebInspector.NetworkDispatcher.prototype.didReceiveWebSocketHandshakeResponse):
     27        (WebInspector.NetworkDispatcher.prototype.didCloseWebSocket):
     28        (WebInspector.NetworkDispatcher.prototype._appendRedirect):
     29        (WebInspector.NetworkDispatcher.prototype._startResource):
     30        (WebInspector.NetworkDispatcher.prototype._finishResource):
     31        (WebInspector.NetworkDispatcher.prototype._createResource):
     32        * inspector/front-end/ResourceTreeModel.js:
     33        (WebInspector.ResourceTreeModel.prototype.addResourceToFrame):
     34        (WebInspector.ResourceTreeModel.prototype._bindResourceURL):
     35        (WebInspector.ResourceTreeModel.prototype._clearResources):
     36        (WebInspector.ResourceTreeModel.prototype._unbindResourceURL):
     37        * inspector/front-end/ResourcesPanel.js:
     38        (WebInspector.ResourcesPanel.prototype.canShowSourceLine):
     39        (WebInspector.ResourcesPanel.prototype.showSourceLine):
     40        * inspector/front-end/ScriptsPanel.js:
     41        (WebInspector.ScriptsPanel.prototype._parsedScriptSource):
     42        (WebInspector.ScriptsPanel.prototype._addScript):
     43
    1442011-01-25  Nikolas Zimmermann  <nzimmermann@rim.com>
    245
  • trunk/Source/WebCore/inspector/front-end/AuditRules.js

    r76105 r76587  
    327327                        continue;
    328328
    329                     var resource = WebInspector.resourceTreeModel.resourceForURL(styleSheet.sourceURL);
     329                    var resource = WebInspector.resourceForURL(styleSheet.sourceURL);
    330330                    var isInlineBlock = resource && resource.type == WebInspector.Resource.Type.Document;
    331331                    var url = !isInlineBlock ? WebInspector.AuditRuleResult.linkifyDisplayName(styleSheet.sourceURL) : String.sprintf("Inline block #%d", ++inlineBlockOrdinal);
  • trunk/Source/WebCore/inspector/front-end/CSSStyleModel.js

    r74740 r76587  
    163163        function callback(href, content)
    164164        {
    165             var resource = WebInspector.resourceTreeModel.resourceForURL(href);
     165            var resource = WebInspector.resourceForURL(href);
    166166            if (resource && resource.type === WebInspector.Resource.Type.Stylesheet)
    167167                resource.setContent(content, this._onRevert.bind(this, styleSheetId));
  • trunk/Source/WebCore/inspector/front-end/DebuggerModel.js

    r76509 r76587  
    248248        var script = new WebInspector.Script(sourceID, sourceURL, "", lineOffset, columnOffset, length, undefined, undefined, scriptWorldType);
    249249        this._scripts[sourceID] = script;
    250         this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedScriptSource, sourceID);
     250        this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedScriptSource, script);
    251251    },
    252252
  • trunk/Source/WebCore/inspector/front-end/NetworkManager.js

    r76519 r76587  
    6262        WebInspector.mainResource = mainResource;
    6363        mainResource.isMainResource = true;
     64    },
     65
     66    inflightResourceForURL: function(url)
     67    {
     68        return this._dispatcher._inflightResourcesByURL[url];
    6469    }
    6570}
     
    7075{
    7176    this._manager = manager;
    72     this._inflightResources = {};
     77    this._inflightResourcesById = {};
     78    this._inflightResourcesByURL = {};
    7379    this._resourceTreeModel = resourceTreeModel;
    7480    this._lastIdentifierForCachedResource = 0;
     
    129135    willSendRequest: function(identifier, time, request, redirectResponse)
    130136    {
    131         var resource = this._inflightResources[identifier];
     137        var resource = this._inflightResourcesById[identifier];
    132138        if (!resource)
    133139            return;
     
    152158    markResourceAsCached: function(identifier)
    153159    {
    154         var resource = this._inflightResources[identifier];
     160        var resource = this._inflightResourcesById[identifier];
    155161        if (!resource)
    156162            return;
     
    162168    didReceiveResponse: function(identifier, time, resourceType, response)
    163169    {
    164         var resource = this._inflightResources[identifier];
     170        var resource = this._inflightResourcesById[identifier];
    165171        if (!resource)
    166172            return;
     
    177183    didReceiveContentLength: function(identifier, time, lengthReceived)
    178184    {
    179         var resource = this._inflightResources[identifier];
     185        var resource = this._inflightResourcesById[identifier];
    180186        if (!resource)
    181187            return;
     
    189195    didFinishLoading: function(identifier, finishTime)
    190196    {
    191         var resource = this._inflightResources[identifier];
     197        var resource = this._inflightResourcesById[identifier];
    192198        if (!resource)
    193199            return;
     
    198204    didFailLoading: function(identifier, time, localizedDescription)
    199205    {
    200         var resource = this._inflightResources[identifier];
     206        var resource = this._inflightResourcesById[identifier];
    201207        if (!resource)
    202208            return;
     
    257263    willSendWebSocketHandshakeRequest: function(identifier, time, request)
    258264    {
    259         var resource = this._inflightResources[identifier];
     265        var resource = this._inflightResourcesById[identifier];
    260266        if (!resource)
    261267            return;
     
    271277    didReceiveWebSocketHandshakeResponse: function(identifier, time, response)
    272278    {
    273         var resource = this._inflightResources[identifier];
     279        var resource = this._inflightResourcesById[identifier];
    274280        if (!resource)
    275281            return;
     
    286292    didCloseWebSocket: function(identifier, time)
    287293    {
    288         var resource = this._inflightResources[identifier];
     294        var resource = this._inflightResourcesById[identifier];
    289295        if (!resource)
    290296            return;
     
    294300    _appendRedirect: function(identifier, time, redirectURL)
    295301    {
    296         var originalResource = this._inflightResources[identifier];
     302        var originalResource = this._inflightResourcesById[identifier];
    297303        var previousRedirects = originalResource.redirects || [];
    298304        originalResource.identifier = "redirected:" + identifier + "." + previousRedirects.length;
    299305        delete originalResource.redirects;
    300306        this._finishResource(originalResource, time);
    301         // We bound resource early, but it happened to be a redirect and won't make it through to
    302         // the resource tree -- so unbind it.
    303         // FIXME: we should bind upon adding to the tree only (encapsulated into ResourceTreeModel),
    304         // Script debugger should do explicit late binding on its own.
    305         this._resourceTreeModel.unbindResourceURL(originalResource);
    306        
    307307        var newResource = this._createResource(identifier, redirectURL, originalResource.loader, originalResource.stackTrace);
    308308        newResource.redirects = previousRedirects.concat(originalResource);
     
    312312    _startResource: function(resource)
    313313    {
    314         this._inflightResources[resource.identifier] = resource;
     314        this._inflightResourcesById[resource.identifier] = resource;
     315        this._inflightResourcesByURL[resource.url] = resource;
    315316        this._dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceStarted, resource);
    316317    },
     
    326327        resource.finished = true;
    327328        this._dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceFinished, resource);
    328         delete this._inflightResources[resource.identifier];
     329        delete this._inflightResourcesById[resource.identifier];
     330        delete this._inflightResourcesByURL[resource.url];
    329331    },
    330332
     
    365367        var resource = new WebInspector.Resource(identifier, url);
    366368        resource.loader = loader;
    367         if (loader) {
     369        if (loader)
    368370            resource.documentURL = loader.url;
    369             this._resourceTreeModel.bindResourceURL(resource);
    370         }
    371371        resource.stackTrace = stackTrace;
    372372        return resource;
  • trunk/Source/WebCore/inspector/front-end/ResourceTreeModel.js

    r76519 r76587  
    8383        }
    8484        resourcesForFrame.push(resource);
     85        this._bindResourceURL(resource);
    8586
    8687        WebInspector.panels.resources.addResourceToFrame(frameId, resource);
     
    130131    },
    131132
    132     bindResourceURL: function(resource)
     133    _bindResourceURL: function(resource)
    133134    {
    134135        var resourceForURL = this._resourcesByURL[resource.url];
     
    170171                continue;
    171172            }
    172             this.unbindResourceURL(resource);
     173            this._unbindResourceURL(resource);
    173174        }
    174175
     
    196197    },
    197198
    198     unbindResourceURL: function(resource)
     199    _unbindResourceURL: function(resource)
    199200    {
    200201        var resourceForURL = this._resourcesByURL[resource.url];
  • trunk/Source/WebCore/inspector/front-end/ResourcesPanel.js

    r76504 r76587  
    339339    canShowSourceLine: function(url, line)
    340340    {
    341         return !!WebInspector.resourceTreeModel.resourceForURL(url);
     341        return !!WebInspector.resourceForURL(url);
    342342    },
    343343
    344344    showSourceLine: function(url, line)
    345345    {
    346         var resource = WebInspector.resourceTreeModel.resourceForURL(url);
     346        var resource = WebInspector.resourceForURL(url);
    347347        if (resource.type === WebInspector.Resource.Type.XHR) {
    348348            // Show XHRs in the network panel only.
     
    353353            return;
    354354        }
    355         this.showResource(WebInspector.resourceTreeModel.resourceForURL(url), line);
     355        this.showResource(WebInspector.resourceForURL(url), line);
    356356    },
    357357
  • trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js

    r76497 r76587  
    243243    _parsedScriptSource: function(event)
    244244    {
    245         var sourceID = event.data;
    246         var script = WebInspector.debuggerModel.scriptForSourceID(sourceID);
    247         this._addScript(script);
     245        this._addScript(event.data);
    248246    },
    249247
     
    276274    _addScript: function(script)
    277275    {
    278         var resource = WebInspector.resourceForURL(script.sourceURL);
     276        var resource = WebInspector.networkManager.inflightResourceForURL(script.sourceURL) || WebInspector.resourceForURL(script.sourceURL);
    279277        if (resource) {
    280278            if (resource.finished) {
Note: See TracChangeset for help on using the changeset viewer.