Bug 1451576 - Set dir=auto on [Browse...] button of <input type=file> draft
authorTimothy Guan-tin Chien <timdream@gmail.com>
Tue, 17 Apr 2018 18:04:39 +0800
changeset 783427 aebf15dbb3573a348630e67cd280b9b6b4c43f25
parent 783412 c02d62a80cdbca2d38cf9495f9d335e395589cb3
push id106710
push usertimdream@gmail.com
push dateTue, 17 Apr 2018 10:53:57 +0000
Bug 1451576 - Set dir=auto on [Browse...] button of <input type=file> The label of the button comes from the UI; it's direction should be independent of the web content directionality. As there is no access to :-moz-locale-dir() selectors in HTML, we'll have to rely on auto-direction here. The alternative (or, addition to the fix here) would be adding the value of the dir attribute to HtmlForm.properties, allowing the localizers to set the directionality explicitly. I however don't know if that's necessary. MozReview-Commit-ID: 5NXeLtxLXVH
--- a/layout/forms/nsFileControlFrame.cpp
+++ b/layout/forms/nsFileControlFrame.cpp
@@ -81,16 +81,18 @@ MakeAnonButton(nsIDocument* aDoc, const 
                const nsAString& aAccessKey)
   RefPtr<Element> button = aDoc->CreateHTMLElement(nsGkAtoms::button);
   // NOTE: SetIsNativeAnonymousRoot() has to be called before setting any
   // attribute.
   button->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
                   NS_LITERAL_STRING("button"), false);
+  button->SetAttr(kNameSpaceID_None, nsGkAtoms::dir,
+                  NS_LITERAL_STRING("auto"), false);
   // Set the file picking button text depending on the current locale.
   nsAutoString buttonTxt;
                                      labelKey, buttonTxt);
   // Set the browse button text. It's a bit of a pain to do because we want to
   // make sure we are not notifying.