Closed
Bug 661991
Opened 14 years ago
Closed 13 years ago
Start using the new Common Item Dialogs in Vista and later in nsFilePicker
Categories
(Core :: Widget: Win32, defect)
Tracking
()
VERIFIED
FIXED
mozilla11
Tracking | Status | |
---|---|---|
firefox11 | --- | verified |
People
(Reporter: bbondy, Assigned: jimm)
References
()
Details
(Keywords: addon-compat, qawanted, verified-beta, Whiteboard: [qa!])
Attachments
(11 files, 12 obsolete files)
24.74 KB,
image/png
|
Details | |
27.59 KB,
image/png
|
Details | |
84.43 KB,
image/png
|
faaborg
:
ui-review+
|
Details |
12.56 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
4.88 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
12.87 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
15.26 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
9.98 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
36.66 KB,
patch
|
neil
:
review+
|
Details | Diff | Splinter Review |
66.44 KB,
patch
|
Details | Diff | Splinter Review | |
1.52 KB,
patch
|
bbondy
:
review+
|
Details | Diff | Splinter Review |
+++ This bug was initially created as a clone of Bug #660833 +++
We should use the new Common Item Dialog (file picker dialogs) in Vista and later.
This code would be implemented in nsFilePicker.cpp instead of the current call to GetOpenFileNameW and GetSaveFileNameW.
From MSDN:
"Starting with Windows Vista, the Common Item Dialog supersedes the older Common File Dialog"
Documentation on the new Common Item Dialog can be found on MSDN here:
http://msdn.microsoft.com/en-us/library/bb776913%28v=vs.85%29.aspx
Steps to Reproduce:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action='#' method='post' enctype='multipart/form-data'>
<input size='40' name='uploads[]' type='file' multiple>
</form>
</body>
</html>
Actual Results:
We use the old file picker dialogs in Vista and later.
Expected Results:
We should use the new recommended file picker dialogs in Vista and later.
Reporter | ||
Updated•14 years ago
|
Assignee: nobody → netzen
Reporter | ||
Updated•14 years ago
|
Summary: Forms with <input type='file' multiple> does not accept more than 253 files at once. → Start using the new Common Item Dialogs in Vista and later in nsFilePicker
I don't see much benefit in using this.
The "Common Item" dialog does not really provide any additional functionality over the "Common File" dialog, and the file picker dialogs spawned by either method are actually the same.
The difference is in the interface. The old OFN is a WinAPI-style interface, using simple calls to C-style functions exported by a DLL. The new interface uses COM. They ultimately provide interfaces to the same underlying OS component.
The biggest advantage to the new interface (and probably the reason why they created it) is that customizing the file dialogs (i.e., adding/removing custom UI elements) is more straightforward: you don't have to deal with dialog templates and message hooks like you did with the old OFN APIs (the old method of customization was so fragile that it often broke with each new version of Windows, which is why MSFT maintains different versions of the file dialog, to give programs that customized a file dialog from an older Windows an older file dialog). But, like most programs in the Windows ecosystem, Firefox does not customize the file picker dialog (nor does it have any compelling reason to), so all this is moot (at least for now; maybe one day we might decide to jazz up the file picker).
This *might* have made bug 660833 easier to fix (I'm not 100% convinced that it would have, since it looks like we have to go manually resize the combo box's maxlength), but then that fix wouldn't work on NT5. Which brings us to the biggest problem here: maintaining two separate code paths for NT5 and NT6 when we already have mature, working code using the legacy API.
This is something to consider when (1) we have a compelling reason to add custom UI elements to the file picker dialog and (2) XP's market share is at least an order of magnitude lower than what it is today. (I'm not going to hold my breath for that last one; maybe there will be a sharp die-off in 2014, but XP is like a cat with nine lives. :P)
Reporter | ||
Comment 2•14 years ago
|
||
Thanks for sharing Kai, I agree that most of the functionality is around customizing the dialog.
I am fine if you want to mark this as invalid or lower priority until we have a better reason to do this task.
Reporter | ||
Updated•14 years ago
|
Assignee: netzen → nobody
Reporter | ||
Comment 3•13 years ago
|
||
Bugs like Bug 629920 might be a good idea to do this task. Also Microsoft has put a notice on many pages about the old API should not be used any more. Perhaps they know of some bugs with it.
Comment 4•13 years ago
|
||
The new Vista/7 directory picker has a new UI, hasn't it? Our current directory picker on Windows is quite ugly and we could use a nicer one I believe.
Reporter | ||
Comment 5•13 years ago
|
||
I could be wrong, but I think the new dialogs are the same look & feel as we have now with the old API.
http://msdn.microsoft.com/en-us/library/bb776913%28v=vs.85%29.aspx
I get almost the same looking dialogs on my Win7 by going to View -> Content on the list view. The difference from the screenshot from what I have I think is just Win7 vs Vista.
Reporter | ||
Comment 6•13 years ago
|
||
The new dialogs do have:
- Ability to customize more, not sure if we have any use for that right now.
- Old API is deprecated by Microsoft, not sure if they will support the old forever.
- They do have state persistence, so it would solve Bug 465198.
Comment 7•13 years ago
|
||
I'm not a Windows developer but according to http://msdn.microsoft.com/en-us/library/bb761832%28v=vs.85%29.aspx there is a FOS_PICKFOLDERS which probably means that the UI for picking a file or a folder is more or less the same (like on GTK). Which wasn't the case for Windows XP AFAIK.
Reporter | ||
Comment 8•13 years ago
|
||
I'm not sure about the look for folders, but the API is the same via that flag as you mentioned.
For folders we use: SHBrowseForFolderW
http://msdn.microsoft.com/en-us/library/bb762115(v=vs.85).aspx
The recommended way is to use IFileDialog with the FOS_PICKFOLDERS
For files we use: GetOpenFileNameW and GetSaveFileNameW
http://msdn.microsoft.com/en-us/library/ms646927(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/ms646928(v=vs.85).aspx
The recommended way is to use IFileOpenDialog and IFileSaveDialog (Which inherit from IFileDialog)
Comment 9•13 years ago
|
||
Assuming the API is the same, I would expect the look to be the same but I might be wrong.
Though, I assume that the real issue here is that there is no way to have a code path for Windows XP and another for Windows Vista/7. Is that the case?
Reporter | ||
Comment 10•13 years ago
|
||
It would be pretty much a rewrite of the nsFilePicker code on Windows, which isn't that big.
But yes we'd need to keep all of the old code as well, so basically 2x the code to support on Windows.
You can check if the method is available dynamically and load the methods dynamically for calling on post XP. So I do not think that is an issue.
Comment 11•13 years ago
|
||
We should do it then! :)
Assignee | ||
Comment 12•13 years ago
|
||
(In reply to comment #11)
> We should do it then! :)
Depends on what we gain.. if it's the same dialog with a slightly updated look but the same functionality, it may not be worth it. We can migrate to this and dump the old code completely if and when we drop XP support. (five years from now maybe?)
Comment 13•13 years ago
|
||
We would like to refresh the UI of the filepicker and add a few functionalities like selecting a directory but the directory picker of Windows is so bad that users might really not like that. If we have something better for Windows Vista and 7 at least, that would be great.
Reporter | ||
Comment 14•13 years ago
|
||
As a next step for this task I'll make a sample app to compare the dialogs to see exactly what visually changes if anything. I'll probably do this early next week and I'll submit some screenshots if they differ.
Reporter | ||
Comment 15•13 years ago
|
||
Reporter | ||
Comment 16•13 years ago
|
||
There is also SHBrowseForFolder w/ BIF_USENEWUI, this is just the same as BIF_NEWDIALOGSTYLE but also with an edit box
Reporter | ||
Comment 17•13 years ago
|
||
Massive improvement for folder picker UI using new API.
Comment 18•13 years ago
|
||
(In reply to Brian R. Bondy [:bbondy] from comment #17)
> Created attachment 551460 [details]
> New folder picker UI by using IFileDialog with the FOS_PICKFOLDERS
>
> Massive improvement for folder picker UI using new API.
Indeed!
I believe there is no reason to argue about why we should use this API now :)
Reporter | ||
Comment 19•13 years ago
|
||
The file picker UI is exactly the same by the way.
The folder picker UI as I mentioned is a significant advantage. We currently use the old one with BIF_USENEWUI.
Assignee | ||
Comment 20•13 years ago
|
||
(In reply to Mounir Lamouri (:volkmar) from comment #18)
> (In reply to Brian R. Bondy [:bbondy] from comment #17)
> > Created attachment 551460 [details]
> > New folder picker UI by using IFileDialog with the FOS_PICKFOLDERS
> >
> > Massive improvement for folder picker UI using new API.
>
> Indeed!
> I believe there is no reason to argue about why we should use this API now :)
I agree, the newer ui looks like a relevant win. We should seek ux approval though to be sure.
Reporter | ||
Updated•13 years ago
|
Assignee: nobody → netzen
Reporter | ||
Updated•13 years ago
|
Attachment #551460 -
Flags: ui-review?(faaborg)
Assignee | ||
Comment 21•13 years ago
|
||
The key issue here is that we will be implementing new code to support this ui on platforms that support it, while maintaining the old code for older platforms. So the open question is, is this a big enough win to justify the overhead.
Comment 22•13 years ago
|
||
Comment on attachment 551460 [details]
New folder picker UI by using IFileDialog with the FOS_PICKFOLDERS
yep, very happy for us to get this fixed.
Attachment #551460 -
Flags: ui-review?(faaborg) → ui-review+
Comment 23•13 years ago
|
||
Something to note here is that the code in question is completely untested in our automated tests, and given bugs like bug 483481 that we've had in the past, I would say that we should be very careful with changes to this code...
Reporter | ||
Comment 24•13 years ago
|
||
Another reason to use the new Common File Dialogs is the fix for Bug 660833 not being able to be used >=Vista. See Comment 5 of Bug 684506. Basically you can't set a hook which we need for Bug 660833 and get the new looking file picker dialogs (with search and new places bar).
As time goes on our code is starting to diverge anyway for >=Vista+ and <=XP. As of the fix in Bug 684506 our code will start to diverge.
Assignee | ||
Updated•13 years ago
|
Assignee: netzen → jmathies
Depends on: CVE-2012-0454
Assignee | ||
Comment 25•13 years ago
|
||
Assignee | ||
Comment 26•13 years ago
|
||
Attachment #578706 -
Attachment is obsolete: true
Assignee | ||
Updated•13 years ago
|
Assignee | ||
Comment 27•13 years ago
|
||
Assignee | ||
Comment 28•13 years ago
|
||
Attachment #579016 -
Attachment is obsolete: true
Assignee | ||
Comment 29•13 years ago
|
||
Assignee | ||
Comment 30•13 years ago
|
||
Assignee | ||
Comment 31•13 years ago
|
||
Attachment #579123 -
Attachment is obsolete: true
Assignee | ||
Comment 32•13 years ago
|
||
Assignee | ||
Comment 33•13 years ago
|
||
Assignee | ||
Comment 34•13 years ago
|
||
Attachment #579807 -
Attachment is obsolete: true
Assignee | ||
Comment 35•13 years ago
|
||
With a few updates these pass try fine. Unfortunately my close on parent close isn't working on XP, once I figure that out I'll post the final set and kick off reviews. I'm still confident we'll get this in before the 20th merge.
Assignee | ||
Comment 36•13 years ago
|
||
Neil, this is purely code reformatting, no changes in functionality.
Attachment #578844 -
Attachment is obsolete: true
Attachment #579019 -
Attachment is obsolete: true
Attachment #579122 -
Attachment is obsolete: true
Attachment #579125 -
Attachment is obsolete: true
Attachment #579425 -
Attachment is obsolete: true
Attachment #579809 -
Attachment is obsolete: true
Attachment #580457 -
Flags: review?(neil)
Assignee | ||
Comment 37•13 years ago
|
||
(In reply to Jim Mathies [:jimm] from comment #36)
> Created attachment 580457 [details] [diff] [review]
> prelim cleanup v.1
>
> Neil, this is purely code reformatting, no changes in functionality.
(Actually, looking at it, there is some new code in the auto classes on the top of the cpp.)
Assignee | ||
Comment 38•13 years ago
|
||
Brian, this is the basic QI set up patch. Note the elevation of some defines in the header. I prefer to avoid this if possible but in this case either I had to do it or would have had to place the header definitions in our code base. (Which is something I also try to avoid.) Thankfully there are no build problems as a result.
Attachment #580460 -
Flags: review?(netzen)
Assignee | ||
Comment 39•13 years ago
|
||
Assignee | ||
Comment 40•13 years ago
|
||
Assignee | ||
Comment 41•13 years ago
|
||
Assignee | ||
Comment 42•13 years ago
|
||
Comment 43•13 years ago
|
||
Comment on attachment 580460 [details] [diff] [review]
part1 - qi, includes, file events
Review of attachment 580460 [details] [diff] [review]:
-----------------------------------------------------------------
::: widget/src/windows/nsFilePicker.cpp
@@ +185,5 @@
> +STDMETHODIMP nsFilePicker::QueryInterface(REFIID refiid, void** ppvResult)
> +{
> + *ppvResult = NULL;
> + if (IID_IUnknown == refiid ||
> + refiid == __uuidof(IFileDialogEvents)) {
I don't know if mingw supports __uuidof, but I won't hold this against you!
Attachment #580460 -
Flags: review?(netzen) → review+
Comment 44•13 years ago
|
||
Comment on attachment 580461 [details] [diff] [review]
part2 - folder picker
Review of attachment 580461 [details] [diff] [review]:
-----------------------------------------------------------------
::: widget/src/windows/nsFilePicker.cpp
@@ +450,5 @@
> + return false;
> +
> + nsRefPtr<IFileOpenDialog> dialog;
> + if (FAILED(CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC,
> + __uuidof(IFileOpenDialog),
Same comment about __uuidof.
@@ +459,5 @@
> + dialog->Advise(this, &mFDECookie);
> +
> + // options
> + FILEOPENDIALOGOPTIONS fos = 0;
> + fos |= FOS_PICKFOLDERS;
FILEOPENDIALOGOPTIONS fos = FOS_PICKFOLDERS;
@@ +467,5 @@
> + dialog->SetTitle(mTitle.get());
> + if (!aInitialDir->IsEmpty()) {
> + nsRefPtr<IShellItem> folder;
> + if (SUCCEEDED(SHCreateItemFromParsingName(aInitialDir->get(), NULL,
> + __uuidof(IShellItem),
Ditto.
@@ +474,5 @@
> + }
> + }
> +
> + AutoDestroyTmpWindow adtw((HWND)(mParentWidget.get() ?
> + mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : NULL));
I find this not very well readable. Can you please init the variable to NULL and then check for the condition on the next line?
@@ +493,5 @@
> + return false;
> + mUnicodeFile.Assign(str);
> + CoTaskMemFree(str);
> +
> + return true;
Nit: indentation.
::: widget/src/windows/nsFilePicker.h
@@ +145,5 @@
> nsCOMArray<nsILocalFile> mFiles;
> static char mLastUsedDirectory[];
> nsString mUnicodeFile;
> static PRUnichar *mLastUsedUnicodeDirectory;
> + DWORD mFDECookie;
Please wrap this in an #ifdef MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN.
Attachment #580461 -
Flags: review+
Comment 45•13 years ago
|
||
Comment on attachment 580462 [details] [diff] [review]
part3 - file picker
Review of attachment 580462 [details] [diff] [review]:
-----------------------------------------------------------------
r=me with the comments addressed.
::: widget/src/windows/nsFilePicker.cpp
@@ +458,5 @@
> // hook up event callbacks
> dialog->Advise(this, &mFDECookie);
>
> // options
> + FILEOPENDIALOGOPTIONS fos = FOS_PICKFOLDERS;
:)
@@ +741,5 @@
> +
> + // options
> +
> + FILEOPENDIALOGOPTIONS fos = 0;
> + fos |= FOS_SHAREAWARE | FOS_OVERWRITEPROMPT | FOS_NOREADONLYRETURN;
:)
@@ +767,5 @@
> + // Don't follow shortcuts when saving a shortcut, this can be used
> + // to trick users (bug 271732)
> + if (IsDefaultPathLink())
> + fos |= FOS_NODEREFERENCELINKS;
> + break;
Add an NS_NOTREACHED default label please?
@@ +810,5 @@
> +
> + // display
> +
> + AutoDestroyTmpWindow adtw((HWND)(mParentWidget.get() ?
> + mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : NULL));
Same comment as before.
@@ +991,2 @@
>
> //First, make sure the file name is not too long!
While you're here, can you please fix the spacing in the comments in this function?
@@ +1194,5 @@
> + NS_WARNING("mSpecList realloc failed.");
> + return;
> + }
> + COMDLG_FILTERSPEC* pSpecForward = (COMDLG_FILTERSPEC*)(((char*)mSpecList)
> + + (size * mLength));
Why don't you cast mSpecList to COMDLG_FILTERSPEC*, and then add mLength to it? It's really the compiler's job to do the pointer arithmetic for you. :-)
@@ +1196,5 @@
> + }
> + COMDLG_FILTERSPEC* pSpecForward = (COMDLG_FILTERSPEC*)(((char*)mSpecList)
> + + (size * mLength));
> + memset(pSpecForward, 0, size);
> + nsString* pStr = mStrings.AppendElement(aTitle);
AppendElement can return null. I think you need to handle that case gracefully here.
::: widget/src/windows/nsFilePicker.h
@@ +160,5 @@
> + ~ComDlgFilterSpec() {
> + free(mSpecList);
> + }
> +
> + PRUint32 Length() {
Make this method const please.
@@ +164,5 @@
> + PRUint32 Length() {
> + return mLength;
> + }
> +
> + const COMDLG_FILTERSPEC* get() {
Same here.
Attachment #580462 -
Flags: review+
Comment 46•13 years ago
|
||
Comment on attachment 580465 [details] [diff] [review]
part5 - cifpn
Review of attachment 580465 [details] [diff] [review]:
-----------------------------------------------------------------
r=me
Attachment #580465 -
Flags: review+
Comment 47•13 years ago
|
||
Comment on attachment 580464 [details] [diff] [review]
part4 - close with parent
Review of attachment 580464 [details] [diff] [review]:
-----------------------------------------------------------------
::: widget/src/windows/nsFilePicker.cpp
@@ +493,5 @@
> + * Close on parent close logic
> + */
> +
> +bool
> +nsFilePicker::ParentDestroyTest(bool aIsXPDialog)
Can you please choose a better name for this function? Like, DestroyParentIfNeeded or something?
@@ +509,5 @@
> + dlgWnd = mDlgWnd;
> + if (IsWindow(dlgWnd) && IsWindowVisible(dlgWnd) && win->DestroyCalled()) {
> + PRUnichar className[64];
> + // Make sure we have the right window
> + if (GetClassNameW(dlgWnd, className, sizeof(className)/sizeof(PRUnichar)) &&
Nit: use mozilla::ArrayLength.
::: widget/src/windows/nsFilePicker.h
@@ +138,5 @@
> + void SetDialogHandle(HWND aWnd);
> + bool ParentDestroyTest(bool aIsXPDialog);
> + static void PickerCallbackTimerFunc(nsITimer *aTimer, void *aPicker);
> + friend UINT_PTR CALLBACK MultiFilePickerHook(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
> + friend UINT_PTR CALLBACK FilePickerHook(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
Hrm, why not just make these static?
@@ +153,5 @@
> nsCOMArray<nsILocalFile> mFiles;
> static char mLastUsedDirectory[];
> nsString mUnicodeFile;
> static PRUnichar *mLastUsedUnicodeDirectory;
> + HWND mDlgWnd;
I think this should also go inside the ifdef below.
@@ +174,5 @@
> const COMDLG_FILTERSPEC* get() {
> return mSpecList;
> }
>
> + bool IsEmpty() {
Make this const please?
::: widget/src/windows/nsWindow.h
@@ +309,5 @@
> // Open file picker tracking
> void PickerOpen();
> void PickerClosed();
>
> + bool DestroyCalled() { return mDestroyCalled; }
Make this const please?
Attachment #580464 -
Flags: review+
Comment 48•13 years ago
|
||
(In reply to Ehsan Akhgari [:ehsan] from comment #47)
> Comment on attachment 580464 [details] [diff] [review]
> part4 - close with parent
>
> Review of attachment 580464 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> ::: widget/src/windows/nsFilePicker.cpp
> @@ +493,5 @@
> > + * Close on parent close logic
> > + */
> > +
> > +bool
> > +nsFilePicker::ParentDestroyTest(bool aIsXPDialog)
>
> Can you please choose a better name for this function? Like,
> DestroyParentIfNeeded or something?
Scratch that, use ClosePickerIfNeeded. :)
Comment 49•13 years ago
|
||
Comment on attachment 580457 [details] [diff] [review]
prelim cleanup v.1
Review of attachment 580457 [details] [diff] [review]:
-----------------------------------------------------------------
::: widget/src/windows/nsFilePicker.cpp
@@ +73,5 @@
> +// Manages matching SuppressBlurEvents calls on the parent widget.
> +class AutoSuppressEvents
> +{
> +public:
> + AutoSuppressEvents(nsIWidget* aWidget) {
Make this explicit please?
@@ +122,5 @@
> +// in picker dialogs. We are responsible for destroying these.
> +class AutoDestroyTmpWindow
> +{
> +public:
> + AutoDestroyTmpWindow(HWND aTmpWnd) :
explicit!
@@ +132,5 @@
> + if (mWnd)
> + DestroyWindow(mWnd);
> + }
> +
> + inline HWND get() { return mWnd; }
const!
@@ +141,5 @@
> +// Manages matching PickerOpen/PickerClosed calls on the parent widget.
> +class AutoWidgetPickerState
> +{
> +public:
> + AutoWidgetPickerState(nsIWidget* aWidget) {
ex!
@@ +150,5 @@
> + ~AutoWidgetPickerState() {
> + PickerState(false);
> + }
> +private:
> + void PickerState(bool aFlag) {
co!
@@ +319,3 @@
> bool result = false;
> +
> + nsAutoArrayPtr<PRUnichar> dirBuffer(new PRUnichar[FILE_BUFFER_SIZE+1]);
You don't need to allocate this dynamically, it's better for it to be on the stack I think.
@@ +324,5 @@
> +
> + AutoDestroyTmpWindow adtw((HWND)(mParentWidget.get() ?
> + mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : NULL));
> +
> + BROWSEINFOW browserInfo;
I would do:
BROWSEINFOW browserInfo = {0};
@@ +379,3 @@
> {
> + OPENFILENAMEW ofn;
> + memset(&ofn, 0, sizeof(ofn));
ofn = {0};
@@ +381,5 @@
> + memset(&ofn, 0, sizeof(ofn));
> + ofn.lStructSize = sizeof(ofn);
> + nsString filterBuffer = mFilterList;
> +
> + nsAutoArrayPtr<PRUnichar> fileBuffer(new PRUnichar[FILE_BUFFER_SIZE+1]);
This can live on the stack as well.
::: widget/src/windows/nsFilePicker.h
@@ +96,5 @@
> + bool ShowFolderPicker(nsString* aInitialDir);
> + void RememberLastUsedDirectory(nsCOMPtr<nsILocalFile>& file);
> + bool IsPrivacyModeEnabled();
> + bool IsDefaultPathLink();
> + bool IsDefaultPathHtml();
Usual const comments apply here. :-)
Attachment #580457 -
Flags: review?(neil) → review+
Comment 50•13 years ago
|
||
Comment on attachment 580457 [details] [diff] [review]
prelim cleanup v.1
>+ AutoSuppressEvents(nsIWidget* aWidget) {
>+ mWidget = aWidget;
: mWidget(aWidget)
>+ nsWindow *win = static_cast<nsWindow *>(mWidget.get());
>+ win->SuppressBlurEvents(aFlag);
>+ }
>+ }
>+ nsCOMPtr<nsIWidget> mWidget;
Annoying. These should be cast to nsWindow somewhere early on.
>+ AutoDestroyTmpWindow(HWND aTmpWnd) :
>+ mWnd(NULL) {
: mWnd(aTmpWnd)
{}
>+ AutoWidgetPickerState(nsIWidget* aWidget) {
>+ mWidget = aWidget;
: mWidget(aWidget)
>+bool
>+nsFilePicker::ShowFolderPicker(nsString* aInitialDir)
> {
>+ if (!aInitialDir)
>+ return false;
Use const nsString& surely?
>+ nsAutoArrayPtr<PRUnichar> dirBuffer(new PRUnichar[FILE_BUFFER_SIZE+1]);
(Oops, FILE_BUFFER_SIZE is 4096. We _really_ don't want to allocate 4097...)
>+void
>+nsFilePicker::RememberLastUsedDirectory(nsCOMPtr<nsILocalFile>& file)
Why not nsILocalFile*?
>+ // InitWithPath() will convert UCS2 to FS path !!! corrupts unicode
[No longer true, of course.]
>+ file->InitWithPath(mUnicodeFile);
Why are you doing this here and not in the caller?
It's unclear that the call changes the file.
Attachment #580457 -
Flags: review-
Comment 51•13 years ago
|
||
Comment on attachment 580462 [details] [diff] [review]
part3 - file picker
>- FILEOPENDIALOGOPTIONS fos = 0;
>- fos |= FOS_PICKFOLDERS;
>+ FILEOPENDIALOGOPTIONS fos = FOS_PICKFOLDERS;
Random cleanup of previous patches???
(Not a problem if you're landing these all in one changeset.)
>+ if (!file || NS_FAILED(file->InitWithPath(nsString(str)))) {
nsDependentString
>+ CoTaskMemFree(str);
>+ continue;
>+ }
>+ mFiles.AppendObject(file);
>+ CoTaskMemFree(str);
Also, why not write this
if (file && NS_SUCCEEDED(file->InitWithPath(nsDependentString(str)))
mFiles.AppendObject(file);
CoTaskMemFree(str);
>+ PRUint32 size = sizeof(COMDLG_FILTERSPEC);
>+ PRUint32 hdrLen = size * (mLength + 1);
>+ mSpecList = (COMDLG_FILTERSPEC*)realloc(mSpecList, hdrLen);
>+ if (!mSpecList) {
>+ NS_WARNING("mSpecList realloc failed.");
>+ return;
>+ }
>+ COMDLG_FILTERSPEC* pSpecForward = (COMDLG_FILTERSPEC*)(((char*)mSpecList)
>+ + (size * mLength));
This looks very much like you're reimplementing an nsTArray...
Comment 52•13 years ago
|
||
The Vista/7 folder and file picker code looks quite similar;
is there any way to share code somehow?
Assignee | ||
Comment 53•13 years ago
|
||
(In reply to neil@parkwaycc.co.uk from comment #52)
> The Vista/7 folder and file picker code looks quite similar;
> is there any way to share code somehow?
Pretty much every step of the way there are variances in what you have to do. To blend them you would need to add a lot of
if (newpickers) {
// do this
} else {
// do that
}
I felt it would add complexity to code that is already pretty crazy to start with, so I kept them separate.
Assignee | ||
Comment 54•13 years ago
|
||
Looking over the rest of the review comments, don't see anything I have any issues with. Will update over the weekend and post a new set on Monday.
Assignee | ||
Comment 55•13 years ago
|
||
(In reply to Ehsan Akhgari [:ehsan] from comment #49)
> Comment on attachment 580457 [details] [diff] [review]
> prelim cleanup v.1
>
> Review of attachment 580457 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> @@ +319,3 @@
> > bool result = false;
> > +
> > + nsAutoArrayPtr<PRUnichar> dirBuffer(new PRUnichar[FILE_BUFFER_SIZE+1]);
>
> You don't need to allocate this dynamically, it's better for it to be on
> the stack I think.
>
One nit - this buffer can be freed in the callbacks and reallocated, which is why we initialize it this way.
Assignee | ||
Comment 56•13 years ago
|
||
comment in the code on the above:
http://mxr.mozilla.org/mozilla-central/source/widget/src/windows/nsFilePicker.cpp#391
Assignee | ||
Comment 57•13 years ago
|
||
(In reply to Ehsan Akhgari [:ehsan] from comment #44)
> Comment on attachment 580461 [details] [diff] [review]
> part2 - folder picker
>
> @@ +474,5 @@
> > + }
> > + }
> > +
> > + AutoDestroyTmpWindow adtw((HWND)(mParentWidget.get() ?
> > + mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : NULL));
>
> I find this not very well readable. Can you please init the variable to
> NULL and then check for the condition on the next line?
Not sure what to do here that's cleaner looking. For example:
HWND hwnd = NULL;
if (mParentWidget.get())
hwnd = mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW);
AutoDestroyTmpWindow adtw(hwnd);
But that doesn't seem as nice as the single line statement I currently have.
> ::: widget/src/windows/nsFilePicker.h
> @@ +145,5 @@
> > nsCOMArray<nsILocalFile> mFiles;
> > static char mLastUsedDirectory[];
> > nsString mUnicodeFile;
> > static PRUnichar *mLastUsedUnicodeDirectory;
> > + DWORD mFDECookie;
>
> Please wrap this in an #ifdef MOZ_WINSDK_TARGETVER >= MOZ_NTDDI_LONGHORN.
This gets updated in one of the patches farther up in the queue.
Assignee | ||
Comment 58•13 years ago
|
||
Attachment #580457 -
Attachment is obsolete: true
Assignee | ||
Comment 59•13 years ago
|
||
resubmitting the first patch for review due to the previous r-.
Attachment #580992 -
Attachment is obsolete: true
Attachment #581003 -
Flags: review?(neil)
Updated•13 years ago
|
Attachment #581003 -
Flags: review?(neil) → review+
Assignee | ||
Comment 60•13 years ago
|
||
Landing this on inbound is on hold until the pgo build problem (bug 709193) gets worked out.
Assignee | ||
Comment 61•13 years ago
|
||
Assignee | ||
Comment 62•13 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/77bcf3671260
https://hg.mozilla.org/mozilla-central/rev/7f5a60c89420
https://hg.mozilla.org/mozilla-central/rev/487e81eb1b6b
https://hg.mozilla.org/mozilla-central/rev/46f1d7608fb4
https://hg.mozilla.org/mozilla-central/rev/df958b75de87
https://hg.mozilla.org/mozilla-central/rev/4f2b48a62b75
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Assignee | ||
Updated•13 years ago
|
status-firefox11:
--- → fixed
Updated•13 years ago
|
Keywords: addon-compat,
dev-doc-needed
Comment 63•13 years ago
|
||
The Vista stuff doesn't compile on the Vista SDK - ShObjIdl.h needs NTDDI_VERSION set to NTDDI_LONGHORN or better, but only MOZ_WINSDK_TARGETVER is set, so we try to compile against interfaces that haven't been defined...
Also the Vista SDK doesn't define FILEOPENDIALOGOPTIONS; newer SDKs typedef it as equivalent to DWORD.
And you don't seem to have spelled Shell correctly in one of the patches.
Assignee | ||
Comment 64•13 years ago
|
||
(In reply to neil@parkwaycc.co.uk from comment #63)
> The Vista stuff doesn't compile on the Vista SDK - ShObjIdl.h needs
> NTDDI_VERSION set to NTDDI_LONGHORN or better, but only MOZ_WINSDK_TARGETVER
> is set, so we try to compile against interfaces that haven't been defined...
>
> Also the Vista SDK doesn't define FILEOPENDIALOGOPTIONS; newer SDKs typedef
> it as equivalent to DWORD.
>
> And you don't seem to have spelled Shell correctly in one of the patches.
filed bug 711073.
Comment 65•13 years ago
|
||
Aha, it's because the Vista SDK doesn't define _WIN32_WINNT_VISTA...
Assignee | ||
Comment 66•13 years ago
|
||
Minor fix for the vista & up code path, I reintroduced bug 665987. I went ahead and moved this down with the single file truncate call, which seemed better.
Attachment #582105 -
Flags: review?(netzen)
Reporter | ||
Comment 67•13 years ago
|
||
Comment on attachment 582105 [details] [diff] [review]
clear mFiles
Looks good!
Attachment #582105 -
Flags: review?(netzen) → review+
Assignee | ||
Comment 68•13 years ago
|
||
(In reply to Brian R. Bondy [:bbondy] from comment #67)
> Comment on attachment 582105 [details] [diff] [review]
> clear mFiles
>
> Looks good!
https://hg.mozilla.org/integration/mozilla-inbound/rev/7c4be303da94
Comment 69•13 years ago
|
||
Target Milestone: --- → mozilla11
Comment 70•13 years ago
|
||
We've now uplifted bug 712571 and bug 715129 to Aurora, both regressions from this bug. I'm adding the qawanted keyword here to do some exploratory testing around the file picker, and try to find any other regressions while 11 is still on Aurora.
Keywords: qawanted
Comment 71•13 years ago
|
||
Dialog windows begun to not open for me since 12.15.2011 Nightly update.
OS: Win 7
Assignee | ||
Comment 72•13 years ago
|
||
(In reply to grebensown from comment #71)
> Dialog windows begun to not open for me since 12.15.2011 Nightly update.
> OS: Win 7
Can you post steps to reproduce?
Reporter | ||
Comment 73•13 years ago
|
||
Maybe we could fall back to the old dialog on error since we need to have that other code working anyway for the XP case? (I'd prefer to try to find out what the issue is here though for grebensown@hotmail.com first).
By the way it works great for me, thanks for doing this :D
Assignee | ||
Comment 74•13 years ago
|
||
(In reply to Brian R. Bondy [:bbondy] from comment #73)
> Maybe we could fall back to the old dialog on error since we need to have
> that other code working anyway for the XP case? (I'd prefer to try to find
> out what the issue is here though for grebensown@hotmail.com first).
I'm not going to fall back since at some point we want the old code to go away.
My best guess on grebensown's problem is that it might be caused by an invalid path passed as a parameter, and the newer dialogs react to this differently. bug 717835 been filed on this, hopefully it will get fleshed out. Whatever the cause is it doesn't appear to be a common problem.
>
> By the way it works great for me, thanks for doing this :D
thx!
Reporter | ||
Comment 75•13 years ago
|
||
> I'm not going to fall back since at some point we want the old code to go away.
I thought maybe only temporarily, you could get telemetry data to see the number of times opened vs the number of times failed to open so you don't lose visibility you get from bug reports. But I think you're right this probably isn't worth it and its better to just fix anything that comes up.
Comment 76•13 years ago
|
||
I think this change might have regressed Bug 718752 too.
Comment 77•13 years ago
|
||
QA Verified on:
Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20100101 Firefox/11.0
Comment 78•13 years ago
|
||
This doesn't appear to involve any API changes, correct? It's just the underlying code using a new API to present the file pickers?
Comment 79•13 years ago
|
||
(In reply to Eric Shepherd [:sheppy] from comment #78)
> This doesn't appear to involve any API changes, correct? It's just the
> underlying code using a new API to present the file pickers?
Exact. I'm not sure why "addon-compat" has been set also.
Keywords: dev-doc-needed
You need to log in
before you can comment on or make changes to this bug.
Description
•