Closed Bug 348233 Opened 18 years ago Closed 16 years ago

FTP and Gopher index pages are LTR always

Categories

(Core :: Networking, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.2a1

People

(Reporter: zwnj, Assigned: ehsan.akhgari)

References

(Depends on 1 open bug, Blocks 1 open bug, )

Details

(Keywords: fixed1.9.1, l12y, rtl)

Attachments

(5 files, 5 obsolete files)

FTP and Gopher index pages are LTR always.

Screenshots in Persian (RTL) locale will be attached.
Mass-assigning the new rtl keyword to RTL-related (see bug 349193).
Keywords: rtl
I can reproduce in Firefox 3.1 beta 2 with Hebrew UI. 

It seems that this page is being rendered in nsIndexedToHTML.cpp. I think it won't be too complicated to fix it.
Target Milestone: Firefox 3 → ---
I'm going to give this a shot.
Assignee: nobody → ehsan.akhgari
Status: NEW → ASSIGNED
Component: General → Networking
Product: Firefox → Core
QA Contact: general → networking
Does anyone know of a working gopher server which can be used to test the patch here?  Does Mozilla still support the gopher protocol at all?
This one works yet: gopher://quux.org/
And this is a gopher-based gopher search site, which you can find a lot of working servers: gopher://gopher.floodgap.com/7/v2/vs?firefox
Attached patch WIP Patch (obsolete) — Splinter Review
We need to import chrome://global/content/global.dtd for the locale.dir entity here.  Since this doesn't seem to be possible for HTML documents (or I don't know how), I tired to change the document to XHTML.  With this patch, any attempt to view a file:// or gopher URL results in a blank page.  DOM Inspector only shows a HEAD element under HTML, and nothing gets logged to the error console.

Can someone point out what's wrong here?
Attached patch Patch (v1) (obsolete) — Splinter Review
The meat of this patch is based on that of bug 437844.  I will comment on some parts of the patch shortly to make the review process easier.  I extended the test suite for bug 437844 to test for this bug as well.
Attachment #354000 - Attachment is obsolete: true
Attachment #359599 - Flags: superreview?(bzbarsky)
Attachment #359599 - Flags: review?(bzbarsky)
Comment on attachment 359599 [details] [diff] [review]
Patch (v1)

Promised comments:

>@@ -296,27 +297,35 @@ nsIndexedToHTML::OnStartRequest(nsIReque
>+                         // Bug 475986 makes this necessary, otherwise
>+                         // "text-align: start" would be fine
>+                         "body[chromedir=\"rtl\"] th {\n"
>+                         "  text-align: right;\n"
>+                         "}\n"

Bug 475986 (which I found when developing this patch) caused text-align:start not to work for <th> elements, so we have to use chromedir here.

>+                         "}\n"
>+                         "body[chromedir=\"rtl\"] table[order] > thead > tr > th::after {\n"
>+                         "  text-align: left;\n"

We don't have text-align:end...

>@@ -343,31 +352,37 @@ nsIndexedToHTML::OnStartRequest(nsIReque
>+                         "  }\n"
>+                         "  table {\n"
>+                         "    direction: ltr;\n"

It doesn't make sense to reverse the direction of gopher listings, because they're not usually in RTL language.  Doing so would look like reversing the direction of LTR documents if the locale direction is RTL.  This simple rule makes sure that the direction of the gopher listing remains LTR, while the rest of the page (header) is correctly converted to RTL.

>diff --git a/toolkit/themes/pinstripe/global/dirListing/dirListing.css b/toolkit/themes/pinstripe/global/dirListing/dirListing.css
> /* last modified */
> th:last-child {
>-  text-align: center;
>+  text-align: center !important;
> }

Without this, the Last Modified column header in RTL pages would be aligned to right.

>diff --git a/toolkit/themes/winstripe/global/dirListing/dirListing.css b/toolkit/themes/winstripe/global/dirListing/dirListing.css
> /* last modified */
> th:last-child {
>-  text-align: center;
>+  text-align: center !important;
> }

Same here.
Probably good to get Dao to review this, since he wrote most of this code...
I'd rather we fix bug 475986 or at least sort out what the desired behavior is there, btw, before we hack around it here.
Attachment #359599 - Flags: review?(dao)
Comment on attachment 359599 [details] [diff] [review]
Patch (v1)

Dao: can you please take a look as well?  Thanks!
The WIP patch is a lot nicer. Can we continue there?
(In reply to comment #15)
> The WIP patch is a lot nicer. Can we continue there?

Converting this to XHTML did not work.  I suspect it was because of the differences between the two (for example an item in this list <http://wiki.whatwg.org/wiki/HTML_vs._XHTML>)) but the major problem was that nothing was reported to the error console and DOM Inspector was useless as well.

Do you know of any way to dump the resulting converted string somewhere to make it possible for me to debug the problem?
The xml namespace is missing from the html element. But it doesn't like any data is being processed, so there must be more wrong...
So, what's happening is that nsDirectoryViewerFactory is creating an HTML document for directory listings <http://mxr.mozilla.org/mozilla-central/source/xpfe/components/directory/nsDirectoryViewer.cpp#1493>, whereas the content of the document tells the parser it's HTML.  So, the parser ends up using expat on an HTML content sink, which fails on this line: <http://mxr.mozilla.org/mozilla-central/source/parser/htmlparser/src/nsExpatDriver.cpp#1222>.  I'm not sure if blindly switching to XHTML mimetype in nsDirectoryViewerFactory::CreateInstance is the way to go here, or if it affects other pieces of the puzzle that I may not be aware of...
Attached patch Patch (XHTML) (obsolete) — Splinter Review
I tried switching to the XHTML doctype, and based on testing it seems to work correctly.  I also ported the test and the CSS fixes from the other patch into this patch, which is hopefully cleaner.
Attachment #359599 - Attachment is obsolete: true
Attachment #359914 - Flags: superreview?(bzbarsky)
Attachment #359914 - Flags: review?(dao)
Attachment #359914 - Flags: review?(bzbarsky)
Attachment #359599 - Flags: superreview?(bzbarsky)
Attachment #359599 - Flags: review?(dao)
Attachment #359599 - Flags: review?(bzbarsky)
Depends on: 475986
Comment on attachment 359914 [details] [diff] [review]
Patch (XHTML)

>+                         "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n"
>+                         "  \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\" ["

I think "<!DOCTYPE html [" would be sufficient.

>                          "table[order] > thead > tr > th::after {\n"
[...]
>                          "  text-align: right;\n"
>+                         "}\n"
>+                         "body[dir=\"rtl\"] table[order] > thead > tr > th::after {\n"
>+                         "  text-align: left;\n"

This could use a reference to bug 299837.

> th:last-child {
>-  text-align: center;
>+  text-align: center !important;
> }

When bug 475986 gets fixed, this should also be reverted.
Attachment #359914 - Flags: review?(dao) → review+
(In reply to comment #20)
> > th:last-child {
> >-  text-align: center;
> >+  text-align: center !important;
> > }
> 
> When bug 475986 gets fixed, this should also be reverted.

Sure.  I'll do this upon landing (in case bug 475986 doesn't get fixed in time, I'll file a followup bug so that this won't get forgotten).
Attached patch Patch (XHTML) (obsolete) — Splinter Review
Addressed Dao's review comments.
Attachment #359914 - Attachment is obsolete: true
Attachment #359989 - Flags: superreview?(bzbarsky)
Attachment #359989 - Flags: review?(bzbarsky)
Attachment #359914 - Flags: superreview?(bzbarsky)
Attachment #359914 - Flags: review?(bzbarsky)
So is there a good reason to not just fix bug 475986 and bug 299837?

Also, there are some places in this patch that are using left+right when they should just use start on <td>, no?
Depends on: 299837
Ehsan, want to update the patch now that the text-align bugs are fixed?
Attached patch Updated patch (obsolete) — Splinter Review
Attachment #359989 - Attachment is obsolete: true
Attachment #360924 - Flags: superreview?(bzbarsky)
Attachment #360924 - Flags: review?(bzbarsky)
Attachment #359989 - Flags: superreview?(bzbarsky)
Attachment #359989 - Flags: review?(bzbarsky)
(In reply to comment #23)
> Also, there are some places in this patch that are using left+right when they
> should just use start on <td>, no?

I'm not sure which changes you were referring to here.
Attachment #360924 - Flags: superreview?(bzbarsky)
Attachment #360924 - Flags: superreview+
Attachment #360924 - Flags: review?(bzbarsky)
Attachment #360924 - Flags: review+
Comment on attachment 360924 [details] [diff] [review]
Updated patch

Looks OK except for the test.  Tests must not require network access to run.
(In reply to comment #27)
> (From update of attachment 360924 [details] [diff] [review])
> Looks OK except for the test.  Tests must not require network access to run.

Hmm, do we have support for testing FTP and gopher servers any other way?  Would it be OK if I handle the no-network situation inside the test so that it doesn't fail?
Attached patch Final patchSplinter Review
This is the same as the previous patch, except that I limited the test to file:// URIs because the FTP and gopher listings are made by the same code, and it should be enough to test the file:// URIs here.
Attachment #360924 - Attachment is obsolete: true
Attachment #361135 - Flags: superreview?(bzbarsky)
Attachment #361135 - Flags: review?(bzbarsky)
> Hmm, do we have support for testing FTP and gopher servers any other way? 

Probably not yet.  Sorry I missed that comment; wasnt cced on the bug.

For what it's worth, if I say "r+sr with this one change" there's generally no need to ask me to look again (esp. if the change was as simple as just removing a hunk of code I asked you to remove, as here).  I trust you to do that right on your own and all. ;)
Attachment #361135 - Flags: superreview?(bzbarsky)
Attachment #361135 - Flags: superreview+
Attachment #361135 - Flags: review?(bzbarsky)
Attachment #361135 - Flags: review+
(In reply to comment #30)
> > Hmm, do we have support for testing FTP and gopher servers any other way? 
> 
> Probably not yet.  Sorry I missed that comment; wasnt cced on the bug.
> 
> For what it's worth, if I say "r+sr with this one change" there's generally no
> need to ask me to look again (esp. if the change was as simple as just removing
> a hunk of code I asked you to remove, as here).  I trust you to do that right
> on your own and all. ;)

Yeah, I was just not sure whether you're OK with removing the tests, or you're suggesting to do the tests another way (hence the question about whether we have support for testing FTP and gopher servers any other way).  :-)

BTW, am I good to go to request approval on this patch for 1.9.1, and land it without the CSS fixes in the two dependencies?
It won't work there without those fixes, will it?  And in fact will trigger CSS warnings for the unimplemented "end" value....
(In reply to comment #32)
> It won't work there without those fixes, will it?  And in fact will trigger CSS
> warnings for the unimplemented "end" value....

I meant to use the CSS styles in attachment 359989 [details] [diff] [review], which work without those two fixes (and in fact work around those bugs).  It won't be an ideal solution but it works, and I think it's enough for 1.9.1.
Ah, yeah.  That would be fine; I assumed by "this patch" you meant the one going into m-c.
http://hg.mozilla.org/mozilla-central/rev/35d3b66853a8
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.2a1
Comment on attachment 361135 [details] [diff] [review]
Final patch

This patch fixes the directionality of the directory listing pages in RTL locales.  It includes a test.  Requesting approval to land on 1.9.1.
Attachment #361135 - Flags: approval1.9.1?
Attachment #361135 - Flags: approval1.9.1? → approval1.9.1+
Landed on 1.9.1 with the required changes to handle the fact that bugs 299837 and 475986 will not be fixed on that branch.

http://hg.mozilla.org/releases/mozilla-1.9.1/rev/452aef18ffa2
Keywords: fixed1.9.1
Ehsan, I am afraid I am seeing a regression in your fix. Please look on the screenshot above, the string "file:" is overlapping the file name!
Attached image ar screenshot
Also reproducible for ar and fa.
Depends on: 494800
Depends on: 500282
Depends on: 525222
Depends on: 552152
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: