diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index c5849de49e..dd2d134f8e 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -3105,6 +3105,26 @@ HTMLInputElement::GetFiles() return mFileList; } +void +HTMLInputElement::SetFiles(FileList* aFiles) +{ + if (mType != NS_FORM_INPUT_FILE || !aFiles) { + return; + } + + // Clear |mFileList| to omit |UpdateFileList| + if (mFileList) { + mFileList->Clear(); + mFileList = nullptr; + } + + // Update |mFilesOrDirectories| + SetFiles(aFiles, true); + + // Update |mFileList| without copy + mFileList = aFiles; +} + /* static */ void HTMLInputElement::HandleNumberControlSpin(void* aData) { diff --git a/dom/html/HTMLInputElement.h b/dom/html/HTMLInputElement.h index 16651d5200..24fc7454ac 100644 --- a/dom/html/HTMLInputElement.h +++ b/dom/html/HTMLInputElement.h @@ -474,6 +474,7 @@ public: // XPCOM GetForm() is OK FileList* GetFiles(); + void SetFiles(FileList* aFiles); // XPCOM GetFormAction() is OK void SetFormAction(const nsAString& aValue, ErrorResult& aRv) diff --git a/dom/webidl/HTMLInputElement.webidl b/dom/webidl/HTMLInputElement.webidl index 93ad90f456..528689bbd1 100644 --- a/dom/webidl/HTMLInputElement.webidl +++ b/dom/webidl/HTMLInputElement.webidl @@ -40,7 +40,7 @@ interface HTMLInputElement : HTMLElement { attribute boolean disabled; readonly attribute HTMLFormElement? form; [Pure] - readonly attribute FileList? files; + attribute FileList? files; [CEReactions, Pure, SetterThrows] attribute DOMString formAction; [CEReactions, Pure, SetterThrows]