[GTK][WPE] Allow to run script dialogs asynchronously in the UI process
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2018 08:24:17 +0000 (08:24 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2018 08:24:17 +0000 (08:24 +0000)
commit0d501fa3dbd43e3921dac21272beaf71b81641f2
tree84aa4a29c2d15f10c332d203d28b5f52302e160e
parentb082f92e8116a1959cfce617dd195e2a8f4acf86
[GTK][WPE] Allow to run script dialogs asynchronously in the UI process
https://bugs.webkit.org/show_bug.cgi?id=189544

Reviewed by Michael Catanzaro.

Source/WebKit:

Script dialogs are sync in the WebProcess, but we don't need to block the UI process while they are running. Our
current API doesn't allow it, because it always expects the dialog to be closed in the signal handler. API
changes are backwards compatible.

* UIProcess/API/glib/WebKitScriptDialog.cpp:
(webkitScriptDialogCreate): Added to heap allocate a WebKitScriptDialog.
(webkitScriptDialogIsRunning): Common implementation here, a script dialog is considered to be running if it has
a competion handler pending.
(webkit_script_dialog_ref): WebKitScriptDialog is now refcounted.
(webkit_script_dialog_unref): Ditto.
(webkit_script_dialog_close): New method to notify that we are done with the dialog.
* UIProcess/API/glib/WebKitScriptDialogPrivate.h:
(_WebKitScriptDialog::_WebKitScriptDialog): Use a single constructor and keep the completion handler.
* UIProcess/API/glib/WebKitUIClient.cpp: Do not call the completion handler, pass it to the web view.
* UIProcess/API/glib/WebKitWebView.cpp:
(webkitWebViewDispose): Close the current script dialog if there's any.
(webkit_web_view_class_init): Document how to handle dialogs asynchronously.
(webkitWebViewRunJavaScriptAlert): Do not stack allocate the WebKitScriptDialog, create it with
webkitScriptDialogCreate() passing the completion handler.
(webkitWebViewRunJavaScriptConfirm): Ditto.
(webkitWebViewRunJavaScriptPrompt): Ditto.
(webkitWebViewRunJavaScriptBeforeUnloadConfirm): Ditto.
* UIProcess/API/glib/WebKitWebViewPrivate.h:
* UIProcess/API/gtk/WebKitScriptDialog.h:
* UIProcess/API/gtk/WebKitScriptDialogGtk.cpp:
(scriptDialogResponseCallback): Hnadle the response callback.
(webkitScriptDialogRun): Do not use gtk_dialog_run(), connect to response signal and show the dialogs instead.
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
* UIProcess/API/gtk/docs/webkit2gtk-docs.sgml:
* UIProcess/API/wpe/WebKitScriptDialogWPE.cpp:

Tools:

Add test cases for the new API.

* TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp:
(testWebViewJavaScriptDialogs):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235969 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/glib/WebKitScriptDialog.cpp
Source/WebKit/UIProcess/API/glib/WebKitScriptDialogPrivate.h
Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp
Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h
Source/WebKit/UIProcess/API/gtk/WebKitScriptDialog.h
Source/WebKit/UIProcess/API/gtk/WebKitScriptDialogGtk.cpp
Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt
Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
Source/WebKit/UIProcess/API/wpe/WebKitScriptDialog.h
Source/WebKit/UIProcess/API/wpe/WebKitScriptDialogWPE.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp