Closed
Bug 1261693
Opened 9 years ago
Closed 9 years ago
Implement HTMLInputElement::GetFiles
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
FIXED
mozilla49
Tracking | Status | |
---|---|---|
firefox49 | --- | fixed |
People
(Reporter: baku, Assigned: baku)
Details
(Whiteboard: btpp-active)
Attachments
(1 file, 2 obsolete files)
20.80 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
No description provided.
Assignee | ||
Comment 1•9 years ago
|
||
Attachment #8737620 -
Attachment is obsolete: true
Updated•9 years ago
|
Whiteboard: btpp-active
Assignee | ||
Updated•9 years ago
|
Attachment #8737694 -
Flags: review?(bugs)
Comment 2•9 years ago
|
||
Hmm, what is this bug about. We certainly support input.files
Comment 3•9 years ago
|
||
oh, this is about the upload proposal getFiles()
Comment 4•9 years ago
|
||
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-
Assignee | ||
Comment 5•9 years ago
|
||
Attachment #8737694 -
Attachment is obsolete: true
Attachment #8753371 -
Flags: review?(bugs)
Comment 6•9 years ago
|
||
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+
Had to back this out in https://hg.mozilla.org/integration/mozilla-inbound/rev/e94aa4bc6f1a for test failures like https://treeherder.mozilla.org/logviewer.html#?job_id=28474115&repo=mozilla-inbound
Flags: needinfo?(amarchesini)
Assignee | ||
Updated•9 years ago
|
Flags: needinfo?(amarchesini)
Pushed by amarchesini@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/b797131df354
Implement HTMLInputElement::GetFiles, r=smaug
Comment 10•9 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox49:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
Updated•6 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•