From 3a3f9340078657ff9e315c039629d786d00553d2 Mon Sep 17 00:00:00 2001 From: "attinasi%netscape.com" Date: Mon, 23 Apr 2001 23:46:50 +0000 Subject: [PATCH] Image dimensions now show up in title with or without IMG2. b=57549 r=pavlov sr=waterson a=blizzard --- content/html/document/src/nsImageDocument.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/content/html/document/src/nsImageDocument.cpp b/content/html/document/src/nsImageDocument.cpp index 37eb8d5f975..d254a59f088 100644 --- a/content/html/document/src/nsImageDocument.cpp +++ b/content/html/document/src/nsImageDocument.cpp @@ -28,6 +28,7 @@ #ifdef USE_IMG2 #include "imgIRequest.h" #include "imgILoader.h" +#include "imgIContainer.h" #else #include "nsIImageGroup.h" #include "nsIImageRequest.h" @@ -470,14 +471,25 @@ nsresult nsImageDocument::UpdateTitle( void ) nsCOMPtr locale = nsnull; rv = stringService->CreateBundle(NSIMAGEDOCUMENT_PROPERTIES_URI, locale, getter_AddRefs(bundle)); } - // XXX this shouldn't be ifndef'd -#ifndef USE_IMG2 if (NS_SUCCEEDED(rv) && bundle) { nsAutoString key; nsXPIDLString valUni; if (mImageRequest) { PRUint32 width, height; - mImageRequest->GetNaturalDimensions(&width, &height); +#ifdef USE_IMG2 + imgIContainer* imgContainer; + rv = mImageRequest->GetImage(&imgContainer); + if (NS_SUCCEEDED(rv) && imgContainer) { + nscoord w = 0, h = 0; + imgContainer->GetWidth(&w); + imgContainer->GetHeight(&h); + width = w; + height = h; + NS_RELEASE(imgContainer); + } +#else + mImageRequest->GetNaturalImageSize(&width, &height); +#endif // if we got a valid size (sometimes we do not) then display it if (width != 0 && height != 0){ key.AssignWithConversion("ImageTitleWithDimensions"); @@ -498,6 +510,5 @@ nsresult nsImageDocument::UpdateTitle( void ) SetTitle(titleStr); } } -#endif return NS_OK; }