Bug 202894 - [GTK][WebInspector] Support for saving data
Summary: [GTK][WebInspector] Support for saving data
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Philippe Normand
URL:
Keywords:
Depends on:
Blocks: 204618
  Show dependency treegraph
 
Reported: 2019-10-13 08:26 PDT by Philippe Normand
Modified: 2019-11-26 06:54 PST (History)
3 users (show)

See Also:


Attachments
Patch (3.94 KB, patch)
2019-10-13 08:29 PDT, Philippe Normand
cgarcia: review+
cgarcia: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Normand 2019-10-13 08:26:30 PDT
Implementation of WebInspectorProxy::platformSave() is missing.
Comment 1 Philippe Normand 2019-10-13 08:29:54 PDT
Created attachment 380843 [details]
Patch
Comment 2 Carlos Garcia Campos 2019-10-14 00:41:13 PDT
Comment on attachment 380843 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=380843&action=review

> Source/WebKit/UIProcess/gtk/WebInspectorProxyGtk.cpp:467
> +        GTK_WINDOW(gtk_widget_get_toplevel(m_inspectorView)), GTK_FILE_CHOOSER_ACTION_SAVE, "Save", "Cancel"));

You need to check the toplevel before using it, you can use WebCore::widgetIsOnscreenToplevelWindow(toplevel) and pass nullptr if it returns false.

> Source/WebKit/UIProcess/gtk/WebInspectorProxyGtk.cpp:470
> +    gtk_file_chooser_set_do_overwrite_confirmation(chooser, true);

TRUE

> Source/WebKit/UIProcess/gtk/WebInspectorProxyGtk.cpp:471
> +    gtk_file_chooser_set_current_name(chooser, suggestedURL.utf8().data());

This expects a name not a URL.

> Source/WebKit/UIProcess/gtk/WebInspectorProxyGtk.cpp:479
> +            if (!base64Decode(content, out, Base64ValidatePadding))

Do we want to decode UTF-16 here?

> Source/WebKit/UIProcess/gtk/WebInspectorProxyGtk.cpp:486
> +            data = content.utf8().data();

We are saving UTF-8 here.
Comment 3 Philippe Normand 2019-10-14 01:53:47 PDT
Comment on attachment 380843 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=380843&action=review

>> Source/WebKit/UIProcess/gtk/WebInspectorProxyGtk.cpp:471
>> +    gtk_file_chooser_set_current_name(chooser, suggestedURL.utf8().data());
> 
> This expects a name not a URL.

Actually the argument is not an URL, it's a filename. I'll rename it.
Comment 4 Adrian Perez 2019-10-14 02:01:14 PDT
Comment on attachment 380843 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=380843&action=review

> Source/WebKit/UIProcess/gtk/WebInspectorProxyGtk.cpp:487
> +            dataLength = strlen(data);

You could use “content.utf8().length()” here instead which is O(1), and avoid
the call to strlen() which is O(n).
Comment 5 Philippe Normand 2019-10-14 02:21:22 PDT
Committed r251069: <https://trac.webkit.org/changeset/251069>
Comment 6 Philippe Normand 2019-10-14 02:21:48 PDT
(In reply to Adrian Perez from comment #4)
> Comment on attachment 380843 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=380843&action=review
> 
> > Source/WebKit/UIProcess/gtk/WebInspectorProxyGtk.cpp:487
> > +            dataLength = strlen(data);
> 
> You could use “content.utf8().length()” here instead which is O(1), and avoid
> the call to strlen() which is O(n).

Indeed, good tip :P