Changeset 71254 in webkit


Ignore:
Timestamp:
Nov 3, 2010 11:38:18 AM (13 years ago)
Author:
pfeldman@chromium.org
Message:

2010-11-03 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Simon Fraser.

Web Inspector: show proper image size for cached resources.
https://bugs.webkit.org/show_bug.cgi?id=48915

  • inspector/front-end/ExtensionServer.js: (WebInspector.ExtensionServer.prototype._onGetResourceContent):
  • inspector/front-end/ImageView.js: (WebInspector.ImageView.prototype.contentTabSelected.onImageLoad): (WebInspector.ImageView.prototype.contentTabSelected): (WebInspector.ImageView.prototype._base64ToSize):
  • inspector/front-end/NetworkPanel.js: (WebInspector.NetworkDataGridNode.prototype._refreshNameCell):
  • inspector/front-end/Resource.js: (WebInspector.Resource.prototype.set finished): (WebInspector.Resource.prototype.get content): (WebInspector.Resource.prototype.requestContent): (WebInspector.Resource.prototype._innerRequestContent):
  • inspector/front-end/ResourceManager.js: (WebInspector.ResourceManager.requestContent):
  • inspector/front-end/SourceView.js: (WebInspector.SourceView.prototype.setupSourceFrameIfNeeded):
Location:
trunk/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r71253 r71254  
     12010-11-03  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Simon Fraser.
     4
     5        Web Inspector: show proper image size for cached resources.
     6        https://bugs.webkit.org/show_bug.cgi?id=48915
     7
     8        * inspector/front-end/ExtensionServer.js:
     9        (WebInspector.ExtensionServer.prototype._onGetResourceContent):
     10        * inspector/front-end/ImageView.js:
     11        (WebInspector.ImageView.prototype.contentTabSelected.onImageLoad):
     12        (WebInspector.ImageView.prototype.contentTabSelected):
     13        (WebInspector.ImageView.prototype._base64ToSize):
     14        * inspector/front-end/NetworkPanel.js:
     15        (WebInspector.NetworkDataGridNode.prototype._refreshNameCell):
     16        * inspector/front-end/Resource.js:
     17        (WebInspector.Resource.prototype.set finished):
     18        (WebInspector.Resource.prototype.get content):
     19        (WebInspector.Resource.prototype.requestContent):
     20        (WebInspector.Resource.prototype._innerRequestContent):
     21        * inspector/front-end/ResourceManager.js:
     22        (WebInspector.ResourceManager.requestContent):
     23        * inspector/front-end/SourceView.js:
     24        (WebInspector.SourceView.prototype.setupSourceFrameIfNeeded):
     25
    1262010-11-03  Noam Rosenthal  <noam.rosenthal@nokia.com>
    227
  • trunk/WebCore/inspector/front-end/ExtensionServer.js

    r71107 r71254  
    333333                response.push(this._status.E_NOTFOUND(id));
    334334            else
    335                 resource.getContent(onContentAvailable.bind(this, id));
     335                resource.requestContent(onContentAvailable.bind(this, id));
    336336        }
    337337        if (response.length === ids.length)
  • trunk/WebCore/inspector/front-end/ImageView.js

    r71133 r71254  
    6868            imagePreviewElement.setAttribute("src", this.resource.contentURL);
    6969        }
    70         this.resource.getContent(onResourceContent.bind(this));
     70        this.resource.requestContent(onResourceContent.bind(this));
    7171
    7272
    7373        function onImageLoad()
    7474        {
     75            var content = this.resource.content;
     76            if (content)
     77                var resourceSize = this._base64ToSize(content);
     78            else
     79                var resourceSize = this.resource.resourceSize;
     80
    7581            var imageProperties = [
    76                 { name: WebInspector.UIString("Dimensions"), value: WebInspector.UIString("%d × %d", imagePreviewElement.naturalWidth, imagePreviewElement.height) },
    77                 { name: WebInspector.UIString("File size"), value: Number.bytesToString(this.resource.resourceSize, WebInspector.UIString) },
     82                { name: WebInspector.UIString("Dimensions"), value: WebInspector.UIString("%d × %d", imagePreviewElement.naturalWidth, imagePreviewElement.naturalHeight) },
     83                { name: WebInspector.UIString("File size"), value: Number.bytesToString(resourceSize, WebInspector.UIString) },
    7884                { name: WebInspector.UIString("MIME type"), value: this.resource.mimeType }
    7985            ];
     
    9197        }
    9298        imagePreviewElement.addEventListener("load", onImageLoad.bind(this), false);
     99    },
     100
     101    _base64ToSize: function(content)
     102    {
     103        if (!content.length)
     104            return 0;
     105        var size = (content.length || 0) * 3 / 4;
     106        if (content.length > 0 && content[content.length - 1] === "=")
     107            size--;
     108        if (content.length > 1 && content[content.length - 2] === "=")
     109            size--;
     110        return size;
    93111    }
    94112}
  • trunk/WebCore/inspector/front-end/NetworkPanel.js

    r71109 r71254  
    14831483            }
    14841484            if (Preferences.useDataURLForResourceImageIcons)
    1485                 this._resource.getContent(onResourceContent.bind(this));
     1485                this._resource.requestContent(onResourceContent.bind(this));
    14861486            else
    14871487                previewImage.src = this._resource.url;
  • trunk/WebCore/inspector/front-end/Resource.js

    r71136 r71254  
    256256            this.dispatchEventToListeners("finished");
    257257            if (this._pendingContentCallbacks.length)
    258                 this._requestContent();
     258                this._innerRequestContent();
    259259        }
    260260    },
     
    617617    },
    618618
     619    get content()
     620    {
     621        return this._content;
     622    },
     623
    619624    set content(content)
    620625    {
     
    622627    },
    623628
    624     getContent: function(callback)
     629    requestContent: function(callback)
    625630    {
    626631        if (this._content) {
     
    630635        this._pendingContentCallbacks.push(callback);
    631636        if (this.finished)
    632             this._requestContent();
     637            this._innerRequestContent();
    633638    },
    634639
     
    643648    },
    644649
    645     _requestContent: function()
     650    _innerRequestContent: function()
    646651    {
    647652        if (this._contentRequested)
     
    659664            delete this._contentRequested;
    660665        }
    661         WebInspector.ResourceManager.getContent(this, this._contentEncoded, onResourceContent.bind(this));
     666        WebInspector.ResourceManager.requestContent(this, this._contentEncoded, onResourceContent.bind(this));
    662667    }
    663668}
  • trunk/WebCore/inspector/front-end/ResourceManager.js

    r71144 r71254  
    470470}
    471471
    472 WebInspector.ResourceManager.getContent = function(resource, base64Encode, callback)
     472WebInspector.ResourceManager.requestContent = function(resource, base64Encode, callback)
    473473{
    474474    InspectorBackend.resourceContent(resource.loader.frameId, resource.url, base64Encode, callback);
  • trunk/WebCore/inspector/front-end/SourceView.js

    r70529 r71254  
    8585
    8686        delete this._frameNeedsSetup;
    87         this.resource.getContent(this._contentLoaded.bind(this));
     87        this.resource.requestContent(this._contentLoaded.bind(this));
    8888    },
    8989
Note: See TracChangeset for help on using the changeset viewer.