Bug 1068838 - Add chrome-only method for setting an <input>'s file list. r=sicking
authorJed Davis <jld@mozilla.com>
Mon, 26 Jan 2015 16:22:59 -0800
changeset 253020 f9131ff0a89b6c8f1c1c6c20610db71ee531780a
parent 253019 7971981a6000a0b92f4d2237745f3a3d052b0a2c
child 253021 a0f9be26c71e854ab8223bdae6f019ec3cd11dc2
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs1068838
milestone38.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 1068838 - Add chrome-only method for setting an <input>'s file list. r=sicking
dom/html/HTMLInputElement.cpp
dom/html/HTMLInputElement.h
dom/webidl/HTMLInputElement.webidl
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -2324,16 +2324,26 @@ HTMLInputElement::MozGetFileNameArray(ui
   }
 
   *aFileNames = ret;
 
   return NS_OK;
 }
 
 void
+HTMLInputElement::MozSetFileArray(const Sequence<OwningNonNull<File>>& aFiles)
+{
+  nsTArray<nsRefPtr<File>> files;
+  for (uint32_t i = 0; i < aFiles.Length(); ++i) {
+    files.AppendElement(aFiles[i]);
+  }
+  SetFiles(files, true);
+}
+
+void
 HTMLInputElement::MozSetFileNameArray(const Sequence< nsString >& aFileNames)
 {
   nsTArray<nsRefPtr<File>> files;
   for (uint32_t i = 0; i < aFileNames.Length(); ++i) {
     nsCOMPtr<nsIFile> file;
 
     if (StringBeginsWith(aFileNames[i], NS_LITERAL_STRING("file:"),
                          nsASCIICaseInsensitiveStringComparator())) {
--- a/dom/html/HTMLInputElement.h
+++ b/dom/html/HTMLInputElement.h
@@ -711,16 +711,17 @@ public:
 
   nsIControllers* GetControllers(ErrorResult& aRv);
 
   int32_t GetTextLength(ErrorResult& aRv);
 
   void MozGetFileNameArray(nsTArray< nsString >& aFileNames);
 
   void MozSetFileNameArray(const Sequence< nsString >& aFileNames);
+  void MozSetFileArray(const Sequence<OwningNonNull<File>>& aFiles);
 
   HTMLInputElement* GetOwnerNumberControl();
 
   void StartNumberControlSpinnerSpin();
   void StopNumberControlSpinnerSpin();
   void StepNumberControlForUserEvent(int32_t aDirection);
 
   /**
--- a/dom/webidl/HTMLInputElement.webidl
+++ b/dom/webidl/HTMLInputElement.webidl
@@ -149,16 +149,19 @@ partial interface HTMLInputElement {
   readonly attribute long                  textLength;
 
   [ChromeOnly]
   sequence<DOMString> mozGetFileNameArray();
 
   [ChromeOnly]
   void mozSetFileNameArray(sequence<DOMString> fileNames);
 
+  [ChromeOnly]
+  void mozSetFileArray(sequence<File> files);
+
   // Number controls (<input type=number>) have an anonymous text control
   // (<input type=text>) in the anonymous shadow tree that they contain. On
   // such an anonymous text control this property provides access to the
   // number control that owns the text control. This is useful, for example,
   // in code that looks at the currently focused element to make decisions
   // about which IME to bring up. Such code needs to be able to check for any
   // owning number control since it probably wants to bring up a number pad
   // instead of the standard keyboard, even when the anonymous text control has