diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index b923f0c3723..31c6898dd75 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -1529,8 +1529,22 @@ nsImageFrame::GetNaturalImageSize(PRUint32* naturalWidth, PRUint32 *naturalHeight) { #ifdef USE_IMG2 - *naturalWidth = mIntrinsicSize.width; - *naturalHeight = mIntrinsicSize.height; + *naturalWidth = 0; + *naturalHeight = 0; + + if (mImageRequest) { + nsCOMPtr container; + mImageRequest->GetImage(getter_AddRefs(container)); + if (container) { + PRInt32 w, h; + container->GetWidth(&w); + container->GetHeight(&h); + + *naturalWidth = NS_STATIC_CAST(PRUint32, w); + *naturalHeight = NS_STATIC_CAST(PRUint32, h); + } + } + #else mImageLoader.GetNaturalImageSize(naturalWidth, naturalHeight); #endif diff --git a/layout/html/base/src/nsImageFrame.cpp b/layout/html/base/src/nsImageFrame.cpp index b923f0c3723..31c6898dd75 100644 --- a/layout/html/base/src/nsImageFrame.cpp +++ b/layout/html/base/src/nsImageFrame.cpp @@ -1529,8 +1529,22 @@ nsImageFrame::GetNaturalImageSize(PRUint32* naturalWidth, PRUint32 *naturalHeight) { #ifdef USE_IMG2 - *naturalWidth = mIntrinsicSize.width; - *naturalHeight = mIntrinsicSize.height; + *naturalWidth = 0; + *naturalHeight = 0; + + if (mImageRequest) { + nsCOMPtr container; + mImageRequest->GetImage(getter_AddRefs(container)); + if (container) { + PRInt32 w, h; + container->GetWidth(&w); + container->GetHeight(&h); + + *naturalWidth = NS_STATIC_CAST(PRUint32, w); + *naturalHeight = NS_STATIC_CAST(PRUint32, h); + } + } + #else mImageLoader.GetNaturalImageSize(naturalWidth, naturalHeight); #endif