Closed Bug 1261693 Opened 9 years ago Closed 9 years ago

Implement HTMLInputElement::GetFiles

Categories

(Core :: DOM: Core & HTML, defect)

47 Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla49
Tracking Status
firefox49 --- fixed

People

(Reporter: baku, Assigned: baku)

Details

(Whiteboard: btpp-active)

Attachments

(1 file, 2 obsolete files)

Attached patch getFiles.patch (obsolete) — Splinter Review
No description provided.
Attached patch 1261693_getFiles.patch (obsolete) — Splinter Review
Attachment #8737620 - Attachment is obsolete: true
Whiteboard: btpp-active
Attachment #8737694 - Flags: review?(bugs)
Hmm, what is this bug about. We certainly support input.files
oh, this is about the upload proposal getFiles()
Comment on attachment 8737694 [details] [diff] [review] 1261693_getFiles.patch You need to call ClearGetFilesHelpers in HTMLInputElement's dtor to ensure the member variables are released in main thread. >+class GetFilesHelper final : public nsRunnable >+{ >+public: >+ static already_AddRefed<GetFilesHelper> >+ Create(nsIGlobalObject* aGlobal, >+ const nsTArray<OwningFileOrDirectory>& aFilesOrDirectory, >+ bool aRecursiveFlag, ErrorResult& aRv) >+ { >+ MOZ_ASSERT(aGlobal); >+ >+ RefPtr<GetFilesHelper> helper = new GetFilesHelper(aGlobal, aRecursiveFlag); >+ >+ nsTArray<nsString> directoryPaths; >+ >+ for (uint32_t i = 0; i < aFilesOrDirectory.Length(); ++i) { >+ const OwningFileOrDirectory& data = aFilesOrDirectory[i]; >+ if (data.IsFile()) { >+ if (!helper->mFiles.AppendElement(data.GetAsFile(), fallible)) { >+ aRv.Throw(NS_ERROR_OUT_OF_MEMORY); >+ return nullptr; >+ } >+ } else { >+ MOZ_ASSERT(data.IsDirectory()); >+ >+ // We just want 1 directory. >+ MOZ_ASSERT(directoryPaths.IsEmpty()); I don't understand this setup. Why do we have an array for directories if we expect to get just one directory. >+#ifdef DEBUG >+ nsAutoString path; >+ directory->GetPath(path, aRv); >+ if (NS_WARN_IF(aRv.Failed())) { >+ return nullptr; >+ } >+ >+ MOZ_ASSERT(path.EqualsLiteral(FILESYSTEM_DOM_PATH_SEPARATOR_LITERAL)); >+#endif Could you perhaps call the variable domPath here to hint that we're playing with the top level dom stuff >+ >+ nsAutoString fullPath; >+ aRv = directory->GetFullRealPath(fullPath); >+ if (NS_WARN_IF(aRv.Failed())) { >+ return nullptr; >+ } >+ >+ directoryPaths.AppendElement(fullPath); >+ } >+ } >+ >+ // No directories to explore. >+ if (directoryPaths.IsEmpty()) { >+ helper->mListingCompleted = true; >+ return helper.forget(); >+ } >+ >+ MOZ_ASSERT(helper->mFiles.IsEmpty()); >+ helper->SetDirectoryPath(directoryPaths[0]); so here we just use the first item. Why do we even have the array? Took a bit time to understand, but yes, almost there. The top level directory handling could use some good comments. Only one directory is expected?
Attachment #8737694 - Flags: review?(bugs) → review-
Attachment #8737694 - Attachment is obsolete: true
Attachment #8753371 - Flags: review?(bugs)
Comment on attachment 8753371 [details] [diff] [review] 1261693_getFiles.patch >+ >+ bool isLink, isSpecial, isFile, isDir; >+ if (NS_WARN_IF(NS_FAILED(currFile->IsSymlink(&isLink)) || >+ NS_FAILED(currFile->IsSpecial(&isSpecial))) || >+ isLink || isSpecial) { >+ continue; >+ } Please file a bug which blocks exposing both blink API and upload proposal to sort out link handling. I think our link handling for files is broken, and it should be fixed everywhere (but not sure, just think so). I've mentioned this in some other bug before. >+ RefPtr<GetFilesHelper> mGetFilesRecursiveHelper; >+ RefPtr<GetFilesHelper> mGetFilesNonRecursiveHelper; Could we store these as nsINode properties to reduce the memory usage of non-type=file input elements. You could do that change as a separate patch or bug.
Attachment #8753371 - Flags: review?(bugs) → review+
Flags: needinfo?(amarchesini)
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: