WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
112339
[WK2] Add C API to copy selected files from WebOpenPanelParameters.
https://bugs.webkit.org/show_bug.cgi?id=112339
Summary
[WK2] Add C API to copy selected files from WebOpenPanelParameters.
Michael Brüning
Reported
2013-03-14 03:42:47 PDT
[WK2] Add C API to copy selected files from WebOpenPanelParameters.
Attachments
Patch
(4.46 KB, patch)
2013-03-14 03:51 PDT
,
Michael Brüning
no flags
Details
Formatted Diff
Diff
Patch
(5.76 KB, patch)
2013-03-20 01:39 PDT
,
Michael Brüning
no flags
Details
Formatted Diff
Diff
Patch
(7.66 KB, patch)
2013-03-20 04:17 PDT
,
Michael Brüning
no flags
Details
Formatted Diff
Diff
Patch
(7.62 KB, patch)
2013-03-20 04:54 PDT
,
Michael Brüning
kling
: review+
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Michael Brüning
Comment 1
2013-03-14 03:51:18 PDT
Created
attachment 193103
[details]
Patch
Michael Brüning
Comment 2
2013-03-14 03:54:29 PDT
Anders, I cc'ed you as you have reviewed the patch that added the API for copying the accepted mime types. Could you please have a look?
Jocelyn Turcotte
Comment 3
2013-03-19 07:25:38 PDT
Comment on
attachment 193103
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=193103&action=review
> Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp:60 > +WKArrayRef WKOpenPanelParametersCopySelectedFileNames(WKOpenPanelParametersRef parametersRef)
This needs to be implemented in WebOpenPanelParameters, the API should just forward the call. This will however ask us to adjust the GTK code to use the C API as well.
> Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp:29 > #include <WKAPICast.h>
I think that you removed the last toImpl(...) call using this header :)
Michael Brüning
Comment 4
2013-03-20 01:39:26 PDT
Created
attachment 193999
[details]
Patch
Kenneth Rohde Christiansen
Comment 5
2013-03-20 01:44:05 PDT
Comment on
attachment 193999
[details]
Patch LGTM
Jocelyn Turcotte
Comment 6
2013-03-20 03:38:54 PDT
Comment on
attachment 193999
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=193999&action=review
> Source/WebKit2/Shared/WebOpenPanelParameters.h:52 > + PassRefPtr<ImmutableArray> copySelectedFileNames() const;
I can't find any Web* classes with "Copy" in their method names, only in the WK* API layer. I also think that this should replace the existing selectedFileNames() method. The GTK port is the only port left using selectedFileNames(), so we could adjust it to use the RefPtr<ImmutableArray> version, as it already does for acceptMIMETypes.
Michael Brüning
Comment 7
2013-03-20 04:17:48 PDT
Created
attachment 194016
[details]
Patch
WebKit Review Bot
Comment 8
2013-03-20 04:24:31 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See
http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Michael Brüning
Comment 9
2013-03-20 04:54:06 PDT
Created
attachment 194026
[details]
Patch Avoiding deep copy of the String vector.
Carlos Garcia Campos
Comment 10
2013-03-20 05:28:14 PDT
Comment on
attachment 194026
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=194026&action=review
> Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.cpp:349 > - const Vector<String> selectedFileNames = request->priv->parameters->selectedFileNames(); > - size_t numOfFiles = selectedFileNames.size(); > + RefPtr<ImmutableArray> selectedFileNames = request->priv->parameters->selectedFileNames(); > + size_t numOfFiles = selectedFileNames->size();
Why duplicating the vector here? Can we just leave two methods, once that duplicates the array returning an Immutable array and another returning a const reference? The duplication is not needed here since we are already duplicating the array to create a GPtrArray
Michael Brüning
Comment 11
2013-03-20 06:14:44 PDT
(In reply to
comment #10
)
> (From update of
attachment 194026
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=194026&action=review
> > > Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.cpp:349 > > - const Vector<String> selectedFileNames = request->priv->parameters->selectedFileNames(); > > - size_t numOfFiles = selectedFileNames.size(); > > + RefPtr<ImmutableArray> selectedFileNames = request->priv->parameters->selectedFileNames(); > > + size_t numOfFiles = selectedFileNames->size(); > > Why duplicating the vector here? Can we just leave two methods, once that duplicates the array returning an Immutable array and another returning a const reference? The duplication is not needed here since we are already duplicating the array to create a GPtrArray
I understand your concern here, but actually, the amount of duplication with the patch is the same as the one in the current implementation: Currently, selectedFileNames is in fact not returning a const reference, but rather creates a copy of the WebOpenPanelParameters::m_settings.selectedFiles Vector and the Strings in it. The new version returns a reference to a Vector of WebStrings instead of Strings (just as the implementation of acceptMIMETypes does). So with that in mind, I would propose to change the implementation for the sake of consistency with acceptMIMETypes and better integration with the C APIs. I would be very interested hearing in your opinion on this or if you see a better way of solving this and avoiding redundancy in the code.
Carlos Garcia Campos
Comment 12
2013-03-20 06:30:16 PDT
(In reply to
comment #11
)
> (In reply to
comment #10
) > > (From update of
attachment 194026
[details]
[details]) > > View in context:
https://bugs.webkit.org/attachment.cgi?id=194026&action=review
> > > > > Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.cpp:349 > > > - const Vector<String> selectedFileNames = request->priv->parameters->selectedFileNames(); > > > - size_t numOfFiles = selectedFileNames.size(); > > > + RefPtr<ImmutableArray> selectedFileNames = request->priv->parameters->selectedFileNames(); > > > + size_t numOfFiles = selectedFileNames->size(); > > > > Why duplicating the vector here? Can we just leave two methods, once that duplicates the array returning an Immutable array and another returning a const reference? The duplication is not needed here since we are already duplicating the array to create a GPtrArray > > I understand your concern here, but actually, the amount of duplication with the patch is the same as the one in the current implementation: > Currently, selectedFileNames is in fact not returning a const reference, but rather creates a copy of the WebOpenPanelParameters::m_settings.selectedFiles Vector and the Strings in it.
Ah, you are right, it returns a copy of the vector.
> The new version returns a reference to a Vector of WebStrings instead of Strings (just as the implementation of acceptMIMETypes does). > > So with that in mind, I would propose to change the implementation for the sake of consistency with acceptMIMETypes and better integration with the C APIs. > > I would be very interested hearing in your opinion on this or if you see a better way of solving this and avoiding redundancy in the code.
Well, the only way I see to avoid the duplication would be to add a getter to return the WebCore::FileChooserSettings, similar to WebURLRequest/Response do. But that would actually be a different issue, so I'm fine with your patch, sorry for the noise.
Jocelyn Turcotte
Comment 13
2013-03-21 07:30:04 PDT
Comment on
attachment 194026
[details]
Patch The Qt part looks good to me. Anders, may I ask you to look at the WK2 part?
Michael Brüning
Comment 14
2013-04-03 03:03:45 PDT
Benjamin, would you like to have a look?
Michael Brüning
Comment 15
2013-04-09 02:55:59 PDT
Benjamin, Anders, any estimate on when you might be able to look at this?
Andreas Kling
Comment 16
2013-04-09 03:57:42 PDT
Comment on
attachment 194026
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=194026&action=review
r=me
> Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.cpp:358 > + String fileNameString = webFileName->string(); > + if (fileNameString.isEmpty()) > continue;
Do you need the String temporary here? if (webFileName->isEmpty()) continue;
Michael Brüning
Comment 17
2013-04-09 04:04:43 PDT
(In reply to
comment #16
)
> (From update of
attachment 194026
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=194026&action=review
> > r=me > > > Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.cpp:358 > > + String fileNameString = webFileName->string(); > > + if (fileNameString.isEmpty()) > > continue; > > Do you need the String temporary here? > > if (webFileName->isEmpty()) > continue;
Good point, fileNameString is indeed not needed. Will land with this change.
Michael Brüning
Comment 18
2013-04-09 04:12:22 PDT
Committed
r148005
: <
http://trac.webkit.org/changeset/148005
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug