зеркало из https://github.com/mozilla/pjs.git
bug:13718: natural img dimens. pnunn, r:sfraser
This commit is contained in:
Родитель
3f5be087d9
Коммит
c6b9835eb3
|
@ -1021,18 +1021,15 @@ nsHTMLImageElement::GetNaturalHeight(PRInt32* aNaturalHeight)
|
|||
|
||||
*aNaturalHeight = 0;
|
||||
|
||||
if (!mLoader)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsImageFrame* imageFrame;
|
||||
nsresult rv = GetImageFrame(&imageFrame);
|
||||
if (NS_FAILED(rv) || !imageFrame) return NS_OK; // don't throw JS exceptions in this case
|
||||
|
||||
nsSize naturalSize(0, 0);
|
||||
//rv = imageFrame->GetNaturalSize(naturalSize);
|
||||
PRUint32 width, height;
|
||||
rv = imageFrame->GetNaturalImageSize(&width, &height);
|
||||
if (NS_FAILED(rv)) return NS_OK;
|
||||
|
||||
*aNaturalHeight = naturalSize.height;
|
||||
*aNaturalHeight = (PRInt32)height;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1042,19 +1039,16 @@ nsHTMLImageElement::GetNaturalWidth(PRInt32* aNaturalWidth)
|
|||
NS_ENSURE_ARG_POINTER(aNaturalWidth);
|
||||
|
||||
*aNaturalWidth = 0;
|
||||
|
||||
if (!mLoader)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
nsImageFrame* imageFrame;
|
||||
nsresult rv = GetImageFrame(&imageFrame);
|
||||
if (NS_FAILED(rv) || !imageFrame) return NS_OK; // don't throw JS exceptions in this case
|
||||
|
||||
nsSize naturalSize(0, 0);
|
||||
//rv = imageFrame->GetNaturalSize(naturalSize);
|
||||
PRUint32 width, height;
|
||||
rv = imageFrame->GetNaturalImageSize(&width, &height);
|
||||
if (NS_FAILED(rv)) return NS_OK;
|
||||
|
||||
*aNaturalWidth = naturalSize.width;
|
||||
*aNaturalWidth = (PRInt32)width;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -92,6 +92,10 @@ public:
|
|||
|
||||
NS_IMETHOD GetIntrinsicSize(nsSize& aResult);
|
||||
|
||||
NS_IMETHOD GetNaturalImageSize(PRUint32* naturalWidth,
|
||||
PRUint32 *naturalHeight);
|
||||
|
||||
|
||||
protected:
|
||||
nsFrameImageLoader();
|
||||
virtual ~nsFrameImageLoader();
|
||||
|
|
|
@ -1086,6 +1086,14 @@ nsImageFrame::GetIntrinsicImageSize(nsSize& aSize)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageFrame::GetNaturalImageSize(PRUint32* naturalWidth,
|
||||
PRUint32 *naturalHeight)
|
||||
{
|
||||
mImageLoader.GetNaturalImageSize(naturalWidth, naturalHeight);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageFrame::IsImageComplete(PRBool* aComplete)
|
||||
{
|
||||
|
|
|
@ -71,6 +71,10 @@ public:
|
|||
PRInt32 aHint);
|
||||
NS_IMETHOD GetFrameType(nsIAtom** aResult) const;
|
||||
NS_IMETHOD GetIntrinsicImageSize(nsSize& aSize);
|
||||
|
||||
NS_IMETHOD GetNaturalImageSize(PRUint32* naturalWidth,
|
||||
PRUint32 *naturalHeight);
|
||||
|
||||
NS_IMETHOD IsImageComplete(PRBool* aComplete);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -134,6 +138,7 @@ protected:
|
|||
PRPackedBool mInitialLoadCompleted;
|
||||
PRPackedBool mCanSendLoadEvent;
|
||||
nsMargin mBorderPadding;
|
||||
PRUint32 mNaturalImageWidth, mNaturalImageHeight;
|
||||
};
|
||||
|
||||
#endif /* nsImageFrame_h___ */
|
||||
|
|
|
@ -78,6 +78,12 @@ nsHTMLImageLoader::GetImage()
|
|||
return image;
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLImageLoader::GetNaturalImageSize(PRUint32* naturalWidth, PRUint32* naturalHeight)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
void
|
||||
nsHTMLImageLoader::SetURL(const nsString& aNewSpec)
|
||||
{
|
||||
|
|
|
@ -90,6 +90,7 @@ public:
|
|||
// Get the intrinsic (natural) size for the image. Returns 0,0 if
|
||||
// the dimensions are not known
|
||||
void GetIntrinsicSize(nsSize& aSize);
|
||||
void GetNaturalImageSize(PRUint32* naturalWidth, PRUint32* naturalHeight);
|
||||
|
||||
#ifdef DEBUG
|
||||
void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const;
|
||||
|
|
|
@ -1086,6 +1086,14 @@ nsImageFrame::GetIntrinsicImageSize(nsSize& aSize)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageFrame::GetNaturalImageSize(PRUint32* naturalWidth,
|
||||
PRUint32 *naturalHeight)
|
||||
{
|
||||
mImageLoader.GetNaturalImageSize(naturalWidth, naturalHeight);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageFrame::IsImageComplete(PRBool* aComplete)
|
||||
{
|
||||
|
|
|
@ -71,6 +71,10 @@ public:
|
|||
PRInt32 aHint);
|
||||
NS_IMETHOD GetFrameType(nsIAtom** aResult) const;
|
||||
NS_IMETHOD GetIntrinsicImageSize(nsSize& aSize);
|
||||
|
||||
NS_IMETHOD GetNaturalImageSize(PRUint32* naturalWidth,
|
||||
PRUint32 *naturalHeight);
|
||||
|
||||
NS_IMETHOD IsImageComplete(PRBool* aComplete);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@ -134,6 +138,7 @@ protected:
|
|||
PRPackedBool mInitialLoadCompleted;
|
||||
PRPackedBool mCanSendLoadEvent;
|
||||
nsMargin mBorderPadding;
|
||||
PRUint32 mNaturalImageWidth, mNaturalImageHeight;
|
||||
};
|
||||
|
||||
#endif /* nsImageFrame_h___ */
|
||||
|
|
|
@ -1021,18 +1021,15 @@ nsHTMLImageElement::GetNaturalHeight(PRInt32* aNaturalHeight)
|
|||
|
||||
*aNaturalHeight = 0;
|
||||
|
||||
if (!mLoader)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsImageFrame* imageFrame;
|
||||
nsresult rv = GetImageFrame(&imageFrame);
|
||||
if (NS_FAILED(rv) || !imageFrame) return NS_OK; // don't throw JS exceptions in this case
|
||||
|
||||
nsSize naturalSize(0, 0);
|
||||
//rv = imageFrame->GetNaturalSize(naturalSize);
|
||||
PRUint32 width, height;
|
||||
rv = imageFrame->GetNaturalImageSize(&width, &height);
|
||||
if (NS_FAILED(rv)) return NS_OK;
|
||||
|
||||
*aNaturalHeight = naturalSize.height;
|
||||
*aNaturalHeight = (PRInt32)height;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1042,19 +1039,16 @@ nsHTMLImageElement::GetNaturalWidth(PRInt32* aNaturalWidth)
|
|||
NS_ENSURE_ARG_POINTER(aNaturalWidth);
|
||||
|
||||
*aNaturalWidth = 0;
|
||||
|
||||
if (!mLoader)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
nsImageFrame* imageFrame;
|
||||
nsresult rv = GetImageFrame(&imageFrame);
|
||||
if (NS_FAILED(rv) || !imageFrame) return NS_OK; // don't throw JS exceptions in this case
|
||||
|
||||
nsSize naturalSize(0, 0);
|
||||
//rv = imageFrame->GetNaturalSize(naturalSize);
|
||||
PRUint32 width, height;
|
||||
rv = imageFrame->GetNaturalImageSize(&width, &height);
|
||||
if (NS_FAILED(rv)) return NS_OK;
|
||||
|
||||
*aNaturalWidth = naturalSize.width;
|
||||
*aNaturalWidth = (PRInt32)width;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче