Changeset 70240 in webkit
- Timestamp:
- Oct 21, 2010 9:31:35 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 1 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r70239 r70240 1 2010-10-21 Pavel Feldman <pfeldman@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: provide resource tree in the Storage panel (behind the flag). 6 https://bugs.webkit.org/show_bug.cgi?id=48069 7 8 * WebCore.gypi: 9 * inspector/Inspector.idl: 10 * inspector/InspectorController.cpp: 11 (WebCore::InspectorController::frameDetachedFromParent): 12 * inspector/InspectorResourceAgent.cpp: 13 (WebCore::buildObjectForDocumentLoader): 14 (WebCore::buildObjectForFrameResource): 15 (WebCore::buildObjectForCachedResource): 16 (WebCore::populateObjectWithFrameResources): 17 (WebCore::InspectorResourceAgent::identifierForInitialRequest): 18 (WebCore::InspectorResourceAgent::didLoadResourceFromMemoryCache): 19 (WebCore::buildObjectForFrameTree): 20 (WebCore::InspectorResourceAgent::didCommitLoad): 21 (WebCore::InspectorResourceAgent::frameDetachedFromParent): 22 (WebCore::InspectorResourceAgent::cachedResources): 23 (WebCore::InspectorResourceAgent::resourceContent): 24 * inspector/InspectorResourceAgent.h: 25 * inspector/front-end/Images/frame.png: Added. 26 * inspector/front-end/NetworkPanel.js: 27 (WebInspector.NetworkPanel.prototype.refreshResource): 28 (WebInspector.NetworkPanel.prototype._showResource): 29 * inspector/front-end/Resource.js: 30 (WebInspector.Resource.Type.toString): 31 (WebInspector.Resource.prototype.getContents): 32 * inspector/front-end/ResourceManager.js: 33 (WebInspector.ResourceManager): 34 (WebInspector.ResourceManager.prototype.identifierForInitialRequest): 35 (WebInspector.ResourceManager.prototype._createResource): 36 (WebInspector.ResourceManager.prototype.willSendRequest): 37 (WebInspector.ResourceManager.prototype._appendRedirect): 38 (WebInspector.ResourceManager.prototype.markResourceAsCached): 39 (WebInspector.ResourceManager.prototype.didReceiveResponse): 40 (WebInspector.ResourceManager.prototype._updateResourceWithResponse): 41 (WebInspector.ResourceManager.prototype.didReceiveContentLength): 42 (WebInspector.ResourceManager.prototype.didFinishLoading): 43 (WebInspector.ResourceManager.prototype.didFailLoading): 44 (WebInspector.ResourceManager.prototype.didLoadResourceFromMemoryCache): 45 (WebInspector.ResourceManager.prototype._updateResourceWithCachedResource): 46 (WebInspector.ResourceManager.prototype.setOverrideContent): 47 (WebInspector.ResourceManager.prototype.didCommitLoadForFrame): 48 (WebInspector.ResourceManager.prototype.frameDetachedFromParent): 49 (WebInspector.ResourceManager.prototype._clearResources): 50 (WebInspector.ResourceManager.prototype.didCreateWebSocket): 51 (WebInspector.ResourceManager.prototype.willSendWebSocketHandshakeRequest): 52 (WebInspector.ResourceManager.prototype.didReceiveWebSocketHandshakeResponse): 53 (WebInspector.ResourceManager.prototype.didCloseWebSocket): 54 (WebInspector.ResourceManager.prototype._processCachedResources): 55 (WebInspector.ResourceManager.prototype._appendFramesRecursively.comparator): 56 (WebInspector.ResourceManager.prototype._appendFramesRecursively): 57 (WebInspector.ResourceManager.createResourceView): 58 (WebInspector.ResourceManager.resourceViewTypeMatchesResource): 59 (WebInspector.ResourceManager.resourceViewForResource): 60 (WebInspector.ResourceManager.getContents): 61 * inspector/front-end/ResourcesPanel.js: 62 (WebInspector.ResourcesPanel.prototype.get searchableViews): 63 (WebInspector.ResourcesPanel.prototype.addMessageToResource): 64 (WebInspector.ResourcesPanel.prototype._recreateViewForResourceIfNeeded): 65 (WebInspector.ResourcesPanel.prototype.showResource): 66 (WebInspector.ResourcesPanel.prototype.sourceFrameForResource): 67 * inspector/front-end/ScriptsPanel.js: 68 (WebInspector.ScriptsPanel.prototype._showScriptOrResource): 69 * inspector/front-end/StoragePanel.js: 70 (WebInspector.StoragePanel): 71 (WebInspector.StoragePanel.prototype.addFrame): 72 (WebInspector.StoragePanel.prototype.removeFrame): 73 (WebInspector.StoragePanel.prototype.addFrameResource): 74 (WebInspector.StoragePanel.prototype.removeFrameResources): 75 (WebInspector.StoragePanel.prototype.showResource): 76 (WebInspector.BaseStorageTreeElement.prototype.onattach): 77 (WebInspector.BaseStorageTreeElement.prototype.onreveal): 78 (WebInspector.FrameTreeElement): 79 (WebInspector.FrameTreeElement.prototype.onselect): 80 (WebInspector.FrameResourceTreeElement): 81 (WebInspector.FrameResourceTreeElement.prototype.onselect): 82 (WebInspector.FrameResourceTreeElement.prototype.onattach): 83 * inspector/front-end/WebKit.qrc: 84 * inspector/front-end/inspector.css: 85 (.frame-storage-tree-item .icon): 86 (.storage.panel .sidebar.outline-disclosure > ol): 87 (.resources-category-images .image-resource-icon-preview): 88 (.children.small .resources-category-images .image-resource-icon-preview): 89 * inspector/front-end/inspector.js: 90 1 91 2010-10-21 David Kilzer <ddkilzer@apple.com> 2 92 -
trunk/WebCore/WebCore.gypi
r70235 r70240 4509 4509 'inspector/front-end/Images/focusButtonGlyph.png', 4510 4510 'inspector/front-end/Images/forward.png', 4511 'inspector/front-end/Images/frame.png', 4511 4512 'inspector/front-end/Images/gearButtonGlyph.png', 4512 4513 'inspector/front-end/Images/glossyHeader.png', -
trunk/WebCore/inspector/Inspector.idl
r70046 r70240 113 113 [handler=Controller] void stopTimelineProfiler(); 114 114 115 [handler=Resource] void cachedResources(out Arrayresources);116 [handler=Resource] void resourceContent(in unsigned long frameI D, in String url, out String content);117 [notify] void identifierForInitialRequest(out long identifier, out String url, out unsigned long frameID, out boolean isMainResource);115 [handler=Resource] void cachedResources(out Object resources); 116 [handler=Resource] void resourceContent(in unsigned long frameId, in String url, out String content); 117 [notify] void identifierForInitialRequest(out long identifier, out String url, out Object loader, out boolean isMainResource); 118 118 [notify] void willSendRequest(out long identifier, out double time, out Object request, out Object redirectResponse); 119 119 [notify] void markResourceAsCached(out long identifier); … … 122 122 [notify] void didFinishLoading(out long identifier, out double finishTime); 123 123 [notify] void didFailLoading(out long identifier, out double time, out String localizedDescription); 124 [notify] void didLoadResourceFromMemoryCache(out double time, out unsigned long frameID, outObject resource);124 [notify] void didLoadResourceFromMemoryCache(out double time, out Object resource); 125 125 [notify] void setOverrideContent(out long identifier, out String sourceString, out String type); 126 [notify] void didCommitLoad (out unsigned long frameID);127 [notify] void frameDetachedFromParent(out unsigned long frameID);126 [notify] void didCommitLoadForFrame(out Object frameTree, out unsigned long loaderId); 127 [notify] void frameDetachedFromParent(out Object frameTree); 128 128 129 129 [notify] void didCreateWebSocket(out unsigned long identifier, out String requestURL); -
trunk/WebCore/inspector/InspectorController.cpp
r70235 r70240 827 827 } 828 828 829 void InspectorController::frameDetachedFromParent(Frame* frame)829 void InspectorController::frameDetachedFromParent(Frame* rootFrame) 830 830 { 831 831 if (!enabled()) … … 833 833 834 834 if (m_resourceAgent) 835 m_resourceAgent->frameDetachedFromParent(frame); 836 837 if (ResourcesMap* resourceMap = m_frameResources.get(frame)) 838 removeAllResources(resourceMap); 835 m_resourceAgent->frameDetachedFromParent(rootFrame); 836 837 for (Frame* frame = rootFrame; frame; frame = frame->tree()->traverseNext(rootFrame)) 838 if (ResourcesMap* resourceMap = m_frameResources.get(frame)) 839 removeAllResources(resourceMap); 839 840 } 840 841 -
trunk/WebCore/inspector/InspectorResourceAgent.cpp
r69949 r70240 200 200 } 201 201 202 static PassRefPtr<InspectorObject> buildObjectForMainResource(Frame* frame) 202 static PassRefPtr<InspectorObject> buildObjectForDocumentLoader(DocumentLoader* loader) 203 { 204 RefPtr<InspectorObject> documentLoaderObject = InspectorObject::create(); 205 documentLoaderObject->setNumber("frameId", reinterpret_cast<uintptr_t>(loader->frame())); 206 documentLoaderObject->setNumber("loaderId", reinterpret_cast<uintptr_t>(loader)); 207 return documentLoaderObject; 208 } 209 210 static PassRefPtr<InspectorObject> buildObjectForFrameResource(Frame* frame) 203 211 { 204 212 FrameLoader* frameLoader = frame->loader(); … … 207 215 RefPtr<InspectorObject> resourceObject = InspectorObject::create(); 208 216 resourceObject->setString("url", loader->url().string()); 209 resourceObject->setString("host", loader->url().host()); 210 resourceObject->setString("path", loader->url().path()); 211 resourceObject->setString("lastPathComponent", loader->url().lastPathComponent()); 212 resourceObject->setString("type", "Document"); 217 resourceObject->setObject("loader", buildObjectForDocumentLoader(loader)); 213 218 resourceObject->setObject("request", buildObjectForResourceRequest(loader->request())); 214 219 resourceObject->setObject("response", buildObjectForResourceResponse(loader->response())); … … 237 242 } 238 243 239 static PassRefPtr<InspectorObject> buildObjectForCachedResource( const CachedResource& cachedResource)244 static PassRefPtr<InspectorObject> buildObjectForCachedResource(DocumentLoader* loader, const CachedResource& cachedResource) 240 245 { 241 246 RefPtr<InspectorObject> resourceObject = InspectorObject::create(); … … 244 249 resourceObject->setNumber("encodedSize", cachedResource.encodedSize()); 245 250 resourceObject->setObject("response", buildObjectForResourceResponse(cachedResource.response())); 251 resourceObject->setObject("loader", buildObjectForDocumentLoader(loader)); 246 252 return resourceObject; 247 253 } 248 254 249 static PassRefPtr<InspectorObject> buildObjectForFrameResources(Frame* frame) 250 { 251 RefPtr<InspectorObject> frameResources = InspectorObject::create(); 252 frameResources->setNumber("frameID", reinterpret_cast<uintptr_t>(frame)); 253 frameResources->setObject("mainResource", buildObjectForMainResource(frame)); 255 static void populateObjectWithFrameResources(Frame* frame, PassRefPtr<InspectorObject> frameResources) 256 { 257 frameResources->setObject("resource", buildObjectForFrameResource(frame)); 254 258 RefPtr<InspectorArray> subresources = InspectorArray::create(); 255 259 frameResources->setArray("subresources", subresources); … … 259 263 for (CachedResourceLoader::DocumentResourceMap::const_iterator it = allResources.begin(); it != end; ++it) { 260 264 CachedResource* cachedResource = it->second.get(); 261 if (cachedResource) 262 subresources->pushValue(buildObjectForCachedResource(*cachedResource)); 263 } 264 return frameResources; 265 if (cachedResource) { 266 RefPtr<InspectorObject> cachedResourceObject = buildObjectForCachedResource(frame->loader()->documentLoader(), *cachedResource); 267 subresources->pushValue(cachedResourceObject); 268 } 269 } 265 270 } 266 271 … … 271 276 void InspectorResourceAgent::identifierForInitialRequest(unsigned long identifier, const KURL& url, DocumentLoader* loader, bool isMainResource) 272 277 { 273 m_frontend->identifierForInitialRequest(identifier, url.string(), reinterpret_cast<uintptr_t>(loader->frame()), isMainResource); 278 RefPtr<InspectorObject> loaderObject = buildObjectForDocumentLoader(loader); 279 m_frontend->identifierForInitialRequest(identifier, url.string(), loaderObject, isMainResource); 274 280 } 275 281 … … 322 328 void InspectorResourceAgent::didLoadResourceFromMemoryCache(DocumentLoader* loader, const CachedResource* resource) 323 329 { 324 Frame* frame = loader->frame(); 325 m_frontend->didLoadResourceFromMemoryCache(currentTime(), reinterpret_cast<uintptr_t>(frame), buildObjectForCachedResource(*resource)); 330 m_frontend->didLoadResourceFromMemoryCache(currentTime(), buildObjectForCachedResource(loader, *resource)); 326 331 } 327 332 … … 343 348 } 344 349 350 static PassRefPtr<InspectorObject> buildObjectForFrameTree(Frame* frame, bool dumpResources) 351 { 352 RefPtr<InspectorObject> frameObject = InspectorObject::create(); 353 frameObject->setNumber("id", reinterpret_cast<uintptr_t>(frame)); 354 if (dumpResources) 355 populateObjectWithFrameResources(frame, frameObject); 356 RefPtr<InspectorArray> childrenArray; 357 for (Frame* child = frame->tree()->firstChild(); child; child = child->tree()->nextSibling()) { 358 if (!childrenArray) { 359 childrenArray = InspectorArray::create(); 360 frameObject->setArray("children", childrenArray); 361 } 362 childrenArray->pushObject(buildObjectForFrameTree(child, dumpResources)); 363 } 364 return frameObject; 365 } 366 345 367 void InspectorResourceAgent::didCommitLoad(DocumentLoader* loader) 346 368 { 347 Frame* frame = loader->frame();348 m_frontend->didCommitLoad (reinterpret_cast<uintptr_t>(frame));369 RefPtr<InspectorObject> frameObject = buildObjectForFrameTree(loader->frame(), false); 370 m_frontend->didCommitLoadForFrame(frameObject, reinterpret_cast<uintptr_t>(loader)); 349 371 } 350 372 351 373 void InspectorResourceAgent::frameDetachedFromParent(Frame* frame) 352 374 { 353 m_frontend->frameDetachedFromParent(reinterpret_cast<uintptr_t>(frame));354 } 355 375 RefPtr<InspectorObject> frameObject = buildObjectForFrameTree(frame, false); 376 m_frontend->frameDetachedFromParent(frameObject); 377 } 356 378 357 379 #if ENABLE(WEB_SOCKETS) … … 405 427 #endif // ENABLE(WEB_SOCKETS) 406 428 407 void InspectorResourceAgent::cachedResources(RefPtr<InspectorArray>* resources) 408 { 409 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext(m_page->mainFrame())) 410 (*resources)->pushObject(buildObjectForFrameResources(frame)); 411 } 412 413 void InspectorResourceAgent::resourceContent(unsigned long frameID, const String& url, String* content) 429 void InspectorResourceAgent::cachedResources(RefPtr<InspectorObject>* object) 430 { 431 *object = buildObjectForFrameTree(m_page->mainFrame(), true); 432 } 433 434 void InspectorResourceAgent::resourceContent(unsigned long frameId, const String& url, String* content) 414 435 { 415 436 RefPtr<InspectorArray> frameResources = InspectorArray::create(); 416 437 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext(m_page->mainFrame())) { 417 if (reinterpret_cast<uintptr_t>(frame) != frameI D)438 if (reinterpret_cast<uintptr_t>(frame) != frameId) 418 439 continue; 419 440 InspectorResourceAgent::resourceContent(frame, KURL(ParsedURLString, url), content); -
trunk/WebCore/inspector/InspectorResourceAgent.h
r69948 r70240 98 98 99 99 // Called from frontend 100 void cachedResources(RefPtr<Inspector Array>*);100 void cachedResources(RefPtr<InspectorObject>*); 101 101 void resourceContent(unsigned long frameID, const String& url, String* content); 102 102 -
trunk/WebCore/inspector/front-end/NetworkPanel.js
r69948 r70240 788 788 return; 789 789 790 if (this._resourceViewTypeMatchesResource(resource, resource._resourcesView)) 791 return; 792 793 var newView = this._createResourceView(resource); 794 if (newView.__proto__ === resource._resourcesView.__proto__) 795 return; 790 if (WebInspector.ResourceManager.resourceViewTypeMatchesResource(resource, resource._resourcesView)) 791 return; 792 var newView = WebInspector.ResourceManager.createResourceView(resource); 796 793 797 794 var oldView = resource._resourcesView; … … 832 829 this.visibleResource._resourcesView.hide(); 833 830 834 var view = this._resourceViewForResource(resource);831 var view = WebInspector.ResourceManager.resourceViewForResource(resource); 835 832 view.headersVisible = true; 836 833 view.show(this._viewsContainerElement); … … 860 857 861 858 this.updateSidebarWidth(); 862 },863 864 _resourceViewForResource: function(resource)865 {866 if (!resource)867 return null;868 if (!resource._resourcesView)869 resource._resourcesView = this._createResourceView(resource);870 return resource._resourcesView;871 859 }, 872 860 … … 889 877 this._timelineGrid.element.removeStyleClass("small"); 890 878 } 891 },892 893 _createResourceView: function(resource)894 {895 switch (resource.category) {896 case WebInspector.resourceCategories.documents:897 case WebInspector.resourceCategories.stylesheets:898 case WebInspector.resourceCategories.scripts:899 case WebInspector.resourceCategories.xhr:900 return new WebInspector.SourceView(resource);901 case WebInspector.resourceCategories.images:902 return new WebInspector.ImageView(resource);903 case WebInspector.resourceCategories.fonts:904 return new WebInspector.FontView(resource);905 default:906 return new WebInspector.ResourceView(resource);907 }908 },909 910 _resourceViewTypeMatchesResource: function(resource, resourceView)911 {912 switch (resource.category) {913 case WebInspector.resourceCategories.documents:914 case WebInspector.resourceCategories.stylesheets:915 case WebInspector.resourceCategories.scripts:916 case WebInspector.resourceCategories.xhr:917 return resourceView instanceof WebInspector.SourceView;918 case WebInspector.resourceCategories.images:919 return resourceView instanceof WebInspector.ImageView;920 case WebInspector.resourceCategories.fonts:921 return resourceView instanceof WebInspector.FontView;922 default:923 return resourceView instanceof WebInspector.ResourceView;924 }925 return false;926 879 }, 927 880 -
trunk/WebCore/inspector/front-end/Resource.js
r70137 r70240 75 75 return "script"; 76 76 case this.XHR: 77 return " XHR";77 return "xhr"; 78 78 case this.Media: 79 79 return "media"; 80 80 case this.WebSocket: 81 return " WebSocket";81 return "websocket"; 82 82 case this.Other: 83 83 default: … … 594 594 getContents: function(callback) 595 595 { 596 // FIXME: eventually, cached resources will have no identifiers. 597 if (this.frameID) 598 InspectorBackend.resourceContent(this.frameID, this.url, callback); 599 else 600 InspectorBackend.getResourceContent(this.identifier, false, callback); 596 WebInspector.ResourceManager.getContents(this, callback); 601 597 } 602 598 } -
trunk/WebCore/inspector/front-end/ResourceManager.js
r69948 r70240 41 41 "didLoadResourceFromMemoryCache", 42 42 "setOverrideContent", 43 "didCommitLoad ",43 "didCommitLoadForFrame", 44 44 "frameDetachedFromParent", 45 45 "didCreateWebSocket", … … 48 48 "didCloseWebSocket"); 49 49 50 this._resources = {};50 this._resourcesById = {}; 51 51 this._resourcesByFrame = {}; 52 52 this._lastCachedId = 0; 53 InspectorBackend.cachedResources(this._processCachedResources.bind(this)); 53 54 } 54 55 … … 60 61 }, 61 62 62 identifierForInitialRequest: function(identifier, url, frameID, isMainResource)63 { 64 var resource = new WebInspector.Resource(identifier, url);63 identifierForInitialRequest: function(identifier, url, loader, isMainResource) 64 { 65 var resource = this._createResource(identifier, url, loader); 65 66 if (isMainResource) 66 67 resource.isMainResource = true; 67 this._resources[identifier] = resource; 68 69 if (frameID) { 70 resource.frameID = frameID; 71 var resourcesForFrame = this._resourcesByFrame[frameID]; 72 if (!resourcesForFrame) { 73 resourcesForFrame = []; 74 this._resourcesByFrame[frameID] = resourcesForFrame; 75 } 76 resourcesForFrame.push(resource); 77 } 78 79 if (WebInspector.panels.network) 80 WebInspector.panels.network.addResource(resource); 68 69 WebInspector.panels.network.addResource(resource); 70 }, 71 72 _createResource: function(identifier, url, loader) 73 { 74 var resource = new WebInspector.Resource(identifier, url); 75 this._resourcesById[identifier] = resource; 76 77 resource.loader = loader; 78 var resourcesForFrame = this._resourcesByFrame[loader.frameId]; 79 if (!resourcesForFrame) { 80 resourcesForFrame = {}; 81 this._resourcesByFrame[loader.frameId] = resourcesForFrame; 82 } 83 resourcesForFrame[resource.identifier] = resource; 84 return resource; 81 85 }, 82 86 83 87 willSendRequest: function(identifier, time, request, redirectResponse) 84 88 { 85 var resource = this._resources [identifier];89 var resource = this._resourcesById[identifier]; 86 90 if (!resource) 87 91 return; … … 89 93 // Redirect may have empty URL and we'd like to not crash with invalid HashMap entry. 90 94 // See http/tests/misc/will-send-request-returns-null-on-redirect.html 91 if (!redirectResponse.isNull && request.url.length) { 95 var isRedirect = !redirectResponse.isNull && request.url.length; 96 if (isRedirect) { 92 97 resource.endTime = time; 93 98 this.didReceiveResponse(identifier, time, "Other", redirectResponse); … … 100 105 resource.startTime = time; 101 106 102 if (WebInspector.panels.network) 107 if (isRedirect) 108 WebInspector.panels.network.addResource(resource); 109 else 103 110 WebInspector.panels.network.refreshResource(resource); 104 111 }, … … 108 115 // We always store last redirect by the original id key. Rest of the redirects are referenced from within the last one. 109 116 110 var originalResource = this._resources [identifier];117 var originalResource = this._resourcesById[identifier]; 111 118 var redirectIdentifier = originalResource.identifier + ":" + (originalResource.redirects ? originalResource.redirects.length : 0); 112 119 originalResource.identifier = redirectIdentifier; 113 this._resources[redirectIdentifier] = originalResource; 114 115 this.identifierForInitialRequest(identifier, redirectURL, originalResource.frameID); 116 117 var newResource = this._resources[identifier]; 120 this._resourcesById[redirectIdentifier] = originalResource; 121 122 var newResource = this._createResource(identifier, redirectURL, originalResource.loader); 118 123 newResource.redirects = originalResource.redirects || []; 119 124 delete originalResource.redirects; … … 124 129 markResourceAsCached: function(identifier) 125 130 { 126 var resource = this._resources [identifier];131 var resource = this._resourcesById[identifier]; 127 132 if (!resource) 128 133 return; 129 134 130 135 resource.cached = true; 131 132 if (WebInspector.panels.network) 133 WebInspector.panels.network.refreshResource(resource); 136 WebInspector.panels.network.refreshResource(resource); 134 137 }, 135 138 136 139 didReceiveResponse: function(identifier, time, resourceType, response) 137 140 { 138 var resource = this._resources [identifier];139 if (!resource) 140 return; 141 141 var resource = this._resourcesById[identifier]; 142 if (!resource) 143 return; 144 this._updateResourceWithResponse(resource, response); 142 145 resource.type = WebInspector.Resource.Type[resourceType]; 146 resource.responseReceivedTime = time; 147 148 WebInspector.panels.network.refreshResource(resource); 149 }, 150 151 _updateResourceWithResponse: function(resource, response) 152 { 143 153 resource.mimeType = response.mimeType; 144 154 resource.expectedContentLength = response.expectedContentLength; … … 151 161 resource.connectionReused = response.connectionReused; 152 162 resource.connectionID = response.connectionID; 153 resource.responseReceivedTime = time;154 163 155 164 if (response.wasCached) … … 162 171 resource.responseHeaders = response.rawHeaders.responseHeaders; 163 172 } 164 165 if (WebInspector.panels.network)166 WebInspector.panels.network.refreshResource(resource);167 173 }, 168 174 169 175 didReceiveContentLength: function(identifier, time, lengthReceived) 170 176 { 171 var resource = this._resources [identifier];177 var resource = this._resourcesById[identifier]; 172 178 if (!resource) 173 179 return; … … 176 182 resource.endTime = time; 177 183 178 if (WebInspector.panels.network) 179 WebInspector.panels.network.refreshResource(resource); 184 WebInspector.panels.network.refreshResource(resource); 180 185 }, 181 186 182 187 didFinishLoading: function(identifier, finishTime) 183 188 { 184 var resource = this._resources [identifier];189 var resource = this._resourcesById[identifier]; 185 190 if (!resource) 186 191 return; … … 189 194 resource.endTime = finishTime; 190 195 191 if (WebInspector.panels.network) 192 WebInspector.panels.network.refreshResource(resource); 196 WebInspector.panels.network.refreshResource(resource); 193 197 }, 194 198 195 199 didFailLoading: function(identifier, time, localizedDescription) 196 200 { 197 var resource = this._resources [identifier];201 var resource = this._resourcesById[identifier]; 198 202 if (!resource) 199 203 return; … … 202 206 resource.endTime = time; 203 207 204 if (WebInspector.panels.network) 205 WebInspector.panels.network.refreshResource(resource); 206 }, 207 208 didLoadResourceFromMemoryCache: function(time, frameID, cachedResource) 208 WebInspector.panels.network.refreshResource(resource); 209 }, 210 211 didLoadResourceFromMemoryCache: function(time, cachedResource) 209 212 { 210 213 var identifier = "cached:" + this._lastCachedId++; 211 this.identifierForInitialRequest(identifier, cachedResource.url, frameID); 212 213 var resource = this._resources[identifier]; 214 var resource = this._createResource(identifier, cachedResource.url, cachedResource.loader); 215 this._updateResourceWithCachedResource(resource, cachedResource); 214 216 resource.cached = true; 215 resource.startTime = resource.responseReceivedTime = time; 216 resource.resourceSize = cachedResource.encodedSize(); 217 218 this.didReceiveResponse(identifier, time, cachedResource.response); 217 resource.startTime = resource.responseReceivedTime = resource.endTime = time; 218 219 WebInspector.panels.network.addResource(resource); 220 }, 221 222 _updateResourceWithCachedResource: function(resource, cachedResource) 223 { 224 resource.type = WebInspector.Resource.Type[cachedResource.type]; 225 resource.resourceSize = cachedResource.encodedSize; 226 this._updateResourceWithResponse(resource, cachedResource.response); 219 227 }, 220 228 221 229 setOverrideContent: function(identifier, sourceString, type) 222 230 { 223 var resource = this._resources [identifier];231 var resource = this._resourcesById[identifier]; 224 232 if (!resource) 225 233 return; … … 228 236 resource.overridenContent = sourceString; 229 237 230 if (WebInspector.panels.network) 231 WebInspector.panels.network.addResource(resource); 232 }, 233 234 didCommitLoad: function(frameID) 235 { 236 }, 237 238 frameDetachedFromParent: function(frameID) 239 { 240 var resourcesForFrame = this._resourcesByFrame[frameID]; 241 for (var i = 0; resourcesForFrame && i < resourcesForFrame.length; ++i) 242 delete this._resources[resourcesForFrame[i].identifier]; 243 delete this._resourcesByFrame[frameID]; 238 WebInspector.panels.network.addResource(resource); 239 }, 240 241 didCommitLoadForFrame: function(frameTree, loaderId) 242 { 243 this._clearResources(frameTree.id, loaderId); 244 for (var i = 0; frameTree.children && frameTree.children.length; ++i) 245 this.didCommitLoadForFrame(frameTree.children[i], loaderId); 246 }, 247 248 frameDetachedFromParent: function(frameTree) 249 { 250 this.didCommitLoadForFrame(frameTree, 0); 251 }, 252 253 _clearResources: function(frameId, loaderToPreserveId) 254 { 255 var resourcesForFrame = this._resourcesByFrame[frameId]; 256 if (resourcesForFrame) 257 return; 258 259 for (var id in resourcesForFrame) { 260 var resource = this._resourcesById[id]; 261 if (resource.loaderId === loaderToPreserveId) 262 continue; 263 delete this._resourcesById[id]; 264 delete resourcesForFrame[id]; 265 } 266 if (!Object.keys(resourcesForFrame).length) 267 delete this._resourcesByFrame[frameId]; 244 268 }, 245 269 … … 247 271 { 248 272 this.identifierForInitialRequest(identifier, requestURL); 249 var resource = this._resources [identifier];273 var resource = this._resourcesById[identifier]; 250 274 resource.type = WebInspector.Resource.Type.WebSocket; 251 275 252 if (WebInspector.panels.network) 253 WebInspector.panels.network.addResource(resource); 276 WebInspector.panels.network.addResource(resource); 254 277 }, 255 278 256 279 willSendWebSocketHandshakeRequest: function(identifier, time, request) 257 280 { 258 var resource = this._resources [identifier];281 var resource = this._resourcesById[identifier]; 259 282 if (!resource) 260 283 return; … … 265 288 resource.startTime = time; 266 289 267 if (WebInspector.panels.network) 268 WebInspector.panels.network.refreshResource(resource); 290 WebInspector.panels.network.refreshResource(resource); 269 291 }, 270 292 271 293 didReceiveWebSocketHandshakeResponse: function(identifier, time, response) 272 294 { 273 var resource = this._resources [identifier];295 var resource = this._resourcesById[identifier]; 274 296 if (!resource) 275 297 return; … … 281 303 resource.responseReceivedTime = time; 282 304 283 if (WebInspector.panels.network) 284 WebInspector.panels.network.refreshResource(resource); 305 WebInspector.panels.network.refreshResource(resource); 285 306 }, 286 307 287 308 didCloseWebSocket: function(identifier, time) 288 309 { 289 var resource = this._resources [identifier];310 var resource = this._resourcesById[identifier]; 290 311 if (!resource) 291 312 return; 292 313 resource.endTime = time; 293 314 294 if (WebInspector.panels.network) 295 WebInspector.panels.network.refreshResource(resource); 315 WebInspector.panels.network.refreshResource(resource); 316 }, 317 318 _processCachedResources: function(mainFramePayload) 319 { 320 this._appendFramesRecursively(null, mainFramePayload); 321 }, 322 323 _appendFramesRecursively: function(parentFrameId, framePayload) 324 { 325 var frameResource = this._createResource(null, framePayload.resource.url, framePayload.resource.loader); 326 frameResource.type = WebInspector.Resource.Type["Document"]; 327 WebInspector.panels.storage.addFrame(parentFrameId, framePayload.id, frameResource); 328 329 for (var i = 0; framePayload.children && i < framePayload.children.length; ++i) 330 this._appendFramesRecursively(framePayload.id, framePayload.children[i]); 331 332 if (!framePayload.subresources) 333 return; 334 335 var resources = []; 336 for (var i = 0; i < framePayload.subresources.length; ++i) { 337 var cachedResource = framePayload.subresources[i]; 338 var resource = this._createResource(null, cachedResource.url, cachedResource.loader); 339 this._updateResourceWithCachedResource(resource, cachedResource); 340 resources.push(resource); 341 } 342 343 function comparator(a, b) 344 { 345 return a.displayName.localeCompare(b.displayName); 346 } 347 resources.sort(comparator); 348 349 for (var i = 0; i < resources.length; ++i) 350 WebInspector.panels.storage.addFrameResource(framePayload.id, resources[i]); 296 351 } 297 352 } 353 354 WebInspector.ResourceManager.createResourceView = function(resource) 355 { 356 switch (resource.category) { 357 case WebInspector.resourceCategories.documents: 358 case WebInspector.resourceCategories.stylesheets: 359 case WebInspector.resourceCategories.scripts: 360 case WebInspector.resourceCategories.xhr: 361 return new WebInspector.SourceView(resource); 362 case WebInspector.resourceCategories.images: 363 return new WebInspector.ImageView(resource); 364 case WebInspector.resourceCategories.fonts: 365 return new WebInspector.FontView(resource); 366 default: 367 return new WebInspector.ResourceView(resource); 368 } 369 } 370 371 WebInspector.ResourceManager.resourceViewTypeMatchesResource = function(resource, resourceView) 372 { 373 switch (resource.category) { 374 case WebInspector.resourceCategories.documents: 375 case WebInspector.resourceCategories.stylesheets: 376 case WebInspector.resourceCategories.scripts: 377 case WebInspector.resourceCategories.xhr: 378 return resourceView.__proto__ === WebInspector.SourceView.prototype; 379 case WebInspector.resourceCategories.images: 380 return resourceView.__proto__ === WebInspector.ImageView.prototype; 381 case WebInspector.resourceCategories.fonts: 382 return resourceView.__proto__ === WebInspector.FontView.prototype; 383 default: 384 return resourceView.__proto__ === WebInspector.ResourceView.prototype; 385 } 386 } 387 388 WebInspector.ResourceManager.resourceViewForResource = function(resource) 389 { 390 if (!resource) 391 return null; 392 if (!resource._resourcesView) 393 resource._resourcesView = WebInspector.ResourceManager.createResourceView(resource); 394 return resource._resourcesView; 395 } 396 397 WebInspector.ResourceManager.getContents = function(resource, callback) 398 { 399 // FIXME: eventually, cached resources will have no identifiers. 400 if (resource.loader) 401 InspectorBackend.resourceContent(resource.loader.frameId, resource.url, callback); 402 else 403 InspectorBackend.getResourceContent(resource.identifier, false, callback); 404 } -
trunk/WebCore/inspector/front-end/ResourcesPanel.js
r70102 r70240 558 558 if (!resource._itemsTreeElement || !resource._itemsTreeElement.selectable) 559 559 continue; 560 var resourceView = this.resourceViewForResource(resource);560 var resourceView = WebInspector.ResourceManager.resourceViewForResource(resource); 561 561 if (!resourceView.performSearch || resourceView === visibleView) 562 562 continue; … … 790 790 resource._itemsTreeElement.updateErrorsAndWarnings(); 791 791 792 var view = this.resourceViewForResource(resource);792 var view = WebInspector.ResourceManager.resourceViewForResource(resource); 793 793 if (view.addMessage) 794 794 view.addMessage(msg); … … 824 824 return; 825 825 826 if ( this._resourceViewIsConsistentWithCategory(resource, resource._resourcesView))826 if (WebInspector.ResourceManager.resourceViewTypeMatchesResource(resource, resource._resourcesView)) 827 827 return; 828 829 var newView = this._createResourceView(resource); 828 var newView = WebInspector.ResourceManager.createResourceView(resource); 829 830 830 if (!this.currentQuery && resource._itemsTreeElement) 831 831 resource._itemsTreeElement.updateErrorsAndWarnings(); … … 869 869 this.visibleResource._resourcesView.hide(); 870 870 871 var view = this.resourceViewForResource(resource);871 var view = WebInspector.ResourceManager.resourceViewForResource(resource); 872 872 view.headersVisible = true; 873 873 view.show(this.viewsContainerElement); … … 910 910 }, 911 911 912 resourceViewForResource: function(resource)913 {914 if (!resource)915 return null;916 if (!resource._resourcesView)917 resource._resourcesView = this._createResourceView(resource);918 return resource._resourcesView;919 },920 921 912 sourceFrameForResource: function(resource) 922 913 { 923 var view = this.resourceViewForResource(resource);914 var view = WebInspector.ResourceManager.resourceViewForResource(resource); 924 915 if (!view) 925 916 return null; … … 1067 1058 this.sortingFunction = selectedOption.sortingFunction; 1068 1059 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 }1086 },1087 1088 _createResourceView: function(resource)1089 {1090 switch (resource.category) {1091 case WebInspector.resourceCategories.documents:1092 case WebInspector.resourceCategories.stylesheets:1093 case WebInspector.resourceCategories.scripts:1094 case WebInspector.resourceCategories.xhr:1095 return new WebInspector.SourceView(resource);1096 case WebInspector.resourceCategories.images:1097 return new WebInspector.ImageView(resource);1098 case WebInspector.resourceCategories.fonts:1099 return new WebInspector.FontView(resource);1100 default:1101 return new WebInspector.ResourceView(resource);1102 }1103 1060 }, 1104 1061 -
trunk/WebCore/inspector/front-end/ScriptsPanel.js
r70054 r70240 588 588 if (!WebInspector.panels.resources) 589 589 return null; 590 view = WebInspector. panels.resources.resourceViewForResource(scriptOrResource);590 view = WebInspector.ResourceManager.resourceViewForResource(scriptOrResource); 591 591 view.headersVisible = false; 592 592 } else if (scriptOrResource instanceof WebInspector.Script) -
trunk/WebCore/inspector/front-end/StoragePanel.js
r70214 r70240 35 35 this.sidebarElement.addStyleClass("outline-disclosure filter-all children small"); 36 36 37 if (Preferences.networkPanelEnabled) { 38 this.resourcesListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Resources"), "frame-storage-tree-item"); 39 this.sidebarTree.appendChild(this.resourcesListTreeElement); 40 this.resourcesListTreeElement.expand(); 41 this._treeElementForFrameId = {}; 42 } 43 37 44 this.databasesListTreeElement = new WebInspector.StorageCategoryTreeElement(this, WebInspector.UIString("Databases"), "database-storage-tree-item"); 38 45 this.sidebarTree.appendChild(this.databasesListTreeElement); … … 111 118 if (this.sidebarTree.selectedTreeElement) 112 119 this.sidebarTree.selectedTreeElement.deselect(); 120 }, 121 122 addFrame: function(parentFrameId, frameId, frameResource) 123 { 124 var parentTreeElement = parentFrameId ? this._treeElementForFrameId[parentFrameId] : this.resourcesListTreeElement; 125 if (!parentTreeElement) { 126 console.error("No frame with id:" + parentFrameId + " to route " + displayName + " to.") 127 return; 128 } 129 130 var frameTreeElement = new WebInspector.FrameTreeElement(this, frameId, frameResource); 131 this._treeElementForFrameId[frameId] = frameTreeElement; 132 parentTreeElement.appendChild(frameTreeElement); 133 }, 134 135 removeFrame: function(frameId) 136 { 137 var frameTreeElement = this._treeElementForFrameId[frameId]; 138 if (!frameTreeElement) { 139 console.error("No frame with id:" + frameId + " to remove."); 140 return; 141 } 142 143 delete this._treeElementForFrameId[frameId]; 144 frameTreeElement.parent.removeChild(frameTreeElement); 145 }, 146 147 addFrameResource: function(frameId, resource) 148 { 149 var frameTreeElement = this._treeElementForFrameId[frameId]; 150 if (!frameTreeElement) { 151 console.error("No frame with id:" + frameId + " to add resource to."); 152 return; 153 } 154 155 var resourceTreeElement = new WebInspector.FrameResourceTreeElement(this, resource); 156 frameTreeElement.appendChild(resourceTreeElement); 157 }, 158 159 removeFrameResources: function(frameId) 160 { 161 var frameTreeElement = this._treeElementForFrameId[frameId]; 162 if (!frameTreeElement) { 163 console.error("No frame with id:" + frameId + " to remove resources from."); 164 return; 165 } 166 frameTreeElement.removeChildren(); 113 167 }, 114 168 … … 165 219 domStorage._domStorageTreeElement.select(); 166 220 } 221 }, 222 223 showResource: function(resource) 224 { 225 var view = WebInspector.ResourceManager.resourceViewForResource(resource); 226 view.headersVisible = false; 227 this._innerShowView(view); 167 228 }, 168 229 … … 429 490 this.listItemElement.addStyleClass(this._iconClass); 430 491 431 varimageElement = document.createElement("img");432 imageElement.className = "icon";433 this.listItemElement.appendChild( imageElement);492 this.imageElement = document.createElement("img"); 493 this.imageElement.className = "icon"; 494 this.listItemElement.appendChild(this.imageElement); 434 495 435 496 var titleElement = document.createElement("span"); … … 441 502 selectionElement.className = "selection"; 442 503 this.listItemElement.appendChild(selectionElement); 504 }, 505 506 onreveal: function() 507 { 508 if (this.listItemElement) 509 this.listItemElement.scrollIntoViewIfNeeded(false); 443 510 } 444 511 } … … 459 526 } 460 527 WebInspector.StorageCategoryTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; 528 529 WebInspector.FrameTreeElement = function(storagePanel, frameId, frameResource) 530 { 531 WebInspector.BaseStorageTreeElement.call(this, storagePanel, frameResource.displayName, "frame-storage-tree-item"); 532 this._frameId = frameId; 533 this._resource = frameResource; 534 } 535 536 WebInspector.FrameTreeElement.prototype = { 537 onselect: function() 538 { 539 this._storagePanel.showResource(this._resource); 540 } 541 } 542 WebInspector.FrameTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; 543 544 WebInspector.FrameResourceTreeElement = function(storagePanel, resource) 545 { 546 WebInspector.BaseStorageTreeElement.call(this, storagePanel, resource.displayName, "resource-sidebar-tree-item resources-category-" + resource.category.name); 547 this._resource = resource; 548 } 549 550 WebInspector.FrameResourceTreeElement.prototype = { 551 onselect: function() 552 { 553 this._storagePanel.showResource(this._resource); 554 }, 555 556 onattach: function() 557 { 558 WebInspector.BaseStorageTreeElement.prototype.onattach.call(this); 559 560 if (this._resource.category === WebInspector.resourceCategories.images) { 561 var previewImage = document.createElement("img"); 562 previewImage.className = "image-resource-icon-preview"; 563 previewImage.src = this._resource.url; 564 565 var iconElement = document.createElement("div"); 566 iconElement.className = "icon"; 567 iconElement.appendChild(previewImage); 568 this.listItemElement.replaceChild(iconElement, this.imageElement); 569 } 570 } 571 } 572 573 WebInspector.FrameResourceTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; 461 574 462 575 WebInspector.DatabaseTreeElement = function(storagePanel, database) -
trunk/WebCore/inspector/front-end/WebKit.qrc
r70137 r70240 159 159 <file>Images/focusButtonGlyph.png</file> 160 160 <file>Images/forward.png</file> 161 <file>Images/frame.png</file> 161 162 <file>Images/gearButtonGlyph.png</file> 162 163 <file>Images/glossyHeader.png</file> -
trunk/WebCore/inspector/front-end/inspector.css
r70214 r70240 1882 1882 } 1883 1883 1884 .frame-storage-tree-item .icon { 1885 content: url(Images/frame.png); 1886 } 1887 1884 1888 .database-storage-tree-item .icon { 1885 1889 content: url(Images/database.png); … … 1920 1924 } 1921 1925 1922 .storage.panel . outline-disclosure > ol {1926 .storage.panel .sidebar.outline-disclosure > ol { 1923 1927 margin-left: -12px; 1924 1928 padding-right: 0px !important; … … 3395 3399 } 3396 3400 3397 .resource -sidebar-tree-item.resources-category-images .image-resource-icon-preview {3401 .resources-category-images .image-resource-icon-preview { 3398 3402 position: absolute; 3399 3403 margin: auto; … … 3413 3417 } 3414 3418 3415 .children.small .resource -sidebar-tree-item.resources-category-images .image-resource-icon-preview {3419 .children.small .resources-category-images .image-resource-icon-preview { 3416 3420 top: 2px; 3417 3421 bottom: 1px; -
trunk/WebCore/inspector/front-end/inspector.js
r70045 r70240 508 508 // TODO: Remove class="hidden" from inspector.html on button#changes-status-bar-item 509 509 this.drawer.visibleView = this.console; 510 // FIXME: uncomment when ready.511 //this.resourceManager = new WebInspector.ResourceManager();510 if (Preferences.networkPanelEnabled) 511 this.resourceManager = new WebInspector.ResourceManager(); 512 512 this.domAgent = new WebInspector.DOMAgent(); 513 513
Note: See TracChangeset
for help on using the changeset viewer.