From 8c09439d283befad60b4f6e08f12088319e55490 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Sun, 15 Feb 2009 10:51:04 +0330 Subject: [PATCH] Bug 348233 - FTP and Gopher index pages are LTR always; r+sr=bzbarsky --- .../streamconv/converters/nsIndexedToHTML.cpp | 43 +++++++++++-------- toolkit/content/tests/chrome/Makefile.in | 1 + toolkit/content/tests/chrome/bug437844.dtd | 1 + .../content/tests/chrome/bug437844.manifest | 1 + .../content/tests/chrome/test_bug437844.xul | 32 ++++++++++---- .../global/dirListing/dirListing.css | 9 ++++ .../global/dirListing/dirListing.css | 9 ++++ .../directory/nsDirectoryViewer.cpp | 8 ++-- 8 files changed, 73 insertions(+), 31 deletions(-) create mode 100644 toolkit/content/tests/chrome/bug437844.dtd diff --git a/netwerk/streamconv/converters/nsIndexedToHTML.cpp b/netwerk/streamconv/converters/nsIndexedToHTML.cpp index b4e9b82b906..6e4a01c1c5e 100644 --- a/netwerk/streamconv/converters/nsIndexedToHTML.cpp +++ b/netwerk/streamconv/converters/nsIndexedToHTML.cpp @@ -23,6 +23,7 @@ * Bradley Baetz * Christopher A. Aillon * Dão Gottwald + * Ehsan Akhgari * * 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 @@ -156,7 +157,7 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) { rv = channel->GetURI(getter_AddRefs(uri)); if (NS_FAILED(rv)) return rv; - channel->SetContentType(NS_LITERAL_CSTRING("text/html")); + channel->SetContentType(NS_LITERAL_CSTRING("application/xhtml+xml")); mParser = do_CreateInstance("@mozilla.org/dirIndexParser;1",&rv); if (NS_FAILED(rv)) return rv; @@ -275,9 +276,7 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) { } nsString buffer; - buffer.AppendLiteral("\n" - "\n\n" - "\n" - "\n" + "]]>\n" "\n"); + " href=\"chrome://global/skin/dirListing/dirListing.css\" />\n"); if (!isSchemeGopher) { - buffer.AppendLiteral("\n"); + "]]>\n"); } buffer.AppendLiteral(" innerUri = NS_GetInnermostURI(uri); @@ -516,7 +523,7 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) { "BYWFOWicuqppoNTnStHzPFCPQhBEBOyGAX4JMADFetubi4BS" "YAAAAABJRU5ErkJggg%3D%3D"); } - buffer.AppendLiteral("\">\n"); + buffer.AppendLiteral("\" />\n<title>"); // Anything but a gopher url needs to end in a /, // otherwise we end up linking to file:///foo/dirfile @@ -585,14 +592,14 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) { nsString htmlEscapedUri; htmlEscapedUri.Adopt(nsEscapeHTML2(utf16BaseURI.get(), utf16BaseURI.Length())); buffer.Append(htmlEscapedUri); - buffer.AppendLiteral("\">\n"); + buffer.AppendLiteral("\" />\n"); } else { NS_ERROR("broken protocol handler didn't escape double-quote."); } - buffer.AppendLiteral("</head>\n<body>\n<h1>"); + buffer.AppendLiteral("</head>\n<body dir=\"&locale.dir;\">\n<h1>"); const PRUnichar* formatHeading[] = { htmlEscSpec.get() @@ -630,7 +637,7 @@ nsIndexedToHTML::OnStartRequest(nsIRequest* request, nsISupports *aContext) { getter_Copies(showHiddenText)); if (NS_FAILED(rv)) return rv; - buffer.AppendLiteral("<p id=\"UI_showHidden\" style=\"display:none\"><label><input type=\"checkbox\" checked onchange=\"updateHidden()\">"); + buffer.AppendLiteral("<p id=\"UI_showHidden\" style=\"display:none\"><label><input type=\"checkbox\" checked=\"checked\" onchange=\"updateHidden()\" />"); AppendNonAsciiToNCR(showHiddenText, buffer); buffer.AppendLiteral("</label></p>\n"); } @@ -934,7 +941,7 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest, getter_Copies(altText)); if (NS_FAILED(rv)) return rv; AppendNonAsciiToNCR(altText, pushBuffer); - pushBuffer.AppendLiteral("\">"); + pushBuffer.AppendLiteral("\" />"); } pushBuffer.Append(escapedShort); diff --git a/toolkit/content/tests/chrome/Makefile.in b/toolkit/content/tests/chrome/Makefile.in index 3a7af0876e6..ea7d73850d2 100644 --- a/toolkit/content/tests/chrome/Makefile.in +++ b/toolkit/content/tests/chrome/Makefile.in @@ -61,6 +61,7 @@ _TEST_FILES = findbar_window.xul \ bug429723_window.xul \ test_bug429723.xul \ bug437844.css \ + bug437844.dtd \ bug437844.manifest \ test_bug437844.xul \ bug451286_window.xul \ diff --git a/toolkit/content/tests/chrome/bug437844.dtd b/toolkit/content/tests/chrome/bug437844.dtd new file mode 100644 index 00000000000..8b32de67467 --- /dev/null +++ b/toolkit/content/tests/chrome/bug437844.dtd @@ -0,0 +1 @@ +<!ENTITY locale.dir "rtl"> diff --git a/toolkit/content/tests/chrome/bug437844.manifest b/toolkit/content/tests/chrome/bug437844.manifest index 630063b9c1b..96372d0c501 100644 --- a/toolkit/content/tests/chrome/bug437844.manifest +++ b/toolkit/content/tests/chrome/bug437844.manifest @@ -1,2 +1,3 @@ # Override intl.css with our own CSS file override chrome://global/locale/intl.css chrome://mochikit/content/chrome/toolkit/content/tests/chrome/bug437844.css +override chrome://global/locale/global.dtd chrome://mochikit/content/chrome/toolkit/content/tests/chrome/bug437844.dtd diff --git a/toolkit/content/tests/chrome/test_bug437844.xul b/toolkit/content/tests/chrome/test_bug437844.xul index 6c0595d56c5..ec9965648d0 100644 --- a/toolkit/content/tests/chrome/test_bug437844.xul +++ b/toolkit/content/tests/chrome/test_bug437844.xul @@ -5,12 +5,13 @@ type="text/css"?> <!-- https://bugzilla.mozilla.org/show_bug.cgi?id=437844 +https://bugzilla.mozilla.org/show_bug.cgi?id=348233 --> -<window title="Mozilla Bug 437844" +<window title="Mozilla Bug 437844 and Bug 348233" xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> - <title>Test for Bug 437844 + Test for Bug 437844 and Bug 348233