From 71ee99d1fa2456bca9c76df8f493bda75138fae9 Mon Sep 17 00:00:00 2001 From: "attinasi%netscape.com" Date: Thu, 16 Mar 2000 22:58:12 +0000 Subject: [PATCH] Fixed a problem where loading an image into second browser window was not updating the dimensions. Also added temporary code to put the image type in the title, even though the image type is not really accurate yet. b=24478 r=dcone git-svn-id: svn://10.0.0.236/trunk@63177 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/document/src/nsImageDocument.cpp | 32 +++++++++++++++---- .../html/document/src/nsImageDocument.cpp | 32 +++++++++++++++---- 2 files changed, 52 insertions(+), 12 deletions(-) diff --git a/mozilla/content/html/document/src/nsImageDocument.cpp b/mozilla/content/html/document/src/nsImageDocument.cpp index 9b18b69eac7..4c8e7a6a7ea 100644 --- a/mozilla/content/html/document/src/nsImageDocument.cpp +++ b/mozilla/content/html/document/src/nsImageDocument.cpp @@ -74,8 +74,8 @@ public: void StartLayout(); - nsIImageRequest* mImageRequest; - nscolor mBlack; + nsIImageRequest* mImageRequest; + nscolor mBlack; }; //---------------------------------------------------------------------- @@ -131,10 +131,13 @@ NS_IMETHODIMP ImageListener::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { + if(mDocument){ + mDocument->EndLayout(ctxt, status, errorMsg); + } + if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - mDocument->EndLayout(ctxt, status, errorMsg); return mNextStream->OnStopRequest(channel, ctxt, status, errorMsg); } @@ -338,10 +341,27 @@ nsImageDocument::EndLayout(nsISupports *ctxt, nsresult nsImageDocument::UpdateTitle( void ) { nsString titleStr; - // get the title from the Document (in case there was a previously set title ) - GetTitle( titleStr ); + + // XXX TEMPORARY XXX + // We want to display the image type, however there is no way to right now + // so instead we just get the image-extension + // - get the URL interface, get the extension, convert to upper-case + // Unless the Imagerequest or Image can tell us the type this is the best we can do. + nsIURL *pURL=nsnull; + if(NS_SUCCEEDED(mDocumentURL->QueryInterface(nsIURL::GetIID(),(void **)&pURL))){ + char *pExtension=nsnull; + pURL->GetFileExtension(&pExtension); + if(pExtension){ + nsString strExt(pExtension); + strExt.ToUpperCase(); + titleStr.Append(strExt); + nsCRT::free(pExtension); + pExtension=nsnull; + } + NS_IF_RELEASE(pURL); + } // append the image information... - titleStr.Append( "Image" ); + titleStr.Append( " Image" ); if (mImageRequest) { PRUint32 width, height; mImageRequest->GetNaturalDimensions(&width, &height); diff --git a/mozilla/layout/html/document/src/nsImageDocument.cpp b/mozilla/layout/html/document/src/nsImageDocument.cpp index 9b18b69eac7..4c8e7a6a7ea 100644 --- a/mozilla/layout/html/document/src/nsImageDocument.cpp +++ b/mozilla/layout/html/document/src/nsImageDocument.cpp @@ -74,8 +74,8 @@ public: void StartLayout(); - nsIImageRequest* mImageRequest; - nscolor mBlack; + nsIImageRequest* mImageRequest; + nscolor mBlack; }; //---------------------------------------------------------------------- @@ -131,10 +131,13 @@ NS_IMETHODIMP ImageListener::OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status, const PRUnichar *errorMsg) { + if(mDocument){ + mDocument->EndLayout(ctxt, status, errorMsg); + } + if (nsnull == mNextStream) { return NS_ERROR_FAILURE; } - mDocument->EndLayout(ctxt, status, errorMsg); return mNextStream->OnStopRequest(channel, ctxt, status, errorMsg); } @@ -338,10 +341,27 @@ nsImageDocument::EndLayout(nsISupports *ctxt, nsresult nsImageDocument::UpdateTitle( void ) { nsString titleStr; - // get the title from the Document (in case there was a previously set title ) - GetTitle( titleStr ); + + // XXX TEMPORARY XXX + // We want to display the image type, however there is no way to right now + // so instead we just get the image-extension + // - get the URL interface, get the extension, convert to upper-case + // Unless the Imagerequest or Image can tell us the type this is the best we can do. + nsIURL *pURL=nsnull; + if(NS_SUCCEEDED(mDocumentURL->QueryInterface(nsIURL::GetIID(),(void **)&pURL))){ + char *pExtension=nsnull; + pURL->GetFileExtension(&pExtension); + if(pExtension){ + nsString strExt(pExtension); + strExt.ToUpperCase(); + titleStr.Append(strExt); + nsCRT::free(pExtension); + pExtension=nsnull; + } + NS_IF_RELEASE(pURL); + } // append the image information... - titleStr.Append( "Image" ); + titleStr.Append( " Image" ); if (mImageRequest) { PRUint32 width, height; mImageRequest->GetNaturalDimensions(&width, &height);