Changeset 70305 in webkit
- Timestamp:
- Oct 22, 2010 6:33:14 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r70304 r70305 1 2010-10-22 Pavel Feldman <pfeldman@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 Web Inspector: update resources tree in storage panel upon network events. 6 https://bugs.webkit.org/show_bug.cgi?id=48121 7 8 * inspector/Inspector.idl: 9 * inspector/InspectorResourceAgent.cpp: 10 (WebCore::buildObjectForDocumentLoader): 11 (WebCore::buildObjectForFrameTree): 12 (WebCore::InspectorResourceAgent::didCommitLoad): 13 (WebCore::InspectorResourceAgent::frameDetachedFromParent): 14 * inspector/front-end/ResourceManager.js: 15 (WebInspector.ResourceManager): 16 (WebInspector.ResourceManager.prototype._createResource): 17 (WebInspector.ResourceManager.prototype.didReceiveResponse): 18 (WebInspector.ResourceManager.prototype.didLoadResourceFromMemoryCache): 19 (WebInspector.ResourceManager.prototype.didCommitLoadForFrame): 20 (WebInspector.ResourceManager.prototype._addResourceToStorageFrame): 21 (WebInspector.ResourceManager.prototype.frameDetachedFromParent): 22 (WebInspector.ResourceManager.prototype._clearResources): 23 (WebInspector.ResourceManager.prototype._processCachedResources): 24 (WebInspector.ResourceManager.prototype._addFramesRecursively): 25 (WebInspector.ResourceManager.getContents): 26 * inspector/front-end/StoragePanel.js: 27 (WebInspector.StoragePanel.prototype.addOrUpdateFrame): 28 (WebInspector.StoragePanel.prototype.removeFrame): 29 (WebInspector.StoragePanel.prototype.addResourceToFrame): 30 (WebInspector.StoragePanel.prototype.removeResourcesFromFrame): 31 (WebInspector.BaseStorageTreeElement.prototype.onattach): 32 (WebInspector.BaseStorageTreeElement.prototype.onreveal): 33 (WebInspector.BaseStorageTreeElement.prototype.set titleText): 34 (WebInspector.FrameTreeElement): 35 (WebInspector.FrameTreeElement.prototype.onselect): 36 (WebInspector.FrameTreeElement.prototype.get displayName): 37 (WebInspector.FrameTreeElement.prototype.set displayName): 38 1 39 2010-10-22 François Sausset <sausset@gmail.com> 2 40 -
trunk/WebCore/inspector/Inspector.idl
r70240 r70305 124 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 didCommitLoadForFrame(out Object frameTree, out unsigned long loaderId);127 [notify] void frameDetachedFromParent(out Object frameTree);126 [notify] void didCommitLoadForFrame(out unsigned long parentFrameId, out Object loader); 127 [notify] void frameDetachedFromParent(out unsigned long frameId); 128 128 129 129 [notify] void didCreateWebSocket(out unsigned long identifier, out String requestURL); -
trunk/WebCore/inspector/InspectorResourceAgent.cpp
r70240 r70305 205 205 documentLoaderObject->setNumber("frameId", reinterpret_cast<uintptr_t>(loader->frame())); 206 206 documentLoaderObject->setNumber("loaderId", reinterpret_cast<uintptr_t>(loader)); 207 documentLoaderObject->setString("url", loader->requestURL().string()); 207 208 return documentLoaderObject; 208 209 } … … 351 352 { 352 353 RefPtr<InspectorObject> frameObject = InspectorObject::create(); 354 frameObject->setNumber("parentId", reinterpret_cast<uintptr_t>(frame->tree()->parent())); 353 355 frameObject->setNumber("id", reinterpret_cast<uintptr_t>(frame)); 354 356 if (dumpResources) … … 367 369 void InspectorResourceAgent::didCommitLoad(DocumentLoader* loader) 368 370 { 369 RefPtr<InspectorObject> frameObject = buildObjectForFrameTree(loader->frame(), false);370 m_frontend->didCommitLoadForFrame( frameObject, reinterpret_cast<uintptr_t>(loader));371 Frame* parentFrame = loader->frame()->tree()->parent(); 372 m_frontend->didCommitLoadForFrame(reinterpret_cast<uintptr_t>(parentFrame), buildObjectForDocumentLoader(loader)); 371 373 } 372 374 373 375 void InspectorResourceAgent::frameDetachedFromParent(Frame* frame) 374 376 { 375 RefPtr<InspectorObject> frameObject = buildObjectForFrameTree(frame, false); 376 m_frontend->frameDetachedFromParent(frameObject); 377 m_frontend->frameDetachedFromParent(reinterpret_cast<uintptr_t>(frame)); 377 378 } 378 379 -
trunk/WebCore/inspector/front-end/ResourceManager.js
r70240 r70305 49 49 50 50 this._resourcesById = {}; 51 this._resourcesByFrame = {};51 this._resourcesByFrameId = {}; 52 52 this._lastCachedId = 0; 53 53 InspectorBackend.cachedResources(this._processCachedResources.bind(this)); … … 76 76 77 77 resource.loader = loader; 78 var resourcesForFrame = this._resourcesByFrame [loader.frameId];78 var resourcesForFrame = this._resourcesByFrameId[loader.frameId]; 79 79 if (!resourcesForFrame) { 80 resourcesForFrame = {};81 this._resourcesByFrame [loader.frameId] = resourcesForFrame;80 resourcesForFrame = []; 81 this._resourcesByFrameId[loader.frameId] = resourcesForFrame; 82 82 } 83 resourcesForFrame [resource.identifier] = resource;83 resourcesForFrame.push(resource); 84 84 return resource; 85 85 }, … … 147 147 148 148 WebInspector.panels.network.refreshResource(resource); 149 this._addResourceToStorageFrame(resource.loader.frameId, resource); 149 150 }, 150 151 … … 218 219 219 220 WebInspector.panels.network.addResource(resource); 221 WebInspector.panels.storage.addResourceToFrame(resource.loader.frameId, resource); 220 222 }, 221 223 … … 239 241 }, 240 242 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); 243 didCommitLoadForFrame: function(parentFrameId, loader) 244 { 245 this._clearResources(loader.frameId, loader.loaderId); 246 WebInspector.panels.storage.removeResourcesFromFrame(loader.frameId); 247 248 var tmpResource = new WebInspector.Resource(null, loader.url); 249 WebInspector.panels.storage.addOrUpdateFrame(parentFrameId, loader.frameId, tmpResource.displayName); 250 251 var resourcesForFrame = this._resourcesByFrameId[loader.frameId]; 252 for (var i = 0; i < resourcesForFrame.length; ++i) 253 this._addResourceToStorageFrame(loader.frameId, resourcesForFrame[i]); 254 }, 255 256 _addResourceToStorageFrame: function(frameId, resource) 257 { 258 // Do not show redirects in resource browser. 259 if (resource.statusCode < 300 || resource.statusCode > 303) 260 WebInspector.panels.storage.addResourceToFrame(frameId, resource); 261 }, 262 263 frameDetachedFromParent: function(frameId) 264 { 265 this._clearResources(frameId, 0); 266 WebInspector.panels.storage.removeFrame(frameId); 251 267 }, 252 268 253 269 _clearResources: function(frameId, loaderToPreserveId) 254 270 { 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) 271 var resourcesForFrame = this._resourcesByFrameId[frameId]; 272 if (!resourcesForFrame) 273 return; 274 275 var preservedResourcesForFrame = []; 276 for (var i = 0; i < resourcesForFrame.length; ++i) { 277 var resource = resourcesForFrame[i]; 278 if (resource.loader.loaderId === loaderToPreserveId) { 279 preservedResourcesForFrame.push(resource); 262 280 continue; 281 } 263 282 delete this._resourcesById[id]; 264 delete resourcesForFrame[id];265 283 } 266 if (!Object.keys(resourcesForFrame).length) 267 delete this._resourcesByFrame[frameId]; 284 delete this._resourcesByFrameId[frameId]; 285 if (preservedResourcesForFrame.length) 286 this._resourcesByFrameId[frameId] = preservedResourcesForFrame; 268 287 }, 269 288 … … 318 337 _processCachedResources: function(mainFramePayload) 319 338 { 320 this._a ppendFramesRecursively(null, mainFramePayload);321 }, 322 323 _a ppendFramesRecursively: function(parentFrameId, framePayload)339 this._addFramesRecursively(null, mainFramePayload); 340 }, 341 342 _addFramesRecursively: function(parentFrameId, framePayload) 324 343 { 325 344 var frameResource = this._createResource(null, framePayload.resource.url, framePayload.resource.loader); 326 345 frameResource.type = WebInspector.Resource.Type["Document"]; 327 WebInspector.panels.storage.addFrame(parentFrameId, framePayload.id, frameResource); 346 WebInspector.panels.storage.addOrUpdateFrame(parentFrameId, framePayload.id, frameResource.displayName); 347 WebInspector.panels.storage.addResourceToFrame(framePayload.id, frameResource); 328 348 329 349 for (var i = 0; framePayload.children && i < framePayload.children.length; ++i) 330 this._a ppendFramesRecursively(framePayload.id, framePayload.children[i]);350 this._addFramesRecursively(framePayload.id, framePayload.children[i]); 331 351 332 352 if (!framePayload.subresources) 333 353 return; 334 354 335 var resources = [];336 355 for (var i = 0; i < framePayload.subresources.length; ++i) { 337 356 var cachedResource = framePayload.subresources[i]; 338 357 var resource = this._createResource(null, cachedResource.url, cachedResource.loader); 339 358 this._updateResourceWithCachedResource(resource, cachedResource); 340 resources.push(resource);359 WebInspector.panels.storage.addResourceToFrame(framePayload.id, resource); 341 360 } 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]);351 361 } 352 362 } … … 397 407 WebInspector.ResourceManager.getContents = function(resource, callback) 398 408 { 409 if ("overridenContent" in resource) { 410 callback(resource.overridenContent); 411 return; 412 } 413 399 414 // FIXME: eventually, cached resources will have no identifiers. 400 415 if (resource.loader) -
trunk/WebCore/inspector/front-end/StoragePanel.js
r70240 r70305 120 120 }, 121 121 122 addFrame: function(parentFrameId, frameId, frameResource) 123 { 122 addOrUpdateFrame: function(parentFrameId, frameId, displayName) 123 { 124 var frameTreeElement = this._treeElementForFrameId[frameId]; 125 if (frameTreeElement) { 126 frameTreeElement.displayName = displayName; 127 return; 128 } 129 124 130 var parentTreeElement = parentFrameId ? this._treeElementForFrameId[parentFrameId] : this.resourcesListTreeElement; 125 131 if (!parentTreeElement) { … … 128 134 } 129 135 130 var frameTreeElement = new WebInspector.FrameTreeElement(this, frameId, frameResource);136 var frameTreeElement = new WebInspector.FrameTreeElement(this, frameId, displayName); 131 137 this._treeElementForFrameId[frameId] = frameTreeElement; 138 139 // Insert in the alphabetical order, first frames, then resources. 140 var children = parentTreeElement.children; 141 for (var i = 0; i < children.length; ++i) { 142 var child = children[i]; 143 if (!(child instanceof WebInspector.FrameTreeElement)) { 144 parentTreeElement.insertChild(frameTreeElement, i); 145 return; 146 } 147 if (child.displayName.localeCompare(frameTreeElement.displayName) > 0) { 148 parentTreeElement.insertChild(frameTreeElement, i); 149 return; 150 } 151 } 132 152 parentTreeElement.appendChild(frameTreeElement); 133 153 }, 134 154 135 155 removeFrame: function(frameId) 156 { 157 var frameTreeElement = this._treeElementForFrameId[frameId]; 158 if (!frameTreeElement) 159 return; 160 161 var children = frameTreeElement.children.slice(); 162 for (var i = 0; i < children.length; ++i) 163 this.removeFrame(children[i]._frameId); 164 165 delete this._treeElementForFrameId[frameId]; 166 frameTreeElement.parent.removeChild(frameTreeElement); 167 }, 168 169 addResourceToFrame: function(frameId, resource) 136 170 { 137 171 var frameTreeElement = this._treeElementForFrameId[frameId]; 138 172 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) 173 console.error("No frame to add resource to"); 174 return; 175 } 176 177 var resourceTreeElement = new WebInspector.FrameResourceTreeElement(this, resource); 178 179 // Insert in the alphabetical order, first frames, then resources. Document resource goes first. 180 var children = frameTreeElement.children; 181 for (var i = 0; i < children.length; ++i) { 182 var child = children[i]; 183 if (!(child instanceof WebInspector.FrameResourceTreeElement)) 184 continue; 185 186 if (resource.type === WebInspector.Resource.Type.Document || 187 (child._resource.type !== WebInspector.Resource.Type.Document && child._resource.displayName.localeCompare(resource.displayName) > 0)) { 188 frameTreeElement.insertChild(resourceTreeElement, i); 189 return; 190 } 191 } 192 frameTreeElement.appendChild(resourceTreeElement); 193 }, 194 195 removeResourcesFromFrame: function(frameId) 148 196 { 149 197 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(); 198 if (frameTreeElement) 199 frameTreeElement.removeChildren(); 167 200 }, 168 201 … … 494 527 this.listItemElement.appendChild(this.imageElement); 495 528 496 vartitleElement = document.createElement("span");497 t itleElement.textContent = this._titleText;498 t itleElement.className = "storage-base-tree-element-title";499 this.listItemElement.appendChild(t itleElement);529 this.titleElement = document.createElement("span"); 530 this.titleElement.textContent = this._titleText; 531 this.titleElement.className = "storage-base-tree-element-title"; 532 this.listItemElement.appendChild(this.titleElement); 500 533 501 534 var selectionElement = document.createElement("div"); … … 508 541 if (this.listItemElement) 509 542 this.listItemElement.scrollIntoViewIfNeeded(false); 543 }, 544 545 set titleText(titleText) 546 { 547 this._titleText = titleText; 548 this.titleElement.textContent = this._titleText; 510 549 } 511 550 } … … 527 566 WebInspector.StorageCategoryTreeElement.prototype.__proto__ = WebInspector.BaseStorageTreeElement.prototype; 528 567 529 WebInspector.FrameTreeElement = function(storagePanel, frameId, frameResource)530 { 531 WebInspector.BaseStorageTreeElement.call(this, storagePanel, frameResource.displayName, "frame-storage-tree-item");568 WebInspector.FrameTreeElement = function(storagePanel, frameId, displayName) 569 { 570 WebInspector.BaseStorageTreeElement.call(this, storagePanel, displayName, "frame-storage-tree-item"); 532 571 this._frameId = frameId; 533 this._ resource = frameResource;572 this._displayName = displayName; 534 573 } 535 574 … … 537 576 onselect: function() 538 577 { 539 this._storagePanel.showResource(this._resource); 578 this._storagePanel.showCategoryView(this._displayName); 579 }, 580 581 get displayName() 582 { 583 return this._displayName; 584 }, 585 586 set displayName(displayName) 587 { 588 this._displayName = displayName; 589 this.titleText = displayName; 540 590 } 541 591 }
Note: See TracChangeset
for help on using the changeset viewer.