Bug 1106235 - [e10s] Form autocompletion dropdown menu doesn't honor RTL
Getting frustrated by bug 863514. I need an easy win. This bug, today, will be my (hopefully) easy win.

Already, it's kinda strange. It looks like the messages that we use to open autocomplete popups from content processes lives inside toolkit/components/satchel… wtf is satchel?

Satchel, apparently, is form history. Okay.

Searches happen asynchronously. The content process requests a search, via "FormHistory:AutoCompleteSearchAsync":

https://hg.mozilla.org/mozilla-central/file/7f343964210b/toolkit/components/satchel/nsFormAutoComplete.js#l386

Then this FormHistoryStartup component thing listens for the message, and calls into AutoCompleteE10S.jsm:

https://hg.mozilla.org/mozilla-central/file/7f343964210b/toolkit/components/satchel/FormHistoryStartup.js#l85

And does the search. As soon as the parent gets the message to search, it inits the popup (which unhides it): https://hg.mozilla.org/mozilla-central/file/7f343964210b/toolkit/components/satchel/AutoCompleteE10S.jsm#l141

When we have search results, we populate the popup with the results and send a message down to the child with the results.

Ok, so the best place to set rtl is probably when we first initialize the popup.

Perhaps we can send the direction of the form field along with the FormHistory:AutoCompleteSearchAsync message?

Yeah, that should work.

Plan:

Compute text direction in toolkit/components/satchel/nsFormAutoComplete.js's "autoCompleteSearchAsync"
Send the direction up in the message
In the message receiver, pass the direction to _initPopup
Have _initPopup set the direction on the popup.

Boom, roasted. Let's do it. With checkboxes!

A brilliant test-case - put this in the URL bar:

data:text/html, <html dir="rtl"><body><form><input type="text" name="text1" value="" autocomplete="on"/></form></body></html>?text1=test

Compute text direction in toolkit/components/satchel/nsFormAutoComplete.js's "autoCompleteSearchAsync"
Send the direction up in the message
In the message receiver, pass the direction to _initPopup
Have _initPopup set the direction on the popup.

Ah, so this is interesting. It looks like I can't just set the dir attribute (or chromedir attribute) on the panel and call it a day. That doesn't seem to work. Looking at the single-process case, this is the bug that added RTL support (bug 649840).

Ok, panel.style.direction setting works just fine. Let's roll!

Posting patch.