Closed
Bug 656647
Opened 14 years ago
Closed 14 years ago
File constructor should take nsIFile
Categories
(Core :: DOM: Core & HTML, enhancement)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla6
People
(Reporter: khuey, Assigned: khuey)
Details
(Keywords: dev-doc-complete)
Attachments
(1 file)
3.69 KB,
patch
|
sicking
:
review+
|
Details | Diff | Splinter Review |
No description provided.
Assignee | ||
Comment 1•14 years ago
|
||
Assignee | ||
Updated•14 years ago
|
Keywords: dev-doc-needed
Comment 2•14 years ago
|
||
Please declare rv closer to its use, and note that you shadow it in the string case.
Comment on attachment 531960 [details] [diff] [review]
Patch
Review of attachment 531960 [details] [diff] [review]:
-----------------------------------------------------------------
::: content/base/src/nsDOMFile.cpp
@@ +682,5 @@
>
> + // If it's not a JSObject, give up
> + JSObject* obj = JSVAL_TO_OBJECT(aArgv[0]);
> + if (!obj)
> + return NS_ERROR_UNEXPECTED;
This doesn't actually work. If you hand JS_TO_OBJECT something that isn't an object it'll assert and perform an invalid cast.
But I believe the JSVAL_IS_PRIMITIVE is enough to ensure that you have an object. So just remove the if-check.
@@ +701,5 @@
> + return NS_ERROR_XPC_BAD_CONVERT_JS;
> + }
> +
> + nsCOMPtr<nsILocalFile> localFile;
> + nsresult rv = NS_NewLocalFile(xpcomStr,
Remove the 'nsresult' here, as Ms2ger pointed out.
@@ +706,5 @@
> + PR_FALSE, getter_AddRefs(localFile));
> + NS_ENSURE_SUCCESS(rv, rv);
> +
> + file = do_QueryInterface(localFile, &rv);
> + NS_ENSURE_SUCCESS(rv, rv);
Generally speaking, don't use nsresults together with do_QIs, simply nullcheck the result instead.
Though in this case an assert should be enough.
Attachment #531960 -
Flags: review?(jonas) → review+
Assignee | ||
Comment 4•14 years ago
|
||
I changed the JSVAL_IS_PRIMITIVE guard to JSVAL_IS_OBJECT.
Other comments addressed.
http://hg.mozilla.org/mozilla-central/rev/190b0bff3507
http://hg.mozilla.org/mozilla-central/rev/0b84815ad48e
Severity: normal → enhancement
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Flags: in-testsuite+
OS: Windows 7 → All
Hardware: x86 → All
Resolution: --- → FIXED
Target Milestone: --- → mozilla6
Version: unspecified → Trunk
Comment 5•14 years ago
|
||
Updated documentation:
https://developer.mozilla.org/en/Extensions/Using_the_DOM_File_API_in_chrome_code
https://developer.mozilla.org/en/DOM/File
And linked to from Firefox 6 for developers.
Keywords: dev-doc-needed → dev-doc-complete
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
•