mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1180991
- Send up natural dimensions of background images loaded in content for Page Info. r=florian
--HG-- extra : commitid : 3WG0R3DrZ5K extra : rebase_source : 9bd7c6c33b8de5342138c8c66c04ebac8c355477 extra : amend_source : 79a786a900756692614126e536135616adc719b0
This commit is contained in:
parent
4a26d3c7da
commit
ba12fbbe72
@ -1104,9 +1104,6 @@ var PageInfoListener = {
|
||||
|
||||
serializeElementInfo: function(document, url, type, alt, item, isBG)
|
||||
{
|
||||
// Interface for image loading content.
|
||||
const nsIImageLoadingContent = Components.interfaces.nsIImageLoadingContent;
|
||||
|
||||
let result = {};
|
||||
|
||||
let imageText;
|
||||
@ -1130,10 +1127,9 @@ var PageInfoListener = {
|
||||
result.mimeType = item.type;
|
||||
}
|
||||
|
||||
if (!result.mimeType && !isBG && item instanceof nsIImageLoadingContent) {
|
||||
if (!result.mimeType && !isBG && item instanceof Ci.nsIImageLoadingContent) {
|
||||
// Interface for image loading content.
|
||||
const nsIImageLoadingContent = Components.interfaces.nsIImageLoadingContent;
|
||||
let imageRequest = item.getRequest(nsIImageLoadingContent.CURRENT_REQUEST);
|
||||
let imageRequest = item.getRequest(Ci.nsIImageLoadingContent.CURRENT_REQUEST);
|
||||
if (imageRequest) {
|
||||
result.mimeType = imageRequest.mimeType;
|
||||
let image = !(imageRequest.imageStatus & imageRequest.STATUS_ERROR) && imageRequest.image;
|
||||
@ -1158,7 +1154,18 @@ var PageInfoListener = {
|
||||
result.HTMLVideoElement = item instanceof content.HTMLVideoElement;
|
||||
result.HTMLAudioElement = item instanceof content.HTMLAudioElement;
|
||||
|
||||
if (!isBG) {
|
||||
if (isBG) {
|
||||
// Items that are showing this image as a background
|
||||
// image might not necessarily have a width or height,
|
||||
// so we'll dynamically generate an image and send up the
|
||||
// natural dimensions.
|
||||
let img = content.document.createElement("img");
|
||||
img.src = url;
|
||||
result.naturalWidth = img.naturalWidth;
|
||||
result.naturalHeight = img.naturalHeight;
|
||||
} else {
|
||||
// Otherwise, we can use the current width and height
|
||||
// of the image.
|
||||
result.width = item.width;
|
||||
result.height = item.height;
|
||||
}
|
||||
|
@ -895,6 +895,14 @@ function makePreview(row)
|
||||
// "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.
|
||||
// Since the image might have been loaded out-of-process, we expect
|
||||
// the item to tell us its width / height dimensions. Failing that
|
||||
// the item should tell us the natural dimensions of the image. Finally
|
||||
// failing that, we'll assume that the image was never loaded in the
|
||||
// other process (this can be true for favicons, for example), and so
|
||||
// we'll assume that we can use the natural dimensions of the newImage
|
||||
// we just created. If the natural dimensions of newImage are not known
|
||||
// then the image is probably broken.
|
||||
if (!isBG) {
|
||||
newImage.width = ("width" in item && item.width) || newImage.naturalWidth;
|
||||
newImage.height = ("height" in item && item.height) || newImage.naturalHeight;
|
||||
@ -902,8 +910,8 @@ function makePreview(row)
|
||||
else {
|
||||
// the Width and Height of an HTML tag should not be used for its background image
|
||||
// (for example, "table" can have "width" or "height" attributes)
|
||||
newImage.width = newImage.naturalWidth;
|
||||
newImage.height = newImage.naturalHeight;
|
||||
newImage.width = item.naturalWidth || newImage.naturalWidth;
|
||||
newImage.height = item.naturalHeight || newImage.naturalHeight;
|
||||
}
|
||||
|
||||
if (item.SVGImageElement) {
|
||||
|
Loading…
Reference in New Issue
Block a user