Show the image type in the URL bar for image documents. Bug 42093,

r=timeless, sr=jag.
This commit is contained in:
bzbarsky%mit.edu 2002-02-06 03:40:18 +00:00
Родитель 8cf5676cfc
Коммит d614b474f4
2 изменённых файлов: 32 добавлений и 16 удалений

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

@ -506,6 +506,7 @@ nsresult nsImageDocument::UpdateTitle( void )
nsAutoString widthStr; nsAutoString widthStr;
nsAutoString heightStr; nsAutoString heightStr;
nsXPIDLString fileStr; nsXPIDLString fileStr;
nsAutoString typeStr;
PRUint32 width = 0, height = 0; PRUint32 width = 0, height = 0;
nsCOMPtr<nsIURL> url = do_QueryInterface(mDocumentURL); nsCOMPtr<nsIURL> url = do_QueryInterface(mDocumentURL);
@ -535,30 +536,44 @@ nsresult nsImageDocument::UpdateTitle( void )
widthStr.AppendInt(width); widthStr.AppendInt(width);
heightStr.AppendInt(height); heightStr.AppendInt(height);
nsXPIDLCString mimeType;
mImageRequest->GetMimeType(getter_Copies(mimeType));
ToUpperCase(mimeType);
nsXPIDLCString::const_iterator start, end;
mimeType.BeginReading(start);
mimeType.EndReading(end);
nsXPIDLCString::const_iterator iter = end;
if (FindInReadable(NS_LITERAL_CSTRING("IMAGE/"), start, iter) && iter != end) {
CopyASCIItoUCS2(Substring(iter, end), typeStr);
} else {
CopyASCIItoUCS2(mimeType, typeStr);
}
} }
// If we got a filename, display it // If we got a filename, display it
if (!fileStr.IsEmpty()) { if (!fileStr.IsEmpty()) {
// if we got a valid size (sometimes we do not) then display it // if we got a valid size (sometimes we do not) then display it
if (width != 0 && height != 0){ if (width != 0 && height != 0){
const PRUnichar *formatStrings[3] = {fileStr.get(), widthStr.get(), heightStr.get()}; const PRUnichar *formatStrings[4] = {fileStr.get(), typeStr.get(), widthStr.get(), heightStr.get()};
rv = bundle->FormatStringFromName(NS_LITERAL_STRING("ImageTitleWithDimensionsAndFile").get(), formatStrings, 3, getter_Copies(valUni)); rv = bundle->FormatStringFromName(NS_LITERAL_STRING("ImageTitleWithDimensionsAndFile").get(), formatStrings, 4, getter_Copies(valUni));
} else { } else {
const PRUnichar *formatStrings[1] = {fileStr.get()}; const PRUnichar *formatStrings[2] = {fileStr.get(), typeStr.get()};
rv = bundle->FormatStringFromName(NS_LITERAL_STRING("ImageTitleWithoutDimensions").get(), formatStrings, 1, getter_Copies(valUni)); rv = bundle->FormatStringFromName(NS_LITERAL_STRING("ImageTitleWithoutDimensions").get(), formatStrings, 2, getter_Copies(valUni));
} }
} else { } else {
// if we got a valid size (sometimes we do not) then display it // if we got a valid size (sometimes we do not) then display it
if (width != 0 && height != 0){ if (width != 0 && height != 0){
const PRUnichar *formatStrings[2] = {widthStr.get(), heightStr.get()}; const PRUnichar *formatStrings[3] = {typeStr.get(), widthStr.get(), heightStr.get()};
rv = bundle->FormatStringFromName(NS_LITERAL_STRING("ImageTitleWithDimensions").get(), formatStrings, 2, getter_Copies(valUni)); rv = bundle->FormatStringFromName(NS_LITERAL_STRING("ImageTitleWithDimensions").get(), formatStrings, 3, getter_Copies(valUni));
} else { } else {
rv = bundle->GetStringFromName(NS_LITERAL_STRING("ImageTitleWithoutDimensionsAndFile").get(), getter_Copies(valUni)); const PRUnichar *formatStrings[1] = {typeStr.get()};
rv = bundle->FormatStringFromName(NS_LITERAL_STRING("ImageTitleWithNeitherDimensionsNorFile").get(), formatStrings, 1, getter_Copies(valUni));
} }
} }
if (NS_SUCCEEDED(rv) && valUni) { if (NS_SUCCEEDED(rv) && valUni) {
// set it on the document // set it on the document
SetTitle(nsDependentString(valUni)); SetTitle(valUni);
} }
} }
return NS_OK; return NS_OK;

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

@ -19,10 +19,11 @@
# Blake Ross <blakeross@telocity.com> (Original Author) # Blake Ross <blakeross@telocity.com> (Original Author)
# Morten Nilsen <morten@nilsen.com> # Morten Nilsen <morten@nilsen.com>
#LOCALIZATION NOTE (ImageTitleWithDimensionsAndfile): first %S is filename, second %S is width and third %S is height #LOCALIZATION NOTE (ImageTitleWithDimensionsAndFile): first %S is filename, second %S is type, third %S is width and fourth %S is height
#LOCALIZATION NOTE (ImageTitleWithoutDimensions): first %S is filename #LOCALIZATION NOTE (ImageTitleWithoutDimensions): first %S is filename, second %S is type
#LOCALIZATION NOTE (ImageTitleWithDimensions): first %S is width and second %S is height #LOCALIZATION NOTE (ImageTitleWithDimensions): first %S is type, second %S is width and third %S is height
ImageTitleWithDimensionsAndFile=%S (Image %Sx%S pixels) #LOCALIZATION NOTE (ImageTitleWithNeitherDimensionsNorFile): first %S is type
ImageTitleWithoutDimensions=%S (Image) ImageTitleWithDimensionsAndFile=%S (%S Image, %Sx%S pixels)
ImageTitleWithDimensions=(Image %Sx%S pixels) ImageTitleWithoutDimensions=%S (%S Image)
ImageTitleWithoutDimensionsAndFile=(Image) ImageTitleWithDimensions=(%S Image, %Sx%S pixels)
ImageTitleWithNeitherDimensionsNorFile=(%S Image)