From 2cd57934712cc8175e8de07c8fc5236a1e0bca91 Mon Sep 17 00:00:00 2001 From: "cbiesinger%web.de" Date: Thu, 28 Mar 2002 21:12:15 +0000 Subject: [PATCH] bug 9796 r=timeless sr=tor a=asa Viewing bad images gives bad feedback --- content/html/document/src/nsImageDocument.cpp | 17 ++++++++++++++++- layout/html/forms/src/ImageDocument.properties | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/content/html/document/src/nsImageDocument.cpp b/content/html/document/src/nsImageDocument.cpp index 6a1b6ad01fe8..eb3e8ed55628 100644 --- a/content/html/document/src/nsImageDocument.cpp +++ b/content/html/document/src/nsImageDocument.cpp @@ -21,6 +21,7 @@ * * Contributor(s): * Morten Nilsen + * Christian Biesinger * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -398,7 +399,21 @@ nsImageDocument::CreateSyntheticDocument() nsHTMLValue val(src_string); image->SetHTMLAttribute(nsHTMLAtoms::src, val, PR_FALSE); - image->SetHTMLAttribute(nsHTMLAtoms::alt, val, PR_FALSE); + + // Create a stringbundle for localized error message + nsCOMPtr bundle; + nsCOMPtr stringService = + do_GetService(kStringBundleServiceCID, &rv); + if (NS_SUCCEEDED(rv) && stringService) + rv = stringService->CreateBundle(NSIMAGEDOCUMENT_PROPERTIES_URI, getter_AddRefs(bundle)); + if (NS_SUCCEEDED(rv) && bundle) { + const PRUnichar* formatString[1] = { src_string.get() }; + nsXPIDLString errorMsg; + rv = bundle->FormatStringFromName(NS_LITERAL_STRING("InvalidImage").get(), formatString, 1, getter_Copies(errorMsg)); + + nsHTMLValue errorText(errorMsg); + image->SetHTMLAttribute(nsHTMLAtoms::alt, errorText, PR_FALSE); + } root->AppendChildTo(body, PR_FALSE, PR_FALSE); center->AppendChildTo(image, PR_FALSE, PR_FALSE); diff --git a/layout/html/forms/src/ImageDocument.properties b/layout/html/forms/src/ImageDocument.properties index af15efe5f697..f78f7f3335ca 100644 --- a/layout/html/forms/src/ImageDocument.properties +++ b/layout/html/forms/src/ImageDocument.properties @@ -18,6 +18,7 @@ # Contributor(s): # Blake Ross (Original Author) # Morten Nilsen +# Christian Biesinger #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, second %S is type @@ -27,3 +28,5 @@ ImageTitleWithDimensionsAndFile=%S (%S Image, %Sx%S pixels) ImageTitleWithoutDimensions=%S (%S Image) ImageTitleWithDimensions=(%S Image, %Sx%S pixels) ImageTitleWithNeitherDimensionsNorFile=(%S Image) + +InvalidImage=The image \u201c%S\u201d cannot be displayed, because it contains errors.