Changeset 70519 in webkit
- Timestamp:
- Oct 26, 2010 7:18:57 AM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r70518 r70519 1 2010-10-20 Andrey Kosyakov <caseq@chromium.org> 2 3 Reviewed by Yury Semikhatsky. 4 5 Inspector needs to use cached resources to display image resources. 6 https://bugs.webkit.org/show_bug.cgi?id=16395 7 8 * inspector/Inspector.idl: Add base64Encode parameter to getContent 9 * inspector/InspectorResourceAgent.cpp: 10 (WebCore::InspectorResourceAgent::resourceContent): 11 * inspector/InspectorResourceAgent.h: 12 * inspector/front-end/ExtensionServer.js: 13 (WebInspector.ExtensionServer.prototype._onGetResourceContent): 14 * inspector/front-end/ImageView.js: 15 (WebInspector.ImageView.prototype.contentTabSelected.onResourceContent): 16 (WebInspector.ImageView.prototype.contentTabSelected): 17 * inspector/front-end/NetworkPanel.js: 18 (WebInspector.NetworkDataGridNode.prototype._refreshNameCell.): 19 (WebInspector.NetworkDataGridNode.prototype._refreshNameCell): 20 * inspector/front-end/Resource.js: 21 (WebInspector.Resource): 22 (WebInspector.Resource.prototype.set finished): 23 (WebInspector.Resource.prototype.getContent): 24 (WebInspector.Resource.prototype.get contentURL): 25 (WebInspector.Resource.prototype._requestContent.onResourceContent): 26 (WebInspector.Resource.prototype._requestContent): 27 * inspector/front-end/ResourcesPanel.js: 28 (WebInspector.ResourceSidebarTreeElement.prototype.createIconElement.): 29 (WebInspector.ResourceSidebarTreeElement.prototype.createIconElement): 30 * inspector/front-end/Settings.js: Added useDataURLForResourceImageIcons 31 * inspector/front-end/SourceView.js: 32 (WebInspector.SourceView.prototype.setupSourceFrameIfNeeded): 33 1 34 2010-10-26 Pavel Feldman <pfeldman@chromium.org> 2 35 -
trunk/WebCore/inspector/Inspector.idl
r70305 r70519 114 114 115 115 [handler=Resource] void cachedResources(out Object resources); 116 [handler=Resource] void resourceContent(in unsigned long frameId, in String url, out String content);116 [handler=Resource] void resourceContent(in unsigned long frameId, in String url, in boolean base64Encode, out String content); 117 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); -
trunk/WebCore/inspector/InspectorResourceAgent.cpp
r70305 r70519 433 433 } 434 434 435 void InspectorResourceAgent::resourceContent(unsigned long frameId, const String& url, String* content) 436 { 437 RefPtr<InspectorArray> frameResources = InspectorArray::create(); 435 void InspectorResourceAgent::resourceContent(unsigned long frameId, const String& url, bool base64Encode, String* content) 436 { 438 437 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree()->traverseNext(m_page->mainFrame())) { 439 438 if (reinterpret_cast<uintptr_t>(frame) != frameId) 440 439 continue; 441 InspectorResourceAgent::resourceContent(frame, KURL(ParsedURLString, url), content); 440 if (base64Encode) 441 InspectorResourceAgent::resourceContentBase64(frame, KURL(ParsedURLString, url), content); 442 else 443 InspectorResourceAgent::resourceContent(frame, KURL(ParsedURLString, url), content); 442 444 break; 443 445 } -
trunk/WebCore/inspector/InspectorResourceAgent.h
r70240 r70519 99 99 // Called from frontend 100 100 void cachedResources(RefPtr<InspectorObject>*); 101 void resourceContent(unsigned long frameID, const String& url, String* content);101 void resourceContent(unsigned long frameID, const String& url, bool base64Encode, String* content); 102 102 103 103 private: -
trunk/WebCore/inspector/front-end/ExtensionServer.js
r70518 r70519 278 278 var response = []; 279 279 280 function onContentAvailable(id, encoded, content)280 function onContentAvailable(id, content, encoded) 281 281 { 282 282 var resourceContent = { … … 302 302 if (!resource) 303 303 response.push(this._status.E_NOTFOUND(id)); 304 else { 305 var encode = !WebInspector.Resource.Type.isTextType(resource.type); 306 WebInspector.getEncodedResourceContent(id, encode, onContentAvailable.bind(this, id, encode)); 307 } 304 else 305 resource.getContent(onContentAvailable.bind(this, id)); 308 306 } 309 307 if (response.length === ids.length) … … 452 450 453 451 WebInspector.extensionServer = new WebInspector.ExtensionServer(); 454 455 WebInspector.getEncodedResourceContent = function(identifier, encode, callback)456 {457 InspectorBackend.getResourceContent(identifier, encode, callback);458 } -
trunk/WebCore/inspector/front-end/ImageView.js
r59688 r70519 50 50 this.imagePreviewElement = document.createElement("img"); 51 51 this.imagePreviewElement.addStyleClass("resource-image-view"); 52 this. imagePreviewElement.setAttribute("src", this.resource.url);52 this._container.appendChild(this.imagePreviewElement); 53 53 54 this._container.appendChild(this.imagePreviewElement); 54 function onResourceContent(element, content) 55 { 56 this.imagePreviewElement.setAttribute("src", this.resource.contentURL); 57 } 58 this.resource.getContent(onResourceContent.bind(this)); 55 59 56 60 this._container = document.createElement("div"); -
trunk/WebCore/inspector/front-end/NetworkPanel.js
r70518 r70519 1463 1463 var previewImage = document.createElement("img"); 1464 1464 previewImage.className = "image-network-icon-preview"; 1465 previewImage.src = this._resource.url; 1465 1466 function onResourceContent() 1467 { 1468 previewImage.src = this._resource.contentURL; 1469 } 1470 if (Preferences.useDataURLForResourceImageIcons) 1471 this._resource.getContent(onResourceContent.bind(this)); 1472 else 1473 previewImage.src = this._resource.url; 1466 1474 1467 1475 var iconElement = document.createElement("div"); -
trunk/WebCore/inspector/front-end/Resource.js
r70518 r70519 35 35 this._requestMethod = ""; 36 36 this._category = WebInspector.resourceCategories.other; 37 this._pendingContentCallbacks = []; 37 38 } 38 39 … … 255 256 this._checkWarnings(); 256 257 this.dispatchEventToListeners("finished"); 258 if (this._pendingContentCallbacks.length) 259 this._requestContent(); 257 260 } 258 261 }, … … 598 601 }, 599 602 600 getContents: function(callback) 601 { 602 WebInspector.ResourceManager.getContents(this, callback); 603 getContent: function(callback) 604 { 605 if (this._content) { 606 callback(this._content, this._contentEncoded); 607 return; 608 } 609 this._pendingContentCallbacks.push(callback); 610 if (this.finished) 611 this._requestContent(); 612 }, 613 614 get contentURL() 615 { 616 const maxDataUrlSize = 1024 * 1024; 617 // If resource content is not available or won't fit a data URL, fall back to using original URL. 618 if (!this._content || this._content.length > maxDataUrlSize) 619 return this.url; 620 621 return "data:" + this.mimeType + (this._contentEncoded ? ";base64," : ",") + this._content; 622 }, 623 624 _requestContent: function() 625 { 626 if (this._contentRequested) 627 return; 628 this._contentRequested = true; 629 this._contentEncoded = !WebInspector.Resource.Type.isTextType(this.type); 630 631 function onResourceContent(data) 632 { 633 this._content = data; 634 var callbacks = this._pendingContentCallbacks.slice(); 635 for (var i = 0; i < callbacks.length; ++i) 636 callbacks[i](this._content, this._contentEncoded); 637 this._pendingContentCallbacks.length = 0; 638 } 639 WebInspector.ResourceManager.getContent(this, this._contentEncoded, onResourceContent.bind(this)); 603 640 } 604 641 } -
trunk/WebCore/inspector/front-end/ResourceManager.js
r70518 r70519 408 408 } 409 409 410 WebInspector.ResourceManager.getContent s = function(resource, callback)410 WebInspector.ResourceManager.getContent = function(resource, base64Encode, callback) 411 411 { 412 412 if ("overridenContent" in resource) { … … 417 417 // FIXME: eventually, cached resources will have no identifiers. 418 418 if (resource.loader) 419 InspectorBackend.resourceContent(resource.loader.frameId, resource.url, callback);419 InspectorBackend.resourceContent(resource.loader.frameId, resource.url, base64Encode, callback); 420 420 else 421 InspectorBackend.getResourceContent(resource.identifier, false, callback);421 InspectorBackend.getResourceContent(resource.identifier, base64Encode, callback); 422 422 } 423 423 -
trunk/WebCore/inspector/front-end/ResourcesPanel.js
r70518 r70519 1667 1667 var previewImage = document.createElement("img"); 1668 1668 previewImage.className = "image-resource-icon-preview"; 1669 previewImage.src = this.resource.url; 1669 1670 function onResourceContent() 1671 { 1672 previewImage.src = this.resource.contentURL; 1673 } 1674 if (Preferences.useDataURLForResourceImageIcons) 1675 this.resource.getContent(onResourceContent.bind(this)); 1676 else 1677 previewImage.src = this.resource.url; 1670 1678 1671 1679 this.iconElement = document.createElement("div"); -
trunk/WebCore/inspector/front-end/Settings.js
r70446 r70519 46 46 nativeInstrumentationEnabled: false, 47 47 resourceExportEnabled: false, 48 networkPanelEnabled: false 48 networkPanelEnabled: false, 49 useDataURLForResourceImageIcons: true 49 50 } 50 51 -
trunk/WebCore/inspector/front-end/SourceView.js
r69948 r70519 84 84 85 85 delete this._frameNeedsSetup; 86 this.resource.getContent s(this._contentLoaded.bind(this));86 this.resource.getContent(this._contentLoaded.bind(this)); 87 87 }, 88 88
Note: See TracChangeset
for help on using the changeset viewer.