зеркало из https://github.com/mozilla/gecko-dev.git
bug 98092 r=db48x sr=bzbarsky [RFE] Show image file size in image property [properties] dialog
This commit is contained in:
Родитель
0136116798
Коммит
ba3bd61cac
|
@ -55,6 +55,15 @@ var onTable = false;
|
||||||
var onTitle = false;
|
var onTitle = false;
|
||||||
var onLang = false;
|
var onLang = false;
|
||||||
|
|
||||||
|
const nsICacheService = Components.interfaces.nsICacheService;
|
||||||
|
const cacheService = Components.classes["@mozilla.org/network/cache-service;1"]
|
||||||
|
.getService(nsICacheService);
|
||||||
|
var httpCacheSession = cacheService.createSession("HTTP", 0, true);
|
||||||
|
httpCacheSession.doomEntriesIfExpired = false;
|
||||||
|
var ftpCacheSession = cacheService.createSession("FTP", 0, true);
|
||||||
|
ftpCacheSession.doomEntriesIfExpired = false;
|
||||||
|
|
||||||
|
|
||||||
function onLoad()
|
function onLoad()
|
||||||
{
|
{
|
||||||
gMetadataBundle = document.getElementById("bundle_metadata");
|
gMetadataBundle = document.getElementById("bundle_metadata");
|
||||||
|
@ -167,15 +176,22 @@ function checkForImage(elem, htmllocalname)
|
||||||
|
|
||||||
if (img) {
|
if (img) {
|
||||||
setInfo("image-url", img.src);
|
setInfo("image-url", img.src);
|
||||||
|
|
||||||
|
var size = getSize(img.src);
|
||||||
|
if (size != -1) {
|
||||||
|
var kbSize = size / 1024;
|
||||||
|
kbSize = Math.round(kbSize*100)/100;
|
||||||
|
setInfo("image-filesize", gMetadataBundle.getFormattedString("imageSize", [kbSize, size]));
|
||||||
|
}
|
||||||
if ("width" in img) {
|
if ("width" in img) {
|
||||||
setInfo("image-width", img.width);
|
setInfo("image-width", img.width);
|
||||||
setInfo("image-height", img.height);
|
setInfo("image-height", img.height);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setInfo("image-width", "");
|
setInfo("image-width", "");
|
||||||
setInfo("image-height", "");
|
setInfo("image-height", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (imgType == "img") {
|
if (imgType == "img") {
|
||||||
setInfo("image-desc", getAbsoluteURL(img.longDesc, img));
|
setInfo("image-desc", getAbsoluteURL(img.longDesc, img));
|
||||||
} else {
|
} else {
|
||||||
|
@ -531,3 +547,22 @@ function convertLanguageCode(abbr)
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the size of the URL in bytes; must be cached and therefore an HTTP or FTP URL
|
||||||
|
function getSize(url) {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var cacheEntryDescriptor = httpCacheSession.openCacheEntry(url, Components.interfaces.nsICache.ACCESS_READ, false);
|
||||||
|
if(cacheEntryDescriptor)
|
||||||
|
return cacheEntryDescriptor.dataSize;
|
||||||
|
}
|
||||||
|
catch(ex) {}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
cacheEntryDescriptor = ftpCacheSession.openCacheEntry(url, Components.interfaces.nsICache.ACCESS_READ, false);
|
||||||
|
if (cacheEntryDescriptor)
|
||||||
|
return cacheEntryDescriptor.dataSize;
|
||||||
|
}
|
||||||
|
catch(ex) {}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
|
@ -137,6 +137,10 @@
|
||||||
<spacer flex="1"/>
|
<spacer flex="1"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
</row>
|
</row>
|
||||||
|
<row id="image-filesize">
|
||||||
|
<label value="&image-filesize.label; "/>
|
||||||
|
<label id="image-filesize-text" value="&filesize-unknown.label;"/>
|
||||||
|
</row>
|
||||||
</rows>
|
</rows>
|
||||||
</grid>
|
</grid>
|
||||||
</groupbox>
|
</groupbox>
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
<!ENTITY image-width.label "Width:">
|
<!ENTITY image-width.label "Width:">
|
||||||
<!ENTITY image-height.label "Height:">
|
<!ENTITY image-height.label "Height:">
|
||||||
<!ENTITY image-pixels.label "pixels">
|
<!ENTITY image-pixels.label "pixels">
|
||||||
|
<!ENTITY image-filesize.label "Size of File:">
|
||||||
|
<!ENTITY filesize-unknown.label "Unknown (not cached)">
|
||||||
<!ENTITY insdel-sec.label "Insert/Delete Properties">
|
<!ENTITY insdel-sec.label "Insert/Delete Properties">
|
||||||
<!ENTITY insdel-cite.label "Info:">
|
<!ENTITY insdel-cite.label "Info:">
|
||||||
<!ENTITY insdel-date.label "Date:">
|
<!ENTITY insdel-date.label "Date:">
|
||||||
|
|
|
@ -4,3 +4,5 @@ parentFrameText=Parent frame
|
||||||
sameFrameText=Same frame
|
sameFrameText=Same frame
|
||||||
embeddedText=Embedded
|
embeddedText=Embedded
|
||||||
unableToShowProps=No properties available.
|
unableToShowProps=No properties available.
|
||||||
|
|
||||||
|
imageSize=%S KB (%S bytes)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче