Diff
Modified: trunk/Source/WebKit2/ChangeLog (122960 => 122961)
--- trunk/Source/WebKit2/ChangeLog 2012-07-18 13:27:12 UTC (rev 122960)
+++ trunk/Source/WebKit2/ChangeLog 2012-07-18 13:39:26 UTC (rev 122961)
@@ -1,5 +1,53 @@
2012-07-18 Carlos Garcia Campos <[email protected]>
+ [GTK] Add WebKitWebView::submit-form signal to WebKit2 GTK+ API
+ https://bugs.webkit.org/show_bug.cgi?id=91605
+
+ Reviewed by Gustavo Noronha Silva.
+
+ The signal is emitted when a form is about to submitted, with a
+ form submission request that can be used to get the text fields
+ and to continue the form submission wheh done.
+
+ * GNUmakefile.list.am: Add new files to compilation.
+ * UIProcess/API/gtk/WebKitFormClient.cpp: Added.
+ (willSubmitForm): Create a WebKitFormSubmissionRequest and call
+ webkitWebViewSubmitFormRequest() with the request.
+ (attachFormClientToView): Add impementation for willSubmitForm
+ callback.
+ * UIProcess/API/gtk/WebKitFormClient.h: Added.
+ * UIProcess/API/gtk/WebKitFormSubmissionRequest.cpp: Added.
+ (webkit_form_submission_request_init):
+ (webkitFormSubmissionRequestFinalize):
+ (webkit_form_submission_request_class_init):
+ (webkitFormSubmissionRequestCreate): Create a new
+ WebKitFormSubmissionRequest for the given values dictionary and
+ submission listener.
+ (webkit_form_submission_request_get_text_fields): Create a
+ GHashTable with the text fields values and return it.
+ (webkit_form_submission_request_submit): Continue the form
+ submission.
+ * UIProcess/API/gtk/WebKitFormSubmissionRequest.h: Added.
+ * UIProcess/API/gtk/WebKitFormSubmissionRequestPrivate.h: Added.
+ * UIProcess/API/gtk/WebKitWebView.cpp:
+ (webkitWebViewConstructed): Attach web view to form client.
+ (webkit_web_view_class_init): Add WebKitWebView::submit-form
+ signal.
+ (webkitWebViewSubmitFormRequest): Emit WebKitWebView::submit-form
+ signal.
+ * UIProcess/API/gtk/WebKitWebView.h:
+ * UIProcess/API/gtk/WebKitWebViewPrivate.h:
+ * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: Add new section for
+ WebKitFormSubmissionRequest.
+ * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbols.
+ * UIProcess/API/gtk/tests/TestWebKitWebView.cpp:
+ (testWebViewSubmitForm):
+ (beforeAll):
+ * UIProcess/API/gtk/webkit2.h: Include
+ WebKitFormSubmissionRequest.h.
+
+2012-07-18 Carlos Garcia Campos <[email protected]>
+
[GTK] No main resource in WebView when page has been loaded from history cache
https://bugs.webkit.org/show_bug.cgi?id=91478
Modified: trunk/Source/WebKit2/GNUmakefile.list.am (122960 => 122961)
--- trunk/Source/WebKit2/GNUmakefile.list.am 2012-07-18 13:27:12 UTC (rev 122960)
+++ trunk/Source/WebKit2/GNUmakefile.list.am 2012-07-18 13:39:26 UTC (rev 122961)
@@ -104,6 +104,7 @@
$(WebKit2)/UIProcess/API/gtk/WebKitError.h \
$(WebKit2)/UIProcess/API/gtk/WebKitFileChooserRequest.h \
$(WebKit2)/UIProcess/API/gtk/WebKitFindController.h \
+ $(WebKit2)/UIProcess/API/gtk/WebKitFormSubmissionRequest.h \
$(WebKit2)/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.h \
$(WebKit2)/UIProcess/API/gtk/WebKitHitTestResult.h \
$(WebKit2)/UIProcess/API/gtk/WebKitJavascriptResult.h \
@@ -637,6 +638,11 @@
Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.cpp \
Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequest.h \
Source/WebKit2/UIProcess/API/gtk/WebKitFileChooserRequestPrivate.h \
+ Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.cpp \
+ Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.h \
+ Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequestPrivate.h \
+ Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.cpp \
+ Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.h \
Source/WebKit2/UIProcess/API/gtk/WebKitFullscreenClient.cpp \
Source/WebKit2/UIProcess/API/gtk/WebKitFullscreenClient.h \
Source/WebKit2/UIProcess/API/gtk/WebKitGeolocationPermissionRequest.cpp \
Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.cpp (0 => 122961)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.cpp 2012-07-18 13:39:26 UTC (rev 122961)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2012 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 "WebKitFormClient.h"
+
+#include "WebKitFormSubmissionRequestPrivate.h"
+#include "WebKitPrivate.h"
+#include "WebKitWebViewBasePrivate.h"
+#include "WebKitWebViewPrivate.h"
+#include <wtf/gobject/GRefPtr.h>
+
+using namespace WebKit;
+
+static void willSubmitForm(WKPageRef page, WKFrameRef frame, WKFrameRef sourceFrame, WKDictionaryRef values, WKTypeRef userData, WKFormSubmissionListenerRef listener, const void* clientInfo)
+{
+ GRefPtr<WebKitFormSubmissionRequest> request = adoptGRef(webkitFormSubmissionRequestCreate(values, listener));
+ webkitWebViewSubmitFormRequest(WEBKIT_WEB_VIEW(clientInfo), request.get());
+}
+
+void attachFormClientToView(WebKitWebView* webView)
+{
+ WKPageFormClient wkFormClient = {
+ kWKPageFormClientCurrentVersion,
+ webView, // clientInfo
+ willSubmitForm
+ };
+ WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)));
+ WKPageSetPageFormClient(wkPage, &wkFormClient);
+}
Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.h (0 => 122961)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFormClient.h 2012-07-18 13:39:26 UTC (rev 122961)
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#ifndef WebKitFormClient_h
+#define WebKitFormClient_h
+
+#include "WebKitWebView.h"
+
+void attachFormClientToView(WebKitWebView*);
+
+#endif
Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.cpp (0 => 122961)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.cpp 2012-07-18 13:39:26 UTC (rev 122961)
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2012 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 "WebKitFormSubmissionRequest.h"
+
+#include "WebKitFormSubmissionRequestPrivate.h"
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+
+G_DEFINE_TYPE(WebKitFormSubmissionRequest, webkit_form_submission_request, G_TYPE_OBJECT)
+
+struct _WebKitFormSubmissionRequestPrivate {
+ WKRetainPtr<WKDictionaryRef> wkValues;
+ WKRetainPtr<WKFormSubmissionListenerRef> wkListener;
+ GRefPtr<GHashTable> values;
+ bool handledRequest;
+};
+
+static void webkit_form_submission_request_init(WebKitFormSubmissionRequest* request)
+{
+ WebKitFormSubmissionRequestPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(request, WEBKIT_TYPE_FORM_SUBMISSION_REQUEST, WebKitFormSubmissionRequestPrivate);
+ request->priv = priv;
+ new (priv) WebKitFormSubmissionRequestPrivate();
+}
+
+static void webkitFormSubmissionRequestFinalize(GObject* object)
+{
+ WebKitFormSubmissionRequest* request = WEBKIT_FORM_SUBMISSION_REQUEST(object);
+
+ // Make sure the request is always handled before finalizing.
+ if (!request->priv->handledRequest)
+ webkit_form_submission_request_submit(request);
+
+ request->priv->~WebKitFormSubmissionRequestPrivate();
+ G_OBJECT_CLASS(webkit_form_submission_request_parent_class)->finalize(object);
+}
+
+static void webkit_form_submission_request_class_init(WebKitFormSubmissionRequestClass* requestClass)
+{
+ GObjectClass* objectClass = G_OBJECT_CLASS(requestClass);
+ objectClass->finalize = webkitFormSubmissionRequestFinalize;
+ g_type_class_add_private(requestClass, sizeof(WebKitFormSubmissionRequestPrivate));
+}
+
+WebKitFormSubmissionRequest* webkitFormSubmissionRequestCreate(WKDictionaryRef wkValues, WKFormSubmissionListenerRef wkListener)
+{
+ WebKitFormSubmissionRequest* request = WEBKIT_FORM_SUBMISSION_REQUEST(g_object_new(WEBKIT_TYPE_FORM_SUBMISSION_REQUEST, NULL));
+ request->priv->wkValues = wkValues;
+ request->priv->wkListener = wkListener;
+ return request;
+}
+
+/**
+ * webkit_form_submission_request_get_text_fields:
+ * @request: a #WebKitFormSubmissionRequest
+ *
+ * Get a #GHashTable with the values of the text fields contained in the form
+ * associated to @request.
+ *
+ * Returns: (transfer none): a #GHashTable with the form text fields, or %NULL if the
+ * form doesn't contain text fields.
+ */
+GHashTable* webkit_form_submission_request_get_text_fields(WebKitFormSubmissionRequest* request)
+{
+ g_return_val_if_fail(WEBKIT_IS_FORM_SUBMISSION_REQUEST(request), 0);
+
+ if (request->priv->values)
+ return request->priv->values.get();
+
+ if (!WKDictionaryGetSize(request->priv->wkValues.get()))
+ return 0;
+
+ request->priv->values = adoptGRef(g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free));
+
+ WKRetainPtr<WKArrayRef> wkKeys(AdoptWK, WKDictionaryCopyKeys(request->priv->wkValues.get()));
+ for (size_t i = 0; i < WKArrayGetSize(wkKeys.get()); ++i) {
+ WKStringRef wkKey = static_cast<WKStringRef>(WKArrayGetItemAtIndex(wkKeys.get(), i));
+ WKStringRef wkValue = static_cast<WKStringRef>(WKDictionaryGetItemForKey(request->priv->wkValues.get(), wkKey));
+ g_hash_table_insert(request->priv->values.get(), g_strdup(toImpl(wkKey)->string().utf8().data()), g_strdup(toImpl(wkValue)->string().utf8().data()));
+ }
+
+ request->priv->wkValues = 0;
+
+ return request->priv->values.get();
+}
+
+/**
+ * webkit_form_submission_request_submit:
+ * @request: a #WebKitFormSubmissionRequest
+ *
+ * Continue the form submission.
+ */
+void webkit_form_submission_request_submit(WebKitFormSubmissionRequest* request)
+{
+ g_return_if_fail(WEBKIT_IS_FORM_SUBMISSION_REQUEST(request));
+
+ WKFormSubmissionListenerContinue(request->priv->wkListener.get());
+ request->priv->handledRequest = true;
+}
Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.h (0 => 122961)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequest.h 2012-07-18 13:39:26 UTC (rev 122961)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitFormSubmissionRequest_h
+#define WebKitFormSubmissionRequest_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_FORM_SUBMISSION_REQUEST (webkit_form_submission_request_get_type())
+#define WEBKIT_FORM_SUBMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_FORM_SUBMISSION_REQUEST, WebKitFormSubmissionRequest))
+#define WEBKIT_IS_FORM_SUBMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_FORM_SUBMISSION_REQUEST))
+#define WEBKIT_FORM_SUBMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_FORM_SUBMISSION_REQUEST, WebKitFormSubmissionRequestClass))
+#define WEBKIT_IS_FORM_SUBMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_FORM_SUBMISSION_REQUEST))
+#define WEBKIT_FORM_SUBMISSION_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_FORM_SUBMISSION_REQUEST, WebKitFormSubmissionRequestClass))
+
+typedef struct _WebKitFormSubmissionRequest WebKitFormSubmissionRequest;
+typedef struct _WebKitFormSubmissionRequestClass WebKitFormSubmissionRequestClass;
+typedef struct _WebKitFormSubmissionRequestPrivate WebKitFormSubmissionRequestPrivate;
+
+struct _WebKitFormSubmissionRequest {
+ GObject parent;
+
+ /*< private >*/
+ WebKitFormSubmissionRequestPrivate *priv;
+};
+
+struct _WebKitFormSubmissionRequestClass {
+ GObjectClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_form_submission_request_get_type (void);
+
+WEBKIT_API GHashTable *
+webkit_form_submission_request_get_text_fields (WebKitFormSubmissionRequest *request);
+
+WEBKIT_API void
+webkit_form_submission_request_submit (WebKitFormSubmissionRequest *request);
+
+G_END_DECLS
+
+#endif
Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequestPrivate.h (0 => 122961)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequestPrivate.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitFormSubmissionRequestPrivate.h 2012-07-18 13:39:26 UTC (rev 122961)
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#ifndef WebKitFormSubmissionRequestPrivate_h
+#define WebKitFormSubmissionRequestPrivate_h
+
+#include "WebKitFormSubmissionRequest.h"
+#include "WebKitPrivate.h"
+
+WebKitFormSubmissionRequest* webkitFormSubmissionRequestCreate(WKDictionaryRef, WKFormSubmissionListenerRef);
+
+#endif // WebKitFormSubmissionRequestPrivate_h
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp (122960 => 122961)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2012-07-18 13:27:12 UTC (rev 122960)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp 2012-07-18 13:39:26 UTC (rev 122961)
@@ -29,6 +29,7 @@
#include "WebKitContextMenuPrivate.h"
#include "WebKitEnumTypes.h"
#include "WebKitError.h"
+#include "WebKitFormClient.h"
#include "WebKitFullscreenClient.h"
#include "WebKitHitTestResultPrivate.h"
#include "WebKitJavascriptResultPrivate.h"
@@ -90,6 +91,8 @@
CONTEXT_MENU,
CONTEXT_MENU_DISMISSED,
+ SUBMIT_FORM,
+
LAST_SIGNAL
};
@@ -325,6 +328,7 @@
attachResourceLoadClientToView(webView);
attachFullScreenClientToView(webView);
attachContextMenuClientToView(webView);
+ attachFormClientToView(webView);
WebPageProxy* page = webkitWebViewBaseGetPage(webViewBase);
priv->backForwardList = adoptGRef(webkitBackForwardListCreate(WKPageGetBackForwardList(toAPI(page))));
@@ -1060,6 +1064,33 @@
0, 0,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+
+ /**
+ * WebKitWebView::submit-form:
+ * @web_view: the #WebKitWebView on which the signal is emitted
+ * @request: a #WebKitFormSubmissionRequest
+ *
+ * This signal is emitted when a form is about to be submitted. The @request
+ * argument passed contains information about the text fields of the form. This
+ * is typically used to store login information that can be used later to
+ * pre-fill the form.
+ * The form will not be submitted until webkit_form_submission_request_submit() is called.
+ *
+ * It is possible to handle the form submission request asynchronously, by
+ * simply calling g_object_ref() on the @request argument and calling
+ * webkit_form_submission_request_submit() when done to continue with the form submission.
+ * If the last reference is removed on a #WebKitFormSubmissionRequest and the
+ * form has not been submitted, webkit_form_submission_request_submit() will be called.
+ */
+ signals[SUBMIT_FORM] =
+ g_signal_new("submit-form",
+ G_TYPE_FROM_CLASS(webViewClass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(WebKitWebViewClass, submit_form),
+ 0, 0,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1,
+ WEBKIT_TYPE_FORM_SUBMISSION_REQUEST);
}
static bool updateReplaceContentStatus(WebKitWebView* webView, WebKitLoadEvent loadEvent)
@@ -1388,6 +1419,11 @@
webkit_context_menu_remove_all(contextMenu.get());
}
+void webkitWebViewSubmitFormRequest(WebKitWebView* webView, WebKitFormSubmissionRequest* request)
+{
+ g_signal_emit(webView, signals[SUBMIT_FORM], 0, request);
+}
+
/**
* webkit_web_view_new:
*
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h (122960 => 122961)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h 2012-07-18 13:27:12 UTC (rev 122960)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h 2012-07-18 13:39:26 UTC (rev 122961)
@@ -33,6 +33,7 @@
#include <webkit2/WebKitDefines.h>
#include <webkit2/WebKitFileChooserRequest.h>
#include <webkit2/WebKitFindController.h>
+#include <webkit2/WebKitFormSubmissionRequest.h>
#include <webkit2/WebKitHitTestResult.h>
#include <webkit2/WebKitJavascriptResult.h>
#include <webkit2/WebKitPermissionRequest.h>
@@ -127,43 +128,45 @@
struct _WebKitWebViewClass {
WebKitWebViewBaseClass parent;
- void (* load_changed) (WebKitWebView *web_view,
- WebKitLoadEvent load_event);
- gboolean (* load_failed) (WebKitWebView *web_view,
- WebKitLoadEvent load_event,
- const gchar *failing_uri,
- GError *error);
+ void (* load_changed) (WebKitWebView *web_view,
+ WebKitLoadEvent load_event);
+ gboolean (* load_failed) (WebKitWebView *web_view,
+ WebKitLoadEvent load_event,
+ const gchar *failing_uri,
+ GError *error);
- GtkWidget *(* create) (WebKitWebView *web_view);
- void (* ready_to_show) (WebKitWebView *web_view);
- void (* run_as_modal) (WebKitWebView *web_view);
- void (* close) (WebKitWebView *web_view);
+ GtkWidget *(* create) (WebKitWebView *web_view);
+ void (* ready_to_show) (WebKitWebView *web_view);
+ void (* run_as_modal) (WebKitWebView *web_view);
+ void (* close) (WebKitWebView *web_view);
- gboolean (* script_dialog) (WebKitWebView *web_view,
- WebKitScriptDialog *dialog);
+ gboolean (* script_dialog) (WebKitWebView *web_view,
+ WebKitScriptDialog *dialog);
- gboolean (* decide_policy) (WebKitWebView *web_view,
- WebKitPolicyDecision *decision,
- WebKitPolicyDecisionType type);
- gboolean (* permission_request) (WebKitWebView *web_view,
- WebKitPermissionRequest *permission_request);
- void (* mouse_target_changed) (WebKitWebView *web_view,
- WebKitHitTestResult *hit_test_result,
- guint modifiers);
- gboolean (* print_requested) (WebKitWebView *web_view,
- WebKitPrintOperation *print_operation);
- void (* resource_load_started) (WebKitWebView *web_view,
- WebKitWebResource *resource,
- WebKitURIRequest *request);
- gboolean (* enter_fullscreen) (WebKitWebView *web_view);
- gboolean (* leave_fullscreen) (WebKitWebView *web_view);
- gboolean (* run_file_chooser) (WebKitWebView *web_view,
- WebKitFileChooserRequest *request);
- gboolean (* context_menu) (WebKitWebView *web_view,
- WebKitContextMenu *context_menu,
- GdkEvent *event,
- WebKitHitTestResult *hit_test_result);
- void (* context_menu_dismissed) (WebKitWebView *web_view);
+ gboolean (* decide_policy) (WebKitWebView *web_view,
+ WebKitPolicyDecision *decision,
+ WebKitPolicyDecisionType type);
+ gboolean (* permission_request) (WebKitWebView *web_view,
+ WebKitPermissionRequest *permission_request);
+ void (* mouse_target_changed) (WebKitWebView *web_view,
+ WebKitHitTestResult *hit_test_result,
+ guint modifiers);
+ gboolean (* print_requested) (WebKitWebView *web_view,
+ WebKitPrintOperation *print_operation);
+ void (* resource_load_started) (WebKitWebView *web_view,
+ WebKitWebResource *resource,
+ WebKitURIRequest *request);
+ gboolean (* enter_fullscreen) (WebKitWebView *web_view);
+ gboolean (* leave_fullscreen) (WebKitWebView *web_view);
+ gboolean (* run_file_chooser) (WebKitWebView *web_view,
+ WebKitFileChooserRequest *request);
+ gboolean (* context_menu) (WebKitWebView *web_view,
+ WebKitContextMenu *context_menu,
+ GdkEvent *event,
+ WebKitHitTestResult *hit_test_result);
+ void (* context_menu_dismissed) (WebKitWebView *web_view);
+ void (* submit_form) (WebKitWebView *web_view,
+ WebKitFormSubmissionRequest *request);
/* Padding for future expansion */
void (*_webkit_reserved0) (void);
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h (122960 => 122961)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h 2012-07-18 13:27:12 UTC (rev 122960)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h 2012-07-18 13:39:26 UTC (rev 122961)
@@ -55,5 +55,6 @@
bool webkitWebViewEnterFullScreen(WebKitWebView*);
bool webkitWebViewLeaveFullScreen(WebKitWebView*);
void webkitWebViewPopulateContextMenu(WebKitWebView*, WKArrayRef proposedMenu, WKHitTestResultRef);
+void webkitWebViewSubmitFormRequest(WebKitWebView*, WebKitFormSubmissionRequest*);
#endif // WebKitWebViewPrivate_h
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml (122960 => 122961)
--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml 2012-07-18 13:27:12 UTC (rev 122960)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml 2012-07-18 13:39:26 UTC (rev 122961)
@@ -39,6 +39,7 @@
<xi:include href=""
<xi:include href=""
<xi:include href=""
+ <xi:include href=""
</chapter>
<index id="index-all">
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (122960 => 122961)
--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt 2012-07-18 13:27:12 UTC (rev 122960)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt 2012-07-18 13:39:26 UTC (rev 122961)
@@ -814,3 +814,23 @@
WebKitContextMenuItemPrivate
webkit_context_menu_item_get_type
</SECTION>
+
+<SECTION>
+<FILE>WebKitFormSubmissionRequest</FILE>
+WebKitFormSubmissionRequest
+webkit_form_submission_request_get_text_fields
+webkit_form_submission_request_submit
+
+<SUBSECTION Standard>
+WebKitFormSubmissionRequestClass
+WEBKIT_TYPE_FORM_SUBMISSION_REQUEST
+WEBKIT_FORM_SUBMISSION_REQUEST
+WEBKIT_IS_FORM_SUBMISSION_REQUEST
+WEBKIT_FORM_SUBMISSION_REQUEST_CLASS
+WEBKIT_IS_FORM_SUBMISSION_REQUEST_CLASS
+WEBKIT_FORM_SUBMISSION_REQUEST_GET_CLASS
+
+<SUBSECTION Private>
+WebKitFormSubmissionRequestPrivate
+webkit_form_submission_request_get_type
+</SECTION>
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp (122960 => 122961)
--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp 2012-07-18 13:27:12 UTC (rev 122960)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp 2012-07-18 13:39:26 UTC (rev 122961)
@@ -865,6 +865,87 @@
g_assert(!webkit_web_view_can_show_mime_type(test->m_webView, "application/octet-stream"));
}
+class FormClientTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(FormClientTest);
+
+ static void submitFormCallback(WebKitWebView*, WebKitFormSubmissionRequest* request, FormClientTest* test)
+ {
+ test->submitForm(request);
+ }
+
+ FormClientTest()
+ : m_submitPositionX(0)
+ , m_submitPositionY(0)
+ {
+ g_signal_connect(m_webView, "submit-form", G_CALLBACK(submitFormCallback), this);
+ }
+
+ ~FormClientTest()
+ {
+ g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ }
+
+ void submitForm(WebKitFormSubmissionRequest* request)
+ {
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(request));
+ m_request = request;
+ webkit_form_submission_request_submit(request);
+ quitMainLoop();
+ }
+
+ GHashTable* waitUntilFormSubmittedAndGetTextFields()
+ {
+ g_main_loop_run(m_mainLoop);
+ return webkit_form_submission_request_get_text_fields(m_request.get());
+ }
+
+ static gboolean doClickIdleCallback(FormClientTest* test)
+ {
+ test->clickMouseButton(test->m_submitPositionX, test->m_submitPositionY, 1);
+ return FALSE;
+ }
+
+ void submitFormAtPosition(int x, int y)
+ {
+ m_submitPositionX = x;
+ m_submitPositionY = y;
+ g_idle_add(reinterpret_cast<GSourceFunc>(doClickIdleCallback), this);
+ }
+
+ int m_submitPositionX;
+ int m_submitPositionY;
+ GRefPtr<WebKitFormSubmissionRequest> m_request;
+};
+
+static void testWebViewSubmitForm(FormClientTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped();
+
+ const char* formHTML =
+ "<html><body>"
+ " <form action=''>"
+ " <input type='text' name='text1' value='value1'>"
+ " <input type='text' name='text2' value='value2'>"
+ " <input type='password' name='password' value='secret'>"
+ " <textarea cols='5' rows='5' name='textarea'>Text</textarea>"
+ " <input type='hidden' name='hidden1' value='hidden1'>"
+ " <input type='submit' value='Submit' style='position:absolute; left:1; top:1' size='10'>"
+ " </form>"
+ "</body></html>";
+
+ test->loadHtml(formHTML, "file:///");
+ test->waitUntilLoadFinished();
+
+ test->submitFormAtPosition(5, 5);
+ GHashTable* values = test->waitUntilFormSubmittedAndGetTextFields();
+ g_assert(values);
+ g_assert_cmpuint(g_hash_table_size(values), ==, 3);
+ g_assert_cmpstr(static_cast<char*>(g_hash_table_lookup(values, "text1")), ==, "value1");
+ g_assert_cmpstr(static_cast<char*>(g_hash_table_lookup(values, "text2")), ==, "value2");
+ g_assert_cmpstr(static_cast<char*>(g_hash_table_lookup(values, "password")), ==, "secret");
+}
+
void beforeAll()
{
WebViewTest::add("WebKitWebView", "default-context", testWebViewDefaultContext);
@@ -883,6 +964,7 @@
FileChooserTest::add("WebKitWebView", "file-chooser-request", testWebViewFileChooserRequest);
FullScreenClientTest::add("WebKitWebView", "fullscreen", testWebViewFullScreen);
WebViewTest::add("WebKitWebView", "can-show-mime-type", testWebViewCanShowMIMEType);
+ FormClientTest::add("WebKitWebView", "submit-form", testWebViewSubmitForm);
}
void afterAll()
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h (122960 => 122961)
--- trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h 2012-07-18 13:27:12 UTC (rev 122960)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h 2012-07-18 13:39:26 UTC (rev 122961)
@@ -36,6 +36,7 @@
#include <webkit2/WebKitError.h>
#include <webkit2/WebKitFileChooserRequest.h>
#include <webkit2/WebKitFindController.h>
+#include <webkit2/WebKitFormSubmissionRequest.h>
#include <webkit2/WebKitGeolocationPermissionRequest.h>
#include <webkit2/WebKitHitTestResult.h>
#include <webkit2/WebKitJavascriptResult.h>