From 629e0a078f3eb02be354ecdb10e9f3000ab2f976 Mon Sep 17 00:00:00 2001 From: "db48x%yahoo.com" Date: Thu, 14 Sep 2006 06:09:14 +0000 Subject: [PATCH] bug 229441: Background images are not shown in Media tab (Page Info) patch by Florian QUEZE , r=db48x, sr=jag --- suite/browser/pageInfo.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/suite/browser/pageInfo.js b/suite/browser/pageInfo.js index c9f88fa92348..523492a8bd10 100644 --- a/suite/browser/pageInfo.js +++ b/suite/browser/pageInfo.js @@ -23,6 +23,7 @@ * smorrison@gte.com * Terry Hayes * Daniel Brooks + * Florian QUEZE * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -880,16 +881,27 @@ function makePreview(row) var physWidth = 0, physHeight = 0; if ((item instanceof nsILinkElement || item instanceof nsIInputElement || - item instanceof nsIImageElement || isBG) && isProtocolAllowed) + item instanceof nsIImageElement || isBG) && isProtocolAllowed) { newImage.src = absoluteURL; physWidth = newImage.width; physHeight = newImage.height; - if ("width" in item && item.width) - newImage.width = item.width; - if ("height" in item && item.height) - newImage.height = item.height; + // "width" and "height" attributes must be set to newImage, + // even if there is no "width" or "height attribute in item; + // otherwise, the preview image cannot be displayed correctly. + if (!isBG) + { + newImage.width = ("width" in item && item.width) || newImage.naturalWidth; + newImage.height = ("height" in item && item.height) || newImage.naturalHeight; + } + else + { + // the Width and Height of an HTML tag should not be use for its background image + // (for example, "table" can have "width" or "height" attributes) + newImage.width = newImage.naturalWidth; + newImage.height = newImage.naturalHeight; + } } else {