Bug 1207088 - Don't show the "Choose folder..." button for a directory picking <input> on platforms that don't have a directory picker. r=jfkthame
☠☠ backed out by 2e41ed832f7e ☠ ☠
authorJonathan Watt <jwatt@jwatt.org>
Thu, 27 Aug 2015 20:19:37 +0100
changeset 263776 19320abf76b198fce1bd46f8a84fe3168f8f0319
parent 263775 562373c7e91c8b8872a3c1cbdfdcbeb5af769a8a
child 263777 c222869cc3115a816c407480e6b17bb80ceb1e92
push id65432
push userjwatt@jwatt.org
push dateTue, 22 Sep 2015 19:22:01 +0000
treeherdermozilla-inbound@19320abf76b1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1207088
milestone44.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 1207088 - Don't show the "Choose folder..." button for a directory picking <input> on platforms that don't have a directory picker. r=jfkthame
dom/html/HTMLInputElement.cpp
layout/forms/nsFileControlFrame.cpp
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -4845,16 +4845,19 @@ HTMLInputElement::IsFilesAndDirectoriesS
 
 void
 HTMLInputElement::ChooseDirectory(ErrorResult& aRv)
 {
   if (mType != NS_FORM_INPUT_FILE) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
+  // Script can call this method directly, so even though we don't show the
+  // "Pick Folder..." button on platforms that don't have a directory picker
+  // we have to redirect to the file picker here.
   InitFilePicker(
 #if defined(ANDROID) || defined(MOZ_B2G)
                  // No native directory picker - redirect to plain file picker
                  FILE_PICKER_FILE
 #else
                  FILE_PICKER_DIRECTORY
 #endif
                  );
--- a/layout/forms/nsFileControlFrame.cpp
+++ b/layout/forms/nsFileControlFrame.cpp
@@ -123,18 +123,23 @@ MakeAnonButton(nsIDocument* aDoc, const 
 }
 
 nsresult
 nsFileControlFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
 {
   nsCOMPtr<nsIDocument> doc = mContent->GetComposedDoc();
 
   nsIContent* content = GetContent();
-  bool isDirPicker = Preferences::GetBool("dom.input.dirpicker", false) &&
-                     content && content->HasAttr(kNameSpaceID_None, nsGkAtoms::directory);
+  bool isDirPicker =
+#if defined(ANDROID) || defined(MOZ_B2G)
+    false;
+#else
+    Preferences::GetBool("dom.input.dirpicker", false) &&
+                         content && content->HasAttr(kNameSpaceID_None, nsGkAtoms::directory);
+#endif
 
   nsRefPtr<HTMLInputElement> fileContent = HTMLInputElement::FromContentOrNull(mContent);
 
   // The access key is transferred to the "Choose files..." button only. In
   // effect that access key allows access to the control via that button, then
   // the user can tab between the two buttons.
   nsAutoString accessKey;
   fileContent->GetAccessKey(accessKey);