Diff
Modified: trunk/Source/WebCore/platform/gtk/po/ChangeLog (220386 => 220387)
--- trunk/Source/WebCore/platform/gtk/po/ChangeLog 2017-08-08 06:22:02 UTC (rev 220386)
+++ trunk/Source/WebCore/platform/gtk/po/ChangeLog 2017-08-08 06:25:23 UTC (rev 220387)
@@ -1,3 +1,12 @@
+2017-08-07 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [GTK] Implement _javascript_ dialog methods of API::AutomationSessionClient
+ https://bugs.webkit.org/show_bug.cgi?id=175259
+
+ Reviewed by Michael Catanzaro.
+
+ * POTFILES.in: Add WebKitScriptDialogGtk.cpp.
+
2017-07-13 Matthew Hanson <matthew_han...@apple.com>
Fix the cMake builds (GTK and WPE.)
Modified: trunk/Source/WebCore/platform/gtk/po/POTFILES.in (220386 => 220387)
--- trunk/Source/WebCore/platform/gtk/po/POTFILES.in 2017-08-08 06:22:02 UTC (rev 220386)
+++ trunk/Source/WebCore/platform/gtk/po/POTFILES.in 2017-08-08 06:25:23 UTC (rev 220387)
@@ -30,6 +30,7 @@
../../../WebKit/UIProcess/API/gtk/WebKitColorChooserRequest.cpp
../../../WebKit/UIProcess/API/gtk/WebKitPrintCustomWidget.cpp
../../../WebKit/UIProcess/API/gtk/WebKitPrintOperation.cpp
+../../../WebKit/UIProcess/API/gtk/WebKitScriptDialogGtk.cpp
../../../WebKit/UIProcess/API/gtk/WebKitWebInspector.cpp
../../../WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
../../../WebKit/UIProcess/API/gtk/WebKitWebViewGtk.cpp
Modified: trunk/Source/WebKit/ChangeLog (220386 => 220387)
--- trunk/Source/WebKit/ChangeLog 2017-08-08 06:22:02 UTC (rev 220386)
+++ trunk/Source/WebKit/ChangeLog 2017-08-08 06:25:23 UTC (rev 220387)
@@ -1,3 +1,49 @@
+2017-08-07 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [GTK] Implement _javascript_ dialog methods of API::AutomationSessionClient
+ https://bugs.webkit.org/show_bug.cgi?id=175259
+
+ Reviewed by Michael Catanzaro.
+
+ Move the default implementation of WebKitScriptDialog from WebKitWebView platform specific files to their own
+ files. Implement all _javascript_ dialog methods of API::AutomationSessionClient in WebKitAutomationSession. For
+ now it only works when the user doesn't override WebKitWebView::script-dialog signal and default implementation
+ is used.
+
+ * PlatformGTK.cmake: Add new files to compilation.
+ * PlatformWPE.cmake: Ditto.
+ * UIProcess/API/glib/WebKitAutomationSession.cpp:
+ (webkitAutomationSessionCreate): Pass the WebKitWebContext to the constructor and keep a pointer to it in session.
+ * UIProcess/API/glib/WebKitAutomationSessionPrivate.h:
+ * UIProcess/API/glib/WebKitScriptDialogPrivate.h:
+ * UIProcess/API/glib/WebKitWebContext.cpp:
+ * UIProcess/API/glib/WebKitWebView.cpp:
+ (webkitWebViewRunJavaScriptAlert): Set the currently script dialog for the scope of the function.
+ (webkitWebViewRunJavaScriptConfirm): Ditto.
+ (webkitWebViewRunJavaScriptPrompt): Ditto.
+ (webkitWebViewRunJavaScriptBeforeUnloadConfirm): Ditto.
+ (webkitWebViewIsShowingScriptDialog): Ask current dialog if there's one.
+ (webkitWebViewGetCurrentScriptDialogMessage): Ditto.
+ (webkitWebViewSetCurrentScriptDialogUserInput): Ditto.
+ (webkitWebViewAcceptCurrentScriptDialog): Ditto.
+ (webkitWebViewDismissCurrentScriptDialog): Ditto.
+ * UIProcess/API/glib/WebKitWebViewPrivate.h:
+ * UIProcess/API/gtk/WebKitScriptDialogGtk.cpp: Added.
+ (webkitWebViewCreateJavaScriptDialog): Moved from WebKitWebViewGtk.cpp.
+ (webkitScriptDialogRun): Run the dialog, this code is moved from WebKitWebViewGtk.cpp.
+ (webkitScriptDialogIsRunning): Return true if the script dialog has a native dialog running.
+ (webkitScriptDialogAccept): Send Ok or Close response to the native dialog depending on the dialog type.
+ (webkitScriptDialogDismiss): Send Close response to the native dialog.
+ (webkitScriptDialogSetUserInput): Set the given text on the prompt dialog entry.
+ * UIProcess/API/gtk/WebKitWebViewGtk.cpp:
+ (webkitWebViewScriptDialog): Simply call webkitScriptDialogRun() now.
+ * UIProcess/API/wpe/WebKitScriptDialogWPE.cpp: Copied from Source/WebKit/UIProcess/API/glib/WebKitAutomationSessionPrivate.h.
+ (webkitScriptDialogRun):
+ (webkitScriptDialogIsRunning):
+ (webkitScriptDialogAccept):
+ (webkitScriptDialogDismiss):
+ (webkitScriptDialogSetUserInput):
+
2017-08-07 Devin Rousso <drou...@apple.com>
Web Inspector: Preview Canvas path when viewing a recording
Modified: trunk/Source/WebKit/PlatformGTK.cmake (220386 => 220387)
--- trunk/Source/WebKit/PlatformGTK.cmake 2017-08-08 06:22:02 UTC (rev 220386)
+++ trunk/Source/WebKit/PlatformGTK.cmake 2017-08-08 06:25:23 UTC (rev 220387)
@@ -183,6 +183,7 @@
UIProcess/API/gtk/WebKitPrintCustomWidget.cpp
UIProcess/API/gtk/WebKitPrintOperation.cpp
UIProcess/API/gtk/WebKitRemoteInspectorProtocolHandler.cpp
+ UIProcess/API/gtk/WebKitScriptDialogGtk.cpp
UIProcess/API/gtk/WebKitVersion.cpp
UIProcess/API/gtk/WebKitVersion.h.in
UIProcess/API/gtk/WebKitWebInspector.cpp
Modified: trunk/Source/WebKit/PlatformWPE.cmake (220386 => 220387)
--- trunk/Source/WebKit/PlatformWPE.cmake 2017-08-08 06:22:02 UTC (rev 220386)
+++ trunk/Source/WebKit/PlatformWPE.cmake 2017-08-08 06:25:23 UTC (rev 220387)
@@ -190,6 +190,7 @@
UIProcess/API/wpe/CompositingManagerProxy.cpp
UIProcess/API/wpe/PageClientImpl.cpp
UIProcess/API/wpe/ScrollGestureController.cpp
+ UIProcess/API/wpe/WebKitScriptDialogWPE.cpp
UIProcess/API/wpe/WebKitWebViewWPE.cpp
UIProcess/API/wpe/WPEView.cpp
Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitAutomationSession.cpp (220386 => 220387)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitAutomationSession.cpp 2017-08-08 06:22:02 UTC (rev 220386)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitAutomationSession.cpp 2017-08-08 06:25:23 UTC (rev 220387)
@@ -23,6 +23,7 @@
#include "APIAutomationSessionClient.h"
#include "WebKitApplicationInfo.h"
#include "WebKitAutomationSessionPrivate.h"
+#include "WebKitWebContextPrivate.h"
#include "WebKitWebViewPrivate.h"
#include <glib/gi18n-lib.h>
#include <wtf/glib/WTFGType.h>
@@ -60,6 +61,7 @@
struct _WebKitAutomationSessionPrivate {
RefPtr<WebAutomationSession> session;
WebKitApplicationInfo* applicationInfo;
+ WebKitWebContext* webContext;
CString id;
};
@@ -90,6 +92,46 @@
return &webkitWebViewGetPage(webView);
}
+ bool isShowingJavaScriptDialogOnPage(WebAutomationSession&, WebPageProxy& page) override
+ {
+ auto* webView = webkitWebContextGetWebViewForPage(m_session->priv->webContext, &page);
+ if (!webView)
+ return false;
+ return webkitWebViewIsShowingScriptDialog(webView);
+ }
+
+ void dismissCurrentJavaScriptDialogOnPage(WebAutomationSession&, WebPageProxy& page) override
+ {
+ auto* webView = webkitWebContextGetWebViewForPage(m_session->priv->webContext, &page);
+ if (!webView)
+ return;
+ webkitWebViewDismissCurrentScriptDialog(webView);
+ }
+
+ void acceptCurrentJavaScriptDialogOnPage(WebAutomationSession&, WebPageProxy& page) override
+ {
+ auto* webView = webkitWebContextGetWebViewForPage(m_session->priv->webContext, &page);
+ if (!webView)
+ return;
+ webkitWebViewAcceptCurrentScriptDialog(webView);
+ }
+
+ String messageOfCurrentJavaScriptDialogOnPage(WebAutomationSession&, WebPageProxy& page) override
+ {
+ auto* webView = webkitWebContextGetWebViewForPage(m_session->priv->webContext, &page);
+ if (!webView)
+ return { };
+ return webkitWebViewGetCurrentScriptDialogMessage(webView);
+ }
+
+ void setUserInputForCurrentJavaScriptPromptOnPage(WebAutomationSession&, WebPageProxy& page, const String& userInput) override
+ {
+ auto* webView = webkitWebContextGetWebViewForPage(m_session->priv->webContext, &page);
+ if (!webView)
+ return;
+ webkitWebViewSetCurrentScriptDialogUserInput(webView, userInput);
+ }
+
WebKitAutomationSession* m_session;
};
@@ -192,9 +234,11 @@
G_TYPE_NONE);
}
-WebKitAutomationSession* webkitAutomationSessionCreate(const char* sessionID)
+WebKitAutomationSession* webkitAutomationSessionCreate(WebKitWebContext* webContext, const char* sessionID)
{
- return WEBKIT_AUTOMATION_SESSION(g_object_new(WEBKIT_TYPE_AUTOMATION_SESSION, "id", sessionID, nullptr));
+ auto* session = WEBKIT_AUTOMATION_SESSION(g_object_new(WEBKIT_TYPE_AUTOMATION_SESSION, "id", sessionID, nullptr));
+ session->priv->webContext = webContext;
+ return session;
}
WebAutomationSession& webkitAutomationSessionGetSession(WebKitAutomationSession* session)
Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitAutomationSessionPrivate.h (220386 => 220387)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitAutomationSessionPrivate.h 2017-08-08 06:22:02 UTC (rev 220386)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitAutomationSessionPrivate.h 2017-08-08 06:25:23 UTC (rev 220387)
@@ -21,8 +21,9 @@
#include "WebAutomationSession.h"
#include "WebKitAutomationSession.h"
+#include "WebKitWebContext.h"
-WebKitAutomationSession* webkitAutomationSessionCreate(const char* sessionID);
+WebKitAutomationSession* webkitAutomationSessionCreate(WebKitWebContext*, const char* sessionID);
WebKit::WebAutomationSession& webkitAutomationSessionGetSession(WebKitAutomationSession*);
String webkitAutomationSessionGetBrowserName(WebKitAutomationSession*);
String webkitAutomationSessionGetBrowserVersion(WebKitAutomationSession*);
Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitScriptDialogPrivate.h (220386 => 220387)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitScriptDialogPrivate.h 2017-08-08 06:22:02 UTC (rev 220386)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitScriptDialogPrivate.h 2017-08-08 06:25:23 UTC (rev 220387)
@@ -17,11 +17,12 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef WebKitScriptDialogPrivate_h
-#define WebKitScriptDialogPrivate_h
+#pragma once
#include "WebKitScriptDialog.h"
+#include "WebKitWebView.h"
#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
struct _WebKitScriptDialog {
_WebKitScriptDialog(unsigned type, const CString& message)
@@ -55,6 +56,14 @@
bool confirmed;
CString text;
+
+#if PLATFORM(GTK)
+ GtkWidget* nativeDialog { nullptr };
+#endif
};
-#endif // WebKitScriptDialogPrivate_h
+void webkitScriptDialogRun(WebKitScriptDialog*, WebKitWebView*);
+bool webkitScriptDialogIsRunning(WebKitScriptDialog*);
+void webkitScriptDialogAccept(WebKitScriptDialog*);
+void webkitScriptDialogDismiss(WebKitScriptDialog*);
+void webkitScriptDialogSetUserInput(WebKitScriptDialog*, const String&);
Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp (220386 => 220387)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp 2017-08-08 06:22:02 UTC (rev 220386)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitWebContext.cpp 2017-08-08 06:25:23 UTC (rev 220387)
@@ -233,7 +233,7 @@
void requestAutomationSession(const String& sessionIdentifier) override
{
ASSERT(!m_webContext->priv->automationSession);
- m_webContext->priv->automationSession = adoptGRef(webkitAutomationSessionCreate(sessionIdentifier.utf8().data()));
+ m_webContext->priv->automationSession = adoptGRef(webkitAutomationSessionCreate(m_webContext, sessionIdentifier.utf8().data()));
g_signal_emit(m_webContext, signals[AUTOMATION_STARTED], 0, m_webContext->priv->automationSession.get());
m_webContext->priv->processPool->setAutomationSession(&webkitAutomationSessionGetSession(m_webContext->priv->automationSession.get()));
}
Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp (220386 => 220387)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp 2017-08-08 06:22:02 UTC (rev 220386)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp 2017-08-08 06:25:23 UTC (rev 220387)
@@ -66,6 +66,7 @@
#include <WebCore/JSDOMExceptionHandling.h>
#include <WebCore/RefPtrCairo.h>
#include <glib/gi18n-lib.h>
+#include <wtf/SetForScope.h>
#include <wtf/glib/GRefPtr.h>
#include <wtf/glib/WTFGType.h>
#include <wtf/text/CString.h>
@@ -219,6 +220,8 @@
GRefPtr<WebKitWebResource> mainResource;
LoadingResourcesMap loadingResourcesMap;
+ WebKitScriptDialog* currentScriptDialog;
+
#if PLATFORM(GTK)
GRefPtr<WebKitWebInspector> inspector;
#endif
@@ -2008,6 +2011,7 @@
void webkitWebViewRunJavaScriptAlert(WebKitWebView* webView, const CString& message)
{
WebKitScriptDialog dialog(WEBKIT_SCRIPT_DIALOG_ALERT, message);
+ SetForScope<WebKitScriptDialog*> change(webView->priv->currentScriptDialog, &dialog);
gboolean returnValue;
g_signal_emit(webView, signals[SCRIPT_DIALOG], 0, &dialog, &returnValue);
}
@@ -2015,6 +2019,7 @@
bool webkitWebViewRunJavaScriptConfirm(WebKitWebView* webView, const CString& message)
{
WebKitScriptDialog dialog(WEBKIT_SCRIPT_DIALOG_CONFIRM, message);
+ SetForScope<WebKitScriptDialog*> change(webView->priv->currentScriptDialog, &dialog);
gboolean returnValue;
g_signal_emit(webView, signals[SCRIPT_DIALOG], 0, &dialog, &returnValue);
return dialog.confirmed;
@@ -2023,6 +2028,7 @@
CString webkitWebViewRunJavaScriptPrompt(WebKitWebView* webView, const CString& message, const CString& defaultText)
{
WebKitScriptDialog dialog(WEBKIT_SCRIPT_DIALOG_PROMPT, message, defaultText);
+ SetForScope<WebKitScriptDialog*> change(webView->priv->currentScriptDialog, &dialog);
gboolean returnValue;
g_signal_emit(webView, signals[SCRIPT_DIALOG], 0, &dialog, &returnValue);
return dialog.text;
@@ -2031,11 +2037,59 @@
bool webkitWebViewRunJavaScriptBeforeUnloadConfirm(WebKitWebView* webView, const CString& message)
{
WebKitScriptDialog dialog(WEBKIT_SCRIPT_DIALOG_BEFORE_UNLOAD_CONFIRM, message);
+ SetForScope<WebKitScriptDialog*> change(webView->priv->currentScriptDialog, &dialog);
gboolean returnValue;
g_signal_emit(webView, signals[SCRIPT_DIALOG], 0, &dialog, &returnValue);
return dialog.confirmed;
}
+bool webkitWebViewIsShowingScriptDialog(WebKitWebView* webView)
+{
+ if (!webView->priv->currentScriptDialog)
+ return false;
+
+ // FIXME: Add API to ask the user in case default implementation is not being used.
+ return webkitScriptDialogIsRunning(webView->priv->currentScriptDialog);
+}
+
+String webkitWebViewGetCurrentScriptDialogMessage(WebKitWebView* webView)
+{
+ if (!webView->priv->currentScriptDialog)
+ return { };
+
+ return String::fromUTF8(webView->priv->currentScriptDialog->message);
+}
+
+void webkitWebViewSetCurrentScriptDialogUserInput(WebKitWebView* webView, const String& userInput)
+{
+ if (!webView->priv->currentScriptDialog)
+ return;
+
+ // FIXME: Add API to ask the user in case default implementation is not being used.
+ if (webkitScriptDialogIsRunning(webView->priv->currentScriptDialog))
+ webkitScriptDialogSetUserInput(webView->priv->currentScriptDialog, userInput);
+}
+
+void webkitWebViewAcceptCurrentScriptDialog(WebKitWebView* webView)
+{
+ if (!webView->priv->currentScriptDialog)
+ return;
+
+ // FIXME: Add API to ask the user in case default implementation is not being used.
+ if (webkitScriptDialogIsRunning(webView->priv->currentScriptDialog))
+ webkitScriptDialogAccept(webView->priv->currentScriptDialog);
+}
+
+void webkitWebViewDismissCurrentScriptDialog(WebKitWebView* webView)
+{
+ if (!webView->priv->currentScriptDialog)
+ return;
+
+ // FIXME: Add API to ask the user in case default implementation is not being used.
+ if (webkitScriptDialogIsRunning(webView->priv->currentScriptDialog))
+ webkitScriptDialogDismiss(webView->priv->currentScriptDialog);
+}
+
void webkitWebViewMakePolicyDecision(WebKitWebView* webView, WebKitPolicyDecisionType type, WebKitPolicyDecision* decision)
{
gboolean returnValue;
Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h (220386 => 220387)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h 2017-08-08 06:22:02 UTC (rev 220386)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h 2017-08-08 06:25:23 UTC (rev 220387)
@@ -53,6 +53,12 @@
bool webkitWebViewRunJavaScriptConfirm(WebKitWebView*, const CString& message);
CString webkitWebViewRunJavaScriptPrompt(WebKitWebView*, const CString& message, const CString& defaultText);
bool webkitWebViewRunJavaScriptBeforeUnloadConfirm(WebKitWebView*, const CString& message);
+bool webkitWebViewIsShowingScriptDialog(WebKitWebView*);
+bool webkitWebViewIsScriptDialogRunning(WebKitWebView*, WebKitScriptDialog*);
+String webkitWebViewGetCurrentScriptDialogMessage(WebKitWebView*);
+void webkitWebViewSetCurrentScriptDialogUserInput(WebKitWebView*, const String&);
+void webkitWebViewAcceptCurrentScriptDialog(WebKitWebView*);
+void webkitWebViewDismissCurrentScriptDialog(WebKitWebView*);
void webkitWebViewMakePermissionRequest(WebKitWebView*, WebKitPermissionRequest*);
void webkitWebViewMakePolicyDecision(WebKitWebView*, WebKitPolicyDecisionType, WebKitPolicyDecision*);
void webkitWebViewMouseTargetChanged(WebKitWebView*, const WebKit::WebHitTestResultData&, WebKit::WebEvent::Modifiers);
Added: trunk/Source/WebKit/UIProcess/API/gtk/WebKitScriptDialogGtk.cpp (0 => 220387)
--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitScriptDialogGtk.cpp (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitScriptDialogGtk.cpp 2017-08-08 06:25:23 UTC (rev 220387)
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitScriptDialog.h"
+
+#include "WebKitScriptDialogPrivate.h"
+#include "WebKitWebViewPrivate.h"
+#include <WebCore/GtkUtilities.h>
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+#include <wtf/glib/GUniquePtr.h>
+
+static GtkWidget* webkitWebViewCreateJavaScriptDialog(WebKitWebView* webView, GtkMessageType type, GtkButtonsType buttons, int defaultResponse, const char* primaryText, const char* secondaryText = nullptr)
+{
+ GtkWidget* parent = gtk_widget_get_toplevel(GTK_WIDGET(webView));
+ GtkWidget* dialog = gtk_message_dialog_new(WebCore::widgetIsOnscreenToplevelWindow(parent) ? GTK_WINDOW(parent) : nullptr,
+ GTK_DIALOG_DESTROY_WITH_PARENT, type, buttons, "%s", primaryText);
+ if (secondaryText)
+ gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s", secondaryText);
+ GUniquePtr<char> title(g_strdup_printf("_javascript_ - %s", webkitWebViewGetPage(webView).pageLoadState().url().utf8().data()));
+ gtk_window_set_title(GTK_WINDOW(dialog), title.get());
+ if (buttons != GTK_BUTTONS_NONE)
+ gtk_dialog_set_default_response(GTK_DIALOG(dialog), defaultResponse);
+
+ return dialog;
+}
+
+void webkitScriptDialogRun(WebKitScriptDialog* scriptDialog, WebKitWebView* webView)
+{
+ GtkWidget* dialog = nullptr;
+
+ switch (scriptDialog->type) {
+ case WEBKIT_SCRIPT_DIALOG_ALERT:
+ dialog = webkitWebViewCreateJavaScriptDialog(webView, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, GTK_RESPONSE_CLOSE, scriptDialog->message.data());
+ scriptDialog->nativeDialog = dialog;
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ break;
+ case WEBKIT_SCRIPT_DIALOG_CONFIRM:
+ dialog = webkitWebViewCreateJavaScriptDialog(webView, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, GTK_RESPONSE_OK, scriptDialog->message.data());
+ scriptDialog->nativeDialog = dialog;
+ scriptDialog->confirmed = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK;
+ break;
+ case WEBKIT_SCRIPT_DIALOG_PROMPT: {
+ dialog = webkitWebViewCreateJavaScriptDialog(webView, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, GTK_RESPONSE_OK, scriptDialog->message.data());
+ scriptDialog->nativeDialog = dialog;
+ GtkWidget* entry = gtk_entry_new();
+ gtk_entry_set_text(GTK_ENTRY(entry), scriptDialog->defaultText.data());
+ gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), entry);
+ gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
+ gtk_widget_show(entry);
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
+ scriptDialog->text = gtk_entry_get_text(GTK_ENTRY(entry));
+ break;
+ }
+ case WEBKIT_SCRIPT_DIALOG_BEFORE_UNLOAD_CONFIRM:
+ dialog = webkitWebViewCreateJavaScriptDialog(webView, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, GTK_RESPONSE_OK,
+ _("Are you sure you want to leave this page?"), scriptDialog->message.data());
+ scriptDialog->nativeDialog = dialog;
+ gtk_dialog_add_buttons(GTK_DIALOG(dialog), _("Stay on Page"), GTK_RESPONSE_CLOSE, _("Leave Page"), GTK_RESPONSE_OK, nullptr);
+ gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
+ scriptDialog->confirmed = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK;
+ break;
+ }
+
+ gtk_widget_destroy(dialog);
+ scriptDialog->nativeDialog = nullptr;
+}
+
+bool webkitScriptDialogIsRunning(WebKitScriptDialog* scriptDialog)
+{
+ return !!scriptDialog->nativeDialog;
+}
+
+void webkitScriptDialogAccept(WebKitScriptDialog* scriptDialog)
+{
+ int response = 0;
+ switch (scriptDialog->type) {
+ case WEBKIT_SCRIPT_DIALOG_ALERT:
+ response = GTK_RESPONSE_CLOSE;
+ break;
+ case WEBKIT_SCRIPT_DIALOG_CONFIRM:
+ case WEBKIT_SCRIPT_DIALOG_PROMPT:
+ case WEBKIT_SCRIPT_DIALOG_BEFORE_UNLOAD_CONFIRM:
+ response = GTK_RESPONSE_OK;
+ break;
+ }
+ ASSERT(scriptDialog->nativeDialog);
+ gtk_dialog_response(GTK_DIALOG(scriptDialog->nativeDialog), response);
+}
+
+void webkitScriptDialogDismiss(WebKitScriptDialog* scriptDialog)
+{
+ ASSERT(scriptDialog->nativeDialog);
+ gtk_dialog_response(GTK_DIALOG(scriptDialog->nativeDialog), GTK_RESPONSE_CLOSE);
+}
+
+void webkitScriptDialogSetUserInput(WebKitScriptDialog* scriptDialog, const String& userInput)
+{
+ if (scriptDialog->type != WEBKIT_SCRIPT_DIALOG_PROMPT)
+ return;
+
+ ASSERT(scriptDialog->nativeDialog);
+ GtkWidget* dialogContentArea = gtk_dialog_get_content_area(GTK_DIALOG(scriptDialog->nativeDialog));
+ GUniquePtr<GList> children(gtk_container_get_children(GTK_CONTAINER(dialogContentArea)));
+ for (GList* child = children.get(); child; child = g_list_next(child)) {
+ GtkWidget* childWidget = GTK_WIDGET(child->data);
+ if (GTK_IS_ENTRY(childWidget)) {
+ gtk_entry_set_text(GTK_ENTRY(childWidget), userInput.utf8().data());
+ break;
+ }
+ }
+}
Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewGtk.cpp (220386 => 220387)
--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewGtk.cpp 2017-08-08 06:22:02 UTC (rev 220386)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewGtk.cpp 2017-08-08 06:25:23 UTC (rev 220387)
@@ -36,56 +36,9 @@
return TRUE;
}
-static GtkWidget* webkitWebViewCreateJavaScriptDialog(WebKitWebView* webView, GtkMessageType type, GtkButtonsType buttons, int defaultResponse, const char* primaryText, const char* secondaryText = nullptr)
-{
- GtkWidget* parent = gtk_widget_get_toplevel(GTK_WIDGET(webView));
- GtkWidget* dialog = gtk_message_dialog_new(WebCore::widgetIsOnscreenToplevelWindow(parent) ? GTK_WINDOW(parent) : nullptr,
- GTK_DIALOG_DESTROY_WITH_PARENT, type, buttons, "%s", primaryText);
- if (secondaryText)
- gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), "%s", secondaryText);
- GUniquePtr<char> title(g_strdup_printf("_javascript_ - %s", webkitWebViewGetPage(webView).pageLoadState().url().utf8().data()));
- gtk_window_set_title(GTK_WINDOW(dialog), title.get());
- if (buttons != GTK_BUTTONS_NONE)
- gtk_dialog_set_default_response(GTK_DIALOG(dialog), defaultResponse);
-
- return dialog;
-}
-
gboolean webkitWebViewScriptDialog(WebKitWebView* webView, WebKitScriptDialog* scriptDialog)
{
- GtkWidget* dialog = 0;
-
- switch (scriptDialog->type) {
- case WEBKIT_SCRIPT_DIALOG_ALERT:
- dialog = webkitWebViewCreateJavaScriptDialog(webView, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, GTK_RESPONSE_CLOSE, scriptDialog->message.data());
- gtk_dialog_run(GTK_DIALOG(dialog));
- break;
- case WEBKIT_SCRIPT_DIALOG_CONFIRM:
- dialog = webkitWebViewCreateJavaScriptDialog(webView, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, GTK_RESPONSE_OK, scriptDialog->message.data());
- scriptDialog->confirmed = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK;
- break;
- case WEBKIT_SCRIPT_DIALOG_PROMPT: {
- dialog = webkitWebViewCreateJavaScriptDialog(webView, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, GTK_RESPONSE_OK, scriptDialog->message.data());
- GtkWidget* entry = gtk_entry_new();
- gtk_entry_set_text(GTK_ENTRY(entry), scriptDialog->defaultText.data());
- gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), entry);
- gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
- gtk_widget_show(entry);
- if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
- scriptDialog->text = gtk_entry_get_text(GTK_ENTRY(entry));
- break;
- }
- case WEBKIT_SCRIPT_DIALOG_BEFORE_UNLOAD_CONFIRM:
- dialog = webkitWebViewCreateJavaScriptDialog(webView, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, GTK_RESPONSE_OK,
- _("Are you sure you want to leave this page?"), scriptDialog->message.data());
- gtk_dialog_add_buttons(GTK_DIALOG(dialog), _("Stay on Page"), GTK_RESPONSE_CLOSE, _("Leave Page"), GTK_RESPONSE_OK, nullptr);
- gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
- scriptDialog->confirmed = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK;
- break;
- }
-
- gtk_widget_destroy(dialog);
-
+ webkitScriptDialogRun(scriptDialog, webView);
return TRUE;
}
Copied: trunk/Source/WebKit/UIProcess/API/wpe/WebKitScriptDialogWPE.cpp (from rev 220386, trunk/Source/WebKit/UIProcess/API/glib/WebKitAutomationSessionPrivate.h) (0 => 220387)
--- trunk/Source/WebKit/UIProcess/API/wpe/WebKitScriptDialogWPE.cpp (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/wpe/WebKitScriptDialogWPE.cpp 2017-08-08 06:25:23 UTC (rev 220387)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitScriptDialog.h"
+
+#include "WebKitScriptDialogPrivate.h"
+
+void webkitScriptDialogRun(WebKitScriptDialog*, WebKitWebView*)
+{
+}
+
+bool webkitScriptDialogIsRunning(WebKitScriptDialog*)
+{
+ return false;
+}
+
+void webkitScriptDialogAccept(WebKitScriptDialog*)
+{
+}
+
+void webkitScriptDialogDismiss(WebKitScriptDialog*)
+{
+}
+
+void webkitScriptDialogSetUserInput(WebKitScriptDialog*, const String&)
+{
+}