Diff
Modified: trunk/Source/WebKit/ChangeLog (252233 => 252234)
--- trunk/Source/WebKit/ChangeLog 2019-11-08 09:09:36 UTC (rev 252233)
+++ trunk/Source/WebKit/ChangeLog 2019-11-08 09:19:03 UTC (rev 252234)
@@ -1,3 +1,35 @@
+2019-11-08 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [GTK] Add pointer lock permission request API
+ https://bugs.webkit.org/show_bug.cgi?id=203896
+
+ Reviewed by Adrian Perez de Castro.
+
+ Add a WebKitPointerLockPermissionRequest class to handle pointer lock permissions.
+
+ * PlatformGTK.cmake:
+ * SourcesGTK.txt:
+ * UIProcess/API/glib/WebKitPointerLockPermissionRequest.cpp: Added.
+ (webkitPointerLockPermissionRequestAllow):
+ (webkitPointerLockPermissionRequestDeny):
+ (webkit_permission_request_interface_init):
+ (webkitPointerLockPermissionRequestDispose):
+ (webkit_pointer_lock_permission_request_class_init):
+ (webkitPointerLockPermissionRequestCreate):
+ (webkitPointerLockPermissionRequestDidLosePointerLock):
+ * UIProcess/API/glib/WebKitPointerLockPermissionRequestPrivate.h: Added.
+ * UIProcess/API/glib/WebKitUIClient.cpp:
+ (UIClient::~UIClient):
+ * UIProcess/API/glib/WebKitWebView.cpp:
+ (webkitWebViewPermissionRequest):
+ (webkitWebViewDenyPointerLockRequest):
+ * UIProcess/API/glib/WebKitWebViewPrivate.h:
+ * UIProcess/API/gtk/WebKitPointerLockPermissionRequest.h: Added.
+ * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
+ * UIProcess/API/gtk/docs/webkit2gtk-4.0.types:
+ * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml:
+ * UIProcess/API/gtk/webkit2.h:
+
2019-11-07 Tim Horton <timothy_hor...@apple.com>
Remove an unused icon resource
Modified: trunk/Source/WebKit/PlatformGTK.cmake (252233 => 252234)
--- trunk/Source/WebKit/PlatformGTK.cmake 2019-11-08 09:09:36 UTC (rev 252233)
+++ trunk/Source/WebKit/PlatformGTK.cmake 2019-11-08 09:19:03 UTC (rev 252234)
@@ -95,6 +95,7 @@
${WEBKIT_DIR}/UIProcess/API/gtk/WebKitOptionMenuItem.h
${WEBKIT_DIR}/UIProcess/API/gtk/WebKitPermissionRequest.h
${WEBKIT_DIR}/UIProcess/API/gtk/WebKitPlugin.h
+ ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitPointerLockPermissionRequest.h
${WEBKIT_DIR}/UIProcess/API/gtk/WebKitPolicyDecision.h
${WEBKIT_DIR}/UIProcess/API/gtk/WebKitPrintCustomWidget.h
${WEBKIT_DIR}/UIProcess/API/gtk/WebKitPrintOperation.h
Modified: trunk/Source/WebKit/SourcesGTK.txt (252233 => 252234)
--- trunk/Source/WebKit/SourcesGTK.txt 2019-11-08 09:09:36 UTC (rev 252233)
+++ trunk/Source/WebKit/SourcesGTK.txt 2019-11-08 09:19:03 UTC (rev 252234)
@@ -158,6 +158,7 @@
UIProcess/API/glib/WebKitNotificationProvider.cpp @no-unify
UIProcess/API/glib/WebKitPermissionRequest.cpp @no-unify
UIProcess/API/glib/WebKitPlugin.cpp @no-unify
+UIProcess/API/glib/WebKitPointerLockPermissionRequest.cpp @no-unify
UIProcess/API/glib/WebKitPolicyDecision.cpp @no-unify
UIProcess/API/glib/WebKitPrivate.cpp @no-unify
UIProcess/API/glib/WebKitProtocolHandler.cpp @no-unify
Added: trunk/Source/WebKit/UIProcess/API/glib/WebKitPointerLockPermissionRequest.cpp (0 => 252234)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitPointerLockPermissionRequest.cpp (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitPointerLockPermissionRequest.cpp 2019-11-08 09:19:03 UTC (rev 252234)
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2019 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 "WebKitPointerLockPermissionRequest.h"
+
+#include "WebKitPermissionRequest.h"
+#include "WebKitPointerLockPermissionRequestPrivate.h"
+#include "WebKitWebViewPrivate.h"
+#include <wtf/glib/WTFGType.h>
+
+/**
+ * SECTION: WebKitPointerLockPermissionRequest
+ * @Short_description: A permission request for locking the pointer
+ * @Title: WebKitPointerLockPermissionRequest
+ * @See_also: #WebKitPermissionRequest, #WebKitWebView
+ *
+ * WebKitPointerLockPermissionRequest represents a request for
+ * permission to decide whether WebKit can lock the pointer device when
+ * requested by web content.
+ *
+ * When a WebKitPointerLockPermissionRequest is not handled by the user,
+ * it is allowed by default.
+ *
+ * Since: 2.28
+ */
+
+static void webkit_permission_request_interface_init(WebKitPermissionRequestIface*);
+
+struct _WebKitPointerLockPermissionRequestPrivate {
+ GRefPtr<WebKitWebView> webView;
+ bool madeDecision;
+};
+
+WEBKIT_DEFINE_TYPE_WITH_CODE(
+ WebKitPointerLockPermissionRequest, webkit_pointer_lock_permission_request, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE(WEBKIT_TYPE_PERMISSION_REQUEST, webkit_permission_request_interface_init))
+
+static void webkitPointerLockPermissionRequestAllow(WebKitPermissionRequest* request)
+{
+ ASSERT(WEBKIT_IS_POINTER_LOCK_PERMISSION_REQUEST(request));
+
+ WebKitPointerLockPermissionRequestPrivate* priv = WEBKIT_POINTER_LOCK_PERMISSION_REQUEST(request)->priv;
+
+ // Only one decision at a time.
+ if (priv->madeDecision)
+ return;
+
+ webkitWebViewRequestPointerLock(priv->webView.get());
+ priv->madeDecision = true;
+}
+
+static void webkitPointerLockPermissionRequestDeny(WebKitPermissionRequest* request)
+{
+ ASSERT(WEBKIT_IS_POINTER_LOCK_PERMISSION_REQUEST(request));
+
+ WebKitPointerLockPermissionRequestPrivate* priv = WEBKIT_POINTER_LOCK_PERMISSION_REQUEST(request)->priv;
+
+ // Only one decision at a time.
+ if (priv->madeDecision)
+ return;
+
+ webkitWebViewDenyPointerLockRequest(priv->webView.get());
+ priv->madeDecision = true;
+}
+
+static void webkit_permission_request_interface_init(WebKitPermissionRequestIface* iface)
+{
+ iface->allow = webkitPointerLockPermissionRequestAllow;
+ iface->deny = webkitPointerLockPermissionRequestDeny;
+}
+
+static void webkitPointerLockPermissionRequestDispose(GObject* object)
+{
+ // Default behaviour when no decision has been made is allowing the request.
+ webkitPointerLockPermissionRequestAllow(WEBKIT_PERMISSION_REQUEST(object));
+ G_OBJECT_CLASS(webkit_pointer_lock_permission_request_parent_class)->dispose(object);
+}
+
+static void webkit_pointer_lock_permission_request_class_init(WebKitPointerLockPermissionRequestClass* klass)
+{
+ GObjectClass* objectClass = G_OBJECT_CLASS(klass);
+ objectClass->dispose = webkitPointerLockPermissionRequestDispose;
+}
+
+WebKitPointerLockPermissionRequest* webkitPointerLockPermissionRequestCreate(WebKitWebView* webView)
+{
+ WebKitPointerLockPermissionRequest* request = WEBKIT_POINTER_LOCK_PERMISSION_REQUEST(g_object_new(WEBKIT_TYPE_POINTER_LOCK_PERMISSION_REQUEST, nullptr));
+ request->priv->webView = webView;
+ return request;
+}
+
+void webkitPointerLockPermissionRequestDidLosePointerLock(WebKitPointerLockPermissionRequest* request)
+{
+ request->priv->madeDecision = true;
+ request->priv->webView = nullptr;
+}
Added: trunk/Source/WebKit/UIProcess/API/glib/WebKitPointerLockPermissionRequestPrivate.h (0 => 252234)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitPointerLockPermissionRequestPrivate.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitPointerLockPermissionRequestPrivate.h 2019-11-08 09:19:03 UTC (rev 252234)
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#pragma once
+
+#if ENABLE(POINTER_LOCK)
+
+#include "WebKitPointerLockPermissionRequest.h"
+#include "WebKitWebView.h"
+
+WebKitPointerLockPermissionRequest* webkitPointerLockPermissionRequestCreate(WebKitWebView*);
+void webkitPointerLockPermissionRequestDidLosePointerLock(WebKitPointerLockPermissionRequest*);
+
+#endif // ENABLE(POINTER_LOCK)
Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp (252233 => 252234)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp 2019-11-08 09:09:36 UTC (rev 252233)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp 2019-11-08 09:19:03 UTC (rev 252234)
@@ -27,6 +27,7 @@
#include "WebKitGeolocationPermissionRequestPrivate.h"
#include "WebKitNavigationActionPrivate.h"
#include "WebKitNotificationPermissionRequestPrivate.h"
+#include "WebKitPointerLockPermissionRequestPrivate.h"
#include "WebKitURIRequestPrivate.h"
#include "WebKitUserMediaPermissionRequestPrivate.h"
#include "WebKitWebViewPrivate.h"
@@ -50,6 +51,14 @@
{
}
+ ~UIClient()
+ {
+#if ENABLE(POINTER_LOCK)
+ if (m_pointerLockPermissionRequest)
+ g_object_remove_weak_pointer(G_OBJECT(m_pointerLockPermissionRequest), reinterpret_cast<void**>(&m_pointerLockPermissionRequest));
+#endif
+ }
+
private:
void createNewPage(WebPageProxy& page, WebCore::WindowFeatures&& windowFeatures, Ref<API::NavigationAction>&& apiNavigationAction, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler) final
{
@@ -253,17 +262,28 @@
#if ENABLE(POINTER_LOCK)
void requestPointerLock(WebPageProxy* page) final
{
- webkitWebViewRequestPointerLock(m_webView);
+ GRefPtr<WebKitPointerLockPermissionRequest> permissionRequest = adoptGRef(webkitPointerLockPermissionRequestCreate(m_webView));
+ RELEASE_ASSERT(!m_pointerLockPermissionRequest);
+ m_pointerLockPermissionRequest = permissionRequest.get();
+ g_object_add_weak_pointer(G_OBJECT(m_pointerLockPermissionRequest), reinterpret_cast<void**>(&m_pointerLockPermissionRequest));
+ webkitWebViewMakePermissionRequest(m_webView, WEBKIT_PERMISSION_REQUEST(permissionRequest.get()));
}
void didLosePointerLock(WebPageProxy*) final
{
+ if (m_pointerLockPermissionRequest) {
+ webkitPointerLockPermissionRequestDidLosePointerLock(m_pointerLockPermissionRequest);
+ g_object_remove_weak_pointer(G_OBJECT(m_pointerLockPermissionRequest), reinterpret_cast<void**>(&m_pointerLockPermissionRequest));
+ m_pointerLockPermissionRequest = nullptr;
+ }
webkitWebViewDidLosePointerLock(m_webView);
}
#endif
-
WebKitWebView* m_webView;
+#if ENABLE(POINTER_LOCK)
+ WebKitPointerLockPermissionRequest* m_pointerLockPermissionRequest { nullptr };
+#endif
};
void attachUIClientToView(WebKitWebView* webView)
Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp (252233 => 252234)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp 2019-11-08 09:09:36 UTC (rev 252233)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp 2019-11-08 09:19:03 UTC (rev 252234)
@@ -81,6 +81,7 @@
#include <wtf/text/StringBuilder.h>
#if PLATFORM(GTK)
+#include "WebKitPointerLockPermissionRequest.h"
#include "WebKitPrintOperationPrivate.h"
#include "WebKitWebInspectorPrivate.h"
#include "WebKitWebViewBasePrivate.h"
@@ -506,6 +507,13 @@
static gboolean webkitWebViewPermissionRequest(WebKitWebView*, WebKitPermissionRequest* request)
{
+#if ENABLE(POINTER_LOCK)
+ if (WEBKIT_IS_POINTER_LOCK_PERMISSION_REQUEST(request)) {
+ webkit_permission_request_allow(request);
+ return TRUE;
+ }
+#endif
+
webkit_permission_request_deny(request);
return TRUE;
}
@@ -2635,6 +2643,11 @@
#endif
}
+void webkitWebViewDenyPointerLockRequest(WebKitWebView* webView)
+{
+ getPage(webView).didDenyPointerLock();
+}
+
void webkitWebViewDidLosePointerLock(WebKitWebView* webView)
{
#if PLATFORM(GTK)
Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h (252233 => 252234)
--- trunk/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h 2019-11-08 09:09:36 UTC (rev 252233)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h 2019-11-08 09:19:03 UTC (rev 252234)
@@ -106,5 +106,6 @@
#if ENABLE(POINTER_LOCK)
void webkitWebViewRequestPointerLock(WebKitWebView*);
+void webkitWebViewDenyPointerLockRequest(WebKitWebView*);
void webkitWebViewDidLosePointerLock(WebKitWebView*);
#endif
Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitAutocleanups.h (252233 => 252234)
--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitAutocleanups.h 2019-11-08 09:09:36 UTC (rev 252233)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitAutocleanups.h 2019-11-08 09:19:03 UTC (rev 252234)
@@ -50,6 +50,7 @@
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitOptionMenu, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitPermissionRequest, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitPlugin, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitPointerLockPermissionRequest, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitPolicyDecision, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitPrintCustomWidget, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitPrintOperation, g_object_unref)
Added: trunk/Source/WebKit/UIProcess/API/gtk/WebKitPointerLockPermissionRequest.h (0 => 252234)
--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitPointerLockPermissionRequest.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitPointerLockPermissionRequest.h 2019-11-08 09:19:03 UTC (rev 252234)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2019 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 WebKitPointerLockPermissionRequest_h
+#define WebKitPointerLockPermissionRequest_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_POINTER_LOCK_PERMISSION_REQUEST (webkit_pointer_lock_permission_request_get_type())
+#define WEBKIT_POINTER_LOCK_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_POINTER_LOCK_PERMISSION_REQUEST, WebKitPointerLockPermissionRequest))
+#define WEBKIT_POINTER_LOCK_PERMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_POINTER_LOCK_PERMISSION_REQUEST, WebKitPointerLockPermissionRequestClass))
+#define WEBKIT_IS_POINTER_LOCK_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_POINTER_LOCK_PERMISSION_REQUEST))
+#define WEBKIT_IS_POINTER_LOCK_PERMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_POINTER_LOCK_PERMISSION_REQUEST))
+#define WEBKIT_POINTER_LOCK_PERMISSION_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_POINTER_LOCK_PERMISSION_REQUEST, WebKitPointerLockPermissionRequestClass))
+
+typedef struct _WebKitPointerLockPermissionRequest WebKitPointerLockPermissionRequest;
+typedef struct _WebKitPointerLockPermissionRequestClass WebKitPointerLockPermissionRequestClass;
+typedef struct _WebKitPointerLockPermissionRequestPrivate WebKitPointerLockPermissionRequestPrivate;
+
+struct _WebKitPointerLockPermissionRequest {
+ GObject parent;
+
+ /*< private >*/
+ WebKitPointerLockPermissionRequestPrivate *priv;
+};
+
+struct _WebKitPointerLockPermissionRequestClass {
+ GObjectClass parent_class;
+
+ void (*_webkit_reserved0) (void);
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+};
+
+WEBKIT_API GType
+webkit_pointer_lock_permission_request_get_type (void);
+
+G_END_DECLS
+
+#endif
Modified: trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt (252233 => 252234)
--- trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt 2019-11-08 09:09:36 UTC (rev 252233)
+++ trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt 2019-11-08 09:19:03 UTC (rev 252234)
@@ -731,6 +731,24 @@
</SECTION>
<SECTION>
+<FILE>WebKitPointerLockPermissionRequest</FILE>
+WebKitPointerLockPermissionRequest
+
+<SUBSECTION Standard>
+WebKitPointerLockPermissionRequestClass
+WEBKIT_TYPE_POINTER_LOCK_PERMISSION_REQUEST
+WEBKIT_POINTER_LOCK_PERMISSION_REQUEST
+WEBKIT_IS_POINTER_LOCK_PERMISSION_REQUEST
+WEBKIT_POINTER_LOCK_PERMISSION_REQUEST_CLASS
+WEBKIT_IS_POINTER_LOCK_PERMISSION_REQUEST_CLASS
+WEBKIT_POINTER_LOCK_PERMISSION_REQUEST_GET_CLASS
+
+<SUBSECTION Private>
+WebKitPointerLockPermissionRequestPrivate
+webkit_pointer_lock_permission_request_get_type
+</SECTION>
+
+<SECTION>
<FILE>WebKitNavigationAction</FILE>
WebKitNavigationAction
webkit_navigation_action_copy
Modified: trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0.types (252233 => 252234)
--- trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0.types 2019-11-08 09:09:36 UTC (rev 252233)
+++ trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0.types 2019-11-08 09:19:03 UTC (rev 252234)
@@ -41,4 +41,5 @@
webkit_option_menu_item_get_type
webkit_device_info_permission_request_get_type
webkit_geolocation_manager_get_type
-webkit_geolocation_position_get_type
\ No newline at end of file
+webkit_geolocation_position_get_type
+webkit_pointer_lock_permission_request_get_type
\ No newline at end of file
Modified: trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml (252233 => 252234)
--- trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml 2019-11-08 09:09:36 UTC (rev 252233)
+++ trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml 2019-11-08 09:19:03 UTC (rev 252234)
@@ -64,6 +64,7 @@
<xi:include href=""
<xi:include href=""
<xi:include href=""
+ <xi:include href=""
</chapter>
<chapter>
Modified: trunk/Source/WebKit/UIProcess/API/gtk/webkit2.h (252233 => 252234)
--- trunk/Source/WebKit/UIProcess/API/gtk/webkit2.h 2019-11-08 09:09:36 UTC (rev 252233)
+++ trunk/Source/WebKit/UIProcess/API/gtk/webkit2.h 2019-11-08 09:19:03 UTC (rev 252234)
@@ -64,6 +64,7 @@
#include <webkit2/WebKitOptionMenuItem.h>
#include <webkit2/WebKitPermissionRequest.h>
#include <webkit2/WebKitPlugin.h>
+#include <webkit2/WebKitPointerLockPermissionRequest.h>
#include <webkit2/WebKitPrintCustomWidget.h>
#include <webkit2/WebKitPrintOperation.h>
#include <webkit2/WebKitResponsePolicyDecision.h>
Modified: trunk/Tools/ChangeLog (252233 => 252234)
--- trunk/Tools/ChangeLog 2019-11-08 09:09:36 UTC (rev 252233)
+++ trunk/Tools/ChangeLog 2019-11-08 09:19:03 UTC (rev 252234)
@@ -1,3 +1,21 @@
+2019-11-08 Carlos Garcia Campos <cgar...@igalia.com>
+
+ [GTK] Add pointer lock permission request API
+ https://bugs.webkit.org/show_bug.cgi?id=203896
+
+ Reviewed by Adrian Perez de Castro.
+
+ Handle pointer lock permission requests in MiniBrowser and add a new tests case to check the new API.
+
+ * MiniBrowser/gtk/BrowserTab.c:
+ (pointerLockMessageTimeoutCallback):
+ (decidePermissionRequest):
+ (browserTabFinalize):
+ (browserTabConstructed):
+ * TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp:
+ (testWebViewPointerLockPermissionRequest):
+ (beforeAll):
+
2019-11-07 Chris Dumez <cdu...@apple.com>
TestController may reuse a view that used window.open(), which prevents process-swapping and causes flakiness
Modified: trunk/Tools/MiniBrowser/gtk/BrowserTab.c (252233 => 252234)
--- trunk/Tools/MiniBrowser/gtk/BrowserTab.c 2019-11-08 09:09:36 UTC (rev 252233)
+++ trunk/Tools/MiniBrowser/gtk/BrowserTab.c 2019-11-08 09:19:03 UTC (rev 252234)
@@ -48,6 +48,8 @@
gboolean inspectorIsVisible;
GtkWidget *fullScreenMessageLabel;
guint fullScreenMessageLabelId;
+ GtkWidget *pointerLockMessageLabel;
+ guint pointerLockMessageLabelId;
/* Tab Title */
GtkWidget *titleBox;
@@ -204,6 +206,13 @@
return TRUE;
}
+static gboolean pointerLockMessageTimeoutCallback(BrowserTab *tab)
+{
+ gtk_widget_hide(tab->pointerLockMessageLabel);
+ tab->pointerLockMessageLabelId = 0;
+ return FALSE;
+}
+
static void permissionRequestDialogResponse(GtkWidget *dialog, gint response, PermissionRequestData *requestData)
{
switch (response) {
@@ -262,6 +271,19 @@
}
g_free(origin);
return FALSE;
+ } else if (WEBKIT_IS_POINTER_LOCK_PERMISSION_REQUEST(request)) {
+ const gchar *titleOrURI = webkit_web_view_get_title(tab->webView);
+ if (!titleOrURI || !titleOrURI[0])
+ titleOrURI = webkit_web_view_get_uri(tab->webView);
+
+ char *message = g_strdup_printf("%s wants to lock the pointer. Press ESC to get the pointer back.", titleOrURI);
+ gtk_label_set_text(GTK_LABEL(tab->pointerLockMessageLabel), message);
+ g_free(message);
+ gtk_widget_show(tab->pointerLockMessageLabel);
+
+ tab->pointerLockMessageLabelId = g_timeout_add_seconds(2, (GSourceFunc)pointerLockMessageTimeoutCallback, tab);
+ g_source_set_name_by_id(tab->pointerLockMessageLabelId, "[WebKit]pointerLockMessageTimeoutCallback");
+ return TRUE;
} else {
g_print("%s request not handled\n", G_OBJECT_TYPE_NAME(request));
return FALSE;
@@ -353,6 +375,8 @@
if (tab->fullScreenMessageLabelId)
g_source_remove(tab->fullScreenMessageLabelId);
+ if (tab->pointerLockMessageLabelId)
+ g_source_remove(tab->pointerLockMessageLabelId);
G_OBJECT_CLASS(browser_tab_parent_class)->finalize(gObject);
}
@@ -390,6 +414,12 @@
gtk_widget_set_no_show_all(tab->fullScreenMessageLabel, TRUE);
gtk_overlay_add_overlay(GTK_OVERLAY(overlay), tab->fullScreenMessageLabel);
+ tab->pointerLockMessageLabel = gtk_label_new(NULL);
+ gtk_widget_set_halign(tab->pointerLockMessageLabel, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign(tab->pointerLockMessageLabel, GTK_ALIGN_START);
+ gtk_widget_set_no_show_all(tab->pointerLockMessageLabel, TRUE);
+ gtk_overlay_add_overlay(GTK_OVERLAY(overlay), tab->pointerLockMessageLabel);
+
gtk_container_add(GTK_CONTAINER(overlay), GTK_WIDGET(tab->webView));
gtk_widget_show(GTK_WIDGET(tab->webView));
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp (252233 => 252234)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp 2019-11-08 09:09:36 UTC (rev 252233)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp 2019-11-08 09:19:03 UTC (rev 252234)
@@ -218,7 +218,8 @@
test->m_mouseTargetHitTestResult = hitTestResult;
test->m_mouseTargetModifiers = modifiers;
- g_main_loop_quit(test->m_mainLoop);
+ if (test->m_waitingForMouseTargetChange)
+ g_main_loop_quit(test->m_mainLoop);
}
static gboolean permissionRequested(WebKitWebView*, WebKitPermissionRequest* request, UIClientTest* test)
@@ -308,8 +309,10 @@
WebKitHitTestResult* moveMouseAndWaitUntilMouseTargetChanged(int x, int y, unsigned mouseModifiers = 0)
{
+ m_waitingForMouseTargetChange = true;
mouseMoveTo(x, y, mouseModifiers);
g_main_loop_run(m_mainLoop);
+ m_waitingForMouseTargetChange = false;
return m_mouseTargetHitTestResult.get();
}
@@ -384,6 +387,7 @@
GRefPtr<WebKitHitTestResult> m_mouseTargetHitTestResult;
unsigned m_mouseTargetModifiers;
GUniquePtr<char> m_permissionResult;
+ bool m_waitingForMouseTargetChange { false };
};
static void testWebViewCreateReadyClose(UIClientTest* test, gconstpointer)
@@ -947,7 +951,45 @@
}
#endif // ENABLE(MEDIA_STREAM)
+#if ENABLE(POINTER_LOCK)
+static void testWebViewPointerLockPermissionRequest(UIClientTest* test, gconstpointer)
+{
#if PLATFORM(GTK)
+ test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);
+#endif
+
+ static const char* pointerLockRequestHTML =
+ "<html>"
+ " <script>"
+ " function runTest()"
+ " {"
+ " document._onpointerlockchange_ = function () { document.title = \"Locked\" };"
+ " document._onpointerlockerror_ = function () { document.title = \"Error\" };"
+ " document.getElementById('target').requestPointerLock();"
+ " }"
+ " </script>"
+ " <body>"
+ " <input style='position:absolute; left:0; top:0; margin:0; padding:0' type='button' value='click to lock pointer' _onclick_='runTest()'/>"
+ " <div id='target'></div>"
+ " </body>"
+ "</html>";
+
+ test->loadHtml(pointerLockRequestHTML, nullptr);
+ test->waitUntilLoadFinished();
+
+ // Test denying a permission request.
+ test->m_allowPermissionRequests = false;
+ test->clickMouseButton(5, 5, 1);
+ test->waitUntilTitleChangedTo("Error");
+
+ // Test allowing a permission request.
+ test->m_allowPermissionRequests = true;
+ test->clickMouseButton(5, 5, 1);
+ test->waitUntilTitleChangedTo("Locked");
+}
+#endif
+
+#if PLATFORM(GTK)
class FileChooserTest: public UIClientTest {
public:
MAKE_GLIB_TEST_FIXTURE(FileChooserTest);
@@ -1204,6 +1246,9 @@
#if PLATFORM(GTK)
ColorChooserTest::add("WebKitWebView", "color-chooser-request", testWebViewColorChooserRequest);
#endif
+#if ENABLE(POINTER_LOCK)
+ UIClientTest::add("WebKitWebView", "pointer-lock-permission-request", testWebViewPointerLockPermissionRequest);
+#endif
}
void afterAll()