Bug 1451576 - Set dir=auto on [Browse...] button of <input type=file> r=Ehsan
authorTimothy Guan-tin Chien <timdream@gmail.com>
Tue, 17 Apr 2018 18:04:39 +0800
changeset 469634 09f7885a83ce43f44209d938e982316067446e5e
parent 469633 c576cede0ed12efe1b15d3617e9cd736b79c4111
child 469635 c3163bee30b9be0e6224930e5c78327e2f4eaaf9
push id9174
push userarchaeopteryx@coole-files.de
push dateMon, 30 Apr 2018 15:33:30 +0000
treeherdermozilla-beta@1b1a8ab75f1f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan
bugs1451576
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1451576 - Set dir=auto on [Browse...] button of <input type=file> r=Ehsan 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
layout/forms/nsFileControlFrame.cpp
layout/reftests/forms/input/file/rtl-ref.xul
--- a/layout/forms/nsFileControlFrame.cpp
+++ b/layout/forms/nsFileControlFrame.cpp
@@ -82,16 +82,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->SetIsNativeAnonymousRoot();
   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;
   nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
                                      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.
--- a/layout/reftests/forms/input/file/rtl-ref.xul
+++ b/layout/reftests/forms/input/file/rtl-ref.xul
@@ -5,13 +5,13 @@
   <vbox>
     <html:style>
       vbox {
        margin-right: 8px;
       }
     </html:style>
     <html:div dir='rtl'>
       <html:div class='file' dir='rtl'>
-        <html:button>Browse&#8230;</html:button><label value="No file selected."/>
+        <html:button dir='ltr'>Browse&#8230;</html:button><label value="No file selected."/>
       </html:div>
     </html:div>
   </vbox>
 </window>