Changeset 252234 in webkit
- Timestamp:
- Nov 8, 2019 1:19:03 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r252223 r252234 1 2019-11-08 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Add pointer lock permission request API 4 https://bugs.webkit.org/show_bug.cgi?id=203896 5 6 Reviewed by Adrian Perez de Castro. 7 8 Add a WebKitPointerLockPermissionRequest class to handle pointer lock permissions. 9 10 * PlatformGTK.cmake: 11 * SourcesGTK.txt: 12 * UIProcess/API/glib/WebKitPointerLockPermissionRequest.cpp: Added. 13 (webkitPointerLockPermissionRequestAllow): 14 (webkitPointerLockPermissionRequestDeny): 15 (webkit_permission_request_interface_init): 16 (webkitPointerLockPermissionRequestDispose): 17 (webkit_pointer_lock_permission_request_class_init): 18 (webkitPointerLockPermissionRequestCreate): 19 (webkitPointerLockPermissionRequestDidLosePointerLock): 20 * UIProcess/API/glib/WebKitPointerLockPermissionRequestPrivate.h: Added. 21 * UIProcess/API/glib/WebKitUIClient.cpp: 22 (UIClient::~UIClient): 23 * UIProcess/API/glib/WebKitWebView.cpp: 24 (webkitWebViewPermissionRequest): 25 (webkitWebViewDenyPointerLockRequest): 26 * UIProcess/API/glib/WebKitWebViewPrivate.h: 27 * UIProcess/API/gtk/WebKitPointerLockPermissionRequest.h: Added. 28 * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: 29 * UIProcess/API/gtk/docs/webkit2gtk-4.0.types: 30 * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: 31 * UIProcess/API/gtk/webkit2.h: 32 1 33 2019-11-07 Tim Horton <timothy_horton@apple.com> 2 34 -
trunk/Source/WebKit/PlatformGTK.cmake
r252126 r252234 96 96 ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitPermissionRequest.h 97 97 ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitPlugin.h 98 ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitPointerLockPermissionRequest.h 98 99 ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitPolicyDecision.h 99 100 ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitPrintCustomWidget.h -
trunk/Source/WebKit/SourcesGTK.txt
r252126 r252234 159 159 UIProcess/API/glib/WebKitPermissionRequest.cpp @no-unify 160 160 UIProcess/API/glib/WebKitPlugin.cpp @no-unify 161 UIProcess/API/glib/WebKitPointerLockPermissionRequest.cpp @no-unify 161 162 UIProcess/API/glib/WebKitPolicyDecision.cpp @no-unify 162 163 UIProcess/API/glib/WebKitPrivate.cpp @no-unify -
trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp
r252126 r252234 28 28 #include "WebKitNavigationActionPrivate.h" 29 29 #include "WebKitNotificationPermissionRequestPrivate.h" 30 #include "WebKitPointerLockPermissionRequestPrivate.h" 30 31 #include "WebKitURIRequestPrivate.h" 31 32 #include "WebKitUserMediaPermissionRequestPrivate.h" … … 49 50 : m_webView(webView) 50 51 { 52 } 53 54 ~UIClient() 55 { 56 #if ENABLE(POINTER_LOCK) 57 if (m_pointerLockPermissionRequest) 58 g_object_remove_weak_pointer(G_OBJECT(m_pointerLockPermissionRequest), reinterpret_cast<void**>(&m_pointerLockPermissionRequest)); 59 #endif 51 60 } 52 61 … … 254 263 void requestPointerLock(WebPageProxy* page) final 255 264 { 256 webkitWebViewRequestPointerLock(m_webView); 265 GRefPtr<WebKitPointerLockPermissionRequest> permissionRequest = adoptGRef(webkitPointerLockPermissionRequestCreate(m_webView)); 266 RELEASE_ASSERT(!m_pointerLockPermissionRequest); 267 m_pointerLockPermissionRequest = permissionRequest.get(); 268 g_object_add_weak_pointer(G_OBJECT(m_pointerLockPermissionRequest), reinterpret_cast<void**>(&m_pointerLockPermissionRequest)); 269 webkitWebViewMakePermissionRequest(m_webView, WEBKIT_PERMISSION_REQUEST(permissionRequest.get())); 257 270 } 258 271 259 272 void didLosePointerLock(WebPageProxy*) final 260 273 { 274 if (m_pointerLockPermissionRequest) { 275 webkitPointerLockPermissionRequestDidLosePointerLock(m_pointerLockPermissionRequest); 276 g_object_remove_weak_pointer(G_OBJECT(m_pointerLockPermissionRequest), reinterpret_cast<void**>(&m_pointerLockPermissionRequest)); 277 m_pointerLockPermissionRequest = nullptr; 278 } 261 279 webkitWebViewDidLosePointerLock(m_webView); 262 280 } 263 281 #endif 264 282 265 266 283 WebKitWebView* m_webView; 284 #if ENABLE(POINTER_LOCK) 285 WebKitPointerLockPermissionRequest* m_pointerLockPermissionRequest { nullptr }; 286 #endif 267 287 }; 268 288 -
trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
r252126 r252234 82 82 83 83 #if PLATFORM(GTK) 84 #include "WebKitPointerLockPermissionRequest.h" 84 85 #include "WebKitPrintOperationPrivate.h" 85 86 #include "WebKitWebInspectorPrivate.h" … … 507 508 static gboolean webkitWebViewPermissionRequest(WebKitWebView*, WebKitPermissionRequest* request) 508 509 { 510 #if ENABLE(POINTER_LOCK) 511 if (WEBKIT_IS_POINTER_LOCK_PERMISSION_REQUEST(request)) { 512 webkit_permission_request_allow(request); 513 return TRUE; 514 } 515 #endif 516 509 517 webkit_permission_request_deny(request); 510 518 return TRUE; … … 2634 2642 webkitWebViewBaseRequestPointerLock(WEBKIT_WEB_VIEW_BASE(webView)); 2635 2643 #endif 2644 } 2645 2646 void webkitWebViewDenyPointerLockRequest(WebKitWebView* webView) 2647 { 2648 getPage(webView).didDenyPointerLock(); 2636 2649 } 2637 2650 -
trunk/Source/WebKit/UIProcess/API/glib/WebKitWebViewPrivate.h
r252126 r252234 107 107 #if ENABLE(POINTER_LOCK) 108 108 void webkitWebViewRequestPointerLock(WebKitWebView*); 109 void webkitWebViewDenyPointerLockRequest(WebKitWebView*); 109 110 void webkitWebViewDidLosePointerLock(WebKitWebView*); 110 111 #endif -
trunk/Source/WebKit/UIProcess/API/gtk/WebKitAutocleanups.h
r251423 r252234 51 51 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitPermissionRequest, g_object_unref) 52 52 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitPlugin, g_object_unref) 53 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitPointerLockPermissionRequest, g_object_unref) 53 54 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitPolicyDecision, g_object_unref) 54 55 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitPrintCustomWidget, g_object_unref) -
trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt
r251181 r252234 732 732 733 733 <SECTION> 734 <FILE>WebKitPointerLockPermissionRequest</FILE> 735 WebKitPointerLockPermissionRequest 736 737 <SUBSECTION Standard> 738 WebKitPointerLockPermissionRequestClass 739 WEBKIT_TYPE_POINTER_LOCK_PERMISSION_REQUEST 740 WEBKIT_POINTER_LOCK_PERMISSION_REQUEST 741 WEBKIT_IS_POINTER_LOCK_PERMISSION_REQUEST 742 WEBKIT_POINTER_LOCK_PERMISSION_REQUEST_CLASS 743 WEBKIT_IS_POINTER_LOCK_PERMISSION_REQUEST_CLASS 744 WEBKIT_POINTER_LOCK_PERMISSION_REQUEST_GET_CLASS 745 746 <SUBSECTION Private> 747 WebKitPointerLockPermissionRequestPrivate 748 webkit_pointer_lock_permission_request_get_type 749 </SECTION> 750 751 <SECTION> 734 752 <FILE>WebKitNavigationAction</FILE> 735 753 WebKitNavigationAction -
trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0.types
r243285 r252234 43 43 webkit_geolocation_manager_get_type 44 44 webkit_geolocation_position_get_type 45 webkit_pointer_lock_permission_request_get_type -
trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
r251181 r252234 65 65 <xi:include href="xml/WebKitGeolocationManager.xml"/> 66 66 <xi:include href="xml/WebKitUserMessage.xml"/> 67 <xi:include href="xml/WebKitPointerLockPermissionRequest.xml"/> 67 68 </chapter> 68 69 -
trunk/Source/WebKit/UIProcess/API/gtk/webkit2.h
r251181 r252234 65 65 #include <webkit2/WebKitPermissionRequest.h> 66 66 #include <webkit2/WebKitPlugin.h> 67 #include <webkit2/WebKitPointerLockPermissionRequest.h> 67 68 #include <webkit2/WebKitPrintCustomWidget.h> 68 69 #include <webkit2/WebKitPrintOperation.h> -
trunk/Tools/ChangeLog
r252228 r252234 1 2019-11-08 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Add pointer lock permission request API 4 https://bugs.webkit.org/show_bug.cgi?id=203896 5 6 Reviewed by Adrian Perez de Castro. 7 8 Handle pointer lock permission requests in MiniBrowser and add a new tests case to check the new API. 9 10 * MiniBrowser/gtk/BrowserTab.c: 11 (pointerLockMessageTimeoutCallback): 12 (decidePermissionRequest): 13 (browserTabFinalize): 14 (browserTabConstructed): 15 * TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp: 16 (testWebViewPointerLockPermissionRequest): 17 (beforeAll): 18 1 19 2019-11-07 Chris Dumez <cdumez@apple.com> 2 20 -
trunk/Tools/MiniBrowser/gtk/BrowserTab.c
r250517 r252234 49 49 GtkWidget *fullScreenMessageLabel; 50 50 guint fullScreenMessageLabelId; 51 GtkWidget *pointerLockMessageLabel; 52 guint pointerLockMessageLabelId; 51 53 52 54 /* Tab Title */ … … 203 205 204 206 return TRUE; 207 } 208 209 static gboolean pointerLockMessageTimeoutCallback(BrowserTab *tab) 210 { 211 gtk_widget_hide(tab->pointerLockMessageLabel); 212 tab->pointerLockMessageLabelId = 0; 213 return FALSE; 205 214 } 206 215 … … 263 272 g_free(origin); 264 273 return FALSE; 274 } else if (WEBKIT_IS_POINTER_LOCK_PERMISSION_REQUEST(request)) { 275 const gchar *titleOrURI = webkit_web_view_get_title(tab->webView); 276 if (!titleOrURI || !titleOrURI[0]) 277 titleOrURI = webkit_web_view_get_uri(tab->webView); 278 279 char *message = g_strdup_printf("%s wants to lock the pointer. Press ESC to get the pointer back.", titleOrURI); 280 gtk_label_set_text(GTK_LABEL(tab->pointerLockMessageLabel), message); 281 g_free(message); 282 gtk_widget_show(tab->pointerLockMessageLabel); 283 284 tab->pointerLockMessageLabelId = g_timeout_add_seconds(2, (GSourceFunc)pointerLockMessageTimeoutCallback, tab); 285 g_source_set_name_by_id(tab->pointerLockMessageLabelId, "[WebKit]pointerLockMessageTimeoutCallback"); 286 return TRUE; 265 287 } else { 266 288 g_print("%s request not handled\n", G_OBJECT_TYPE_NAME(request)); … … 354 376 if (tab->fullScreenMessageLabelId) 355 377 g_source_remove(tab->fullScreenMessageLabelId); 378 if (tab->pointerLockMessageLabelId) 379 g_source_remove(tab->pointerLockMessageLabelId); 356 380 357 381 G_OBJECT_CLASS(browser_tab_parent_class)->finalize(gObject); … … 390 414 gtk_widget_set_no_show_all(tab->fullScreenMessageLabel, TRUE); 391 415 gtk_overlay_add_overlay(GTK_OVERLAY(overlay), tab->fullScreenMessageLabel); 416 417 tab->pointerLockMessageLabel = gtk_label_new(NULL); 418 gtk_widget_set_halign(tab->pointerLockMessageLabel, GTK_ALIGN_CENTER); 419 gtk_widget_set_valign(tab->pointerLockMessageLabel, GTK_ALIGN_START); 420 gtk_widget_set_no_show_all(tab->pointerLockMessageLabel, TRUE); 421 gtk_overlay_add_overlay(GTK_OVERLAY(overlay), tab->pointerLockMessageLabel); 392 422 393 423 gtk_container_add(GTK_CONTAINER(overlay), GTK_WIDGET(tab->webView)); -
trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp
r251132 r252234 219 219 test->m_mouseTargetHitTestResult = hitTestResult; 220 220 test->m_mouseTargetModifiers = modifiers; 221 g_main_loop_quit(test->m_mainLoop); 221 if (test->m_waitingForMouseTargetChange) 222 g_main_loop_quit(test->m_mainLoop); 222 223 } 223 224 … … 309 310 WebKitHitTestResult* moveMouseAndWaitUntilMouseTargetChanged(int x, int y, unsigned mouseModifiers = 0) 310 311 { 312 m_waitingForMouseTargetChange = true; 311 313 mouseMoveTo(x, y, mouseModifiers); 312 314 g_main_loop_run(m_mainLoop); 315 m_waitingForMouseTargetChange = false; 313 316 return m_mouseTargetHitTestResult.get(); 314 317 } … … 385 388 unsigned m_mouseTargetModifiers; 386 389 GUniquePtr<char> m_permissionResult; 390 bool m_waitingForMouseTargetChange { false }; 387 391 }; 388 392 … … 948 952 #endif // ENABLE(MEDIA_STREAM) 949 953 954 #if ENABLE(POINTER_LOCK) 955 static void testWebViewPointerLockPermissionRequest(UIClientTest* test, gconstpointer) 956 { 957 #if PLATFORM(GTK) 958 test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL); 959 #endif 960 961 static const char* pointerLockRequestHTML = 962 "<html>" 963 " <script>" 964 " function runTest()" 965 " {" 966 " document.onpointerlockchange = function () { document.title = \"Locked\" };" 967 " document.onpointerlockerror = function () { document.title = \"Error\" };" 968 " document.getElementById('target').requestPointerLock();" 969 " }" 970 " </script>" 971 " <body>" 972 " <input style='position:absolute; left:0; top:0; margin:0; padding:0' type='button' value='click to lock pointer' onclick='runTest()'/>" 973 " <div id='target'></div>" 974 " </body>" 975 "</html>"; 976 977 test->loadHtml(pointerLockRequestHTML, nullptr); 978 test->waitUntilLoadFinished(); 979 980 // Test denying a permission request. 981 test->m_allowPermissionRequests = false; 982 test->clickMouseButton(5, 5, 1); 983 test->waitUntilTitleChangedTo("Error"); 984 985 // Test allowing a permission request. 986 test->m_allowPermissionRequests = true; 987 test->clickMouseButton(5, 5, 1); 988 test->waitUntilTitleChangedTo("Locked"); 989 } 990 #endif 991 950 992 #if PLATFORM(GTK) 951 993 class FileChooserTest: public UIClientTest { … … 1205 1247 ColorChooserTest::add("WebKitWebView", "color-chooser-request", testWebViewColorChooserRequest); 1206 1248 #endif 1249 #if ENABLE(POINTER_LOCK) 1250 UIClientTest::add("WebKitWebView", "pointer-lock-permission-request", testWebViewPointerLockPermissionRequest); 1251 #endif 1207 1252 } 1208 1253
Note: See TracChangeset
for help on using the changeset viewer.