Get the image URI in a better way that works even for images that didn't load.

Bug 350378, patch by Dorian <boissomag@free.fr>, r+sr=bzbarsky
This commit is contained in:
bzbarsky%mit.edu 2006-08-28 02:15:56 +00:00
Родитель 23d7c72d67
Коммит 6b73b90092
1 изменённых файлов: 3 добавлений и 16 удалений

Просмотреть файл

@ -181,22 +181,9 @@ nsContextMenuInfo::GetImageSrc(nsIURI **aURI)
NS_ENSURE_ARG_POINTER(aURI);
NS_ENSURE_STATE(mDOMNode);
// First try the easy case of our node being a nsIDOMHTMLImageElement
nsCOMPtr<nsIDOMHTMLImageElement> imgElement(do_QueryInterface(mDOMNode));
if (imgElement) {
nsAutoString imgSrcSpec;
nsresult rv = imgElement->GetSrc(imgSrcSpec);
if (NS_SUCCEEDED(rv))
return NS_NewURI(aURI, NS_ConvertUTF16toUTF8(imgSrcSpec));
}
// If not, dig deeper.
nsCOMPtr<imgIRequest> request;
GetImageRequest(mDOMNode, getter_AddRefs(request));
if (request)
return request->GetURI(aURI);
return NS_ERROR_FAILURE;
nsCOMPtr<nsIImageLoadingContent> content(do_QueryInterface(mDOMNode));
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
return content->GetCurrentURI(aURI);
}
/* readonly attribute imgIContainer backgroundImageContainer; */