Changeset 264647 in webkit
- Timestamp:
- Jul 21, 2020, 1:08:18 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 23 edited
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/API/glib/InputMethodFilter.h (modified) (1 diff)
-
Source/WebKit/UIProcess/API/gtk/InputMethodFilterGtk.cpp (modified) (2 diffs)
-
Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp (modified) (3 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp (modified) (4 diffs)
-
Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp (modified) (4 diffs)
-
Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp (modified) (11 diffs)
-
Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp (modified) (2 diffs)
-
Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitFindController.cpp (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitPolicyClient.cpp (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp (modified) (5 diffs)
-
Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp (modified) (11 diffs)
-
Tools/TestWebKitAPI/Tests/WebKitGtk/TestDOMDOMWindow.cpp (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp (modified) (3 diffs)
-
Tools/TestWebKitAPI/Tests/WebKitGtk/TestInspectorServer.cpp (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp (modified) (1 diff)
-
Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.h (modified) (2 diffs)
-
Tools/TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp (modified) (5 diffs)
-
Tools/TestWebKitAPI/glib/WebKitGLib/wpe/WebViewTestWPE.cpp (modified) (1 diff)
-
Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r264637 r264647 1 2020-07-21 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Prepare unit tests for GTK4 4 https://bugs.webkit.org/show_bug.cgi?id=214251 5 6 Reviewed by Adrian Perez de Castro. 7 8 Make it possible to test input methods. 9 10 * UIProcess/API/glib/InputMethodFilter.h: 11 * UIProcess/API/gtk/InputMethodFilterGtk.cpp: 12 (WebKit::InputMethodFilter::filterKeyEvent): Added to receive the key event properties instead of the GdkEvent. 13 * UIProcess/API/gtk/WebKitWebViewBase.cpp: 14 (webkitWebViewBaseSynthesizeMouseEvent): Create a GdkEvent for right clicks since it's needed by GTK3 API. 15 (webkitWebViewBaseSynthesizeKeyEvent): Send key press and release events to the IM filter. 16 1 17 2020-07-20 Megan Gardner <megan_gardner@apple.com> 2 18 -
trunk/Source/WebKit/UIProcess/API/glib/InputMethodFilter.h
r260752 r264647 68 68 FilterResult filterKeyEvent(PlatformEventKey*); 69 69 70 #if PLATFORM(GTK) 71 FilterResult filterKeyEvent(unsigned type, unsigned keyval, unsigned keycode, unsigned modifiers); 72 #endif 73 70 74 void notifyFocusedIn(); 71 75 void notifyFocusedOut(); -
trunk/Source/WebKit/UIProcess/API/gtk/InputMethodFilterGtk.cpp
r260752 r264647 22 22 23 23 #include "WebKitInputMethodContextPrivate.h" 24 #include <WebCore/GUniquePtrGtk.h> 24 25 #include <WebCore/IntRect.h> 25 26 #include <gdk/gdk.h> … … 42 43 } 43 44 45 InputMethodFilter::FilterResult InputMethodFilter::filterKeyEvent(unsigned type, unsigned keyval, unsigned keycode, unsigned modifiers) 46 { 47 if (!isEnabled() || !m_context) 48 return { }; 49 50 #if !USE(GTK4) 51 auto* webView = webkitInputMethodContextGetWebView(m_context.get()); 52 ASSERT(webView); 53 54 GUniquePtr<GdkEvent> event(gdk_event_new(static_cast<GdkEventType>(type))); 55 event->key.window = gtk_widget_get_window(GTK_WIDGET(webView)); 56 g_object_ref(event->key.window); 57 event->key.time = GDK_CURRENT_TIME; 58 event->key.keyval = keyval; 59 event->key.hardware_keycode = keycode; 60 event->key.state = modifiers; 61 gdk_event_set_device(event.get(), gdk_seat_get_keyboard(gdk_display_get_default_seat(gtk_widget_get_display(GTK_WIDGET(webView))))); 62 return filterKeyEvent(event.get()); 63 #else 64 return { }; 65 #endif 66 } 67 44 68 } // namespace WebKit -
trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp
r263887 r264647 2546 2546 webEventType = WebEvent::MouseDown; 2547 2547 priv->inputMethodFilter.cancelComposition(); 2548 #if !USE(GTK4) 2549 if (webEventButton == WebMouseEvent::RightButton) { 2550 GUniquePtr<GdkEvent> event(gdk_event_new(GDK_BUTTON_PRESS)); 2551 event->button.window = gtk_widget_get_window(GTK_WIDGET(webViewBase)); 2552 g_object_ref(event->button.window); 2553 event->button.time = GDK_CURRENT_TIME; 2554 event->button.x = x; 2555 event->button.y = y; 2556 event->button.axes = 0; 2557 event->button.state = modifiers; 2558 event->button.button = button; 2559 event->button.device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(GTK_WIDGET(webViewBase)))); 2560 int xRoot, yRoot; 2561 gdk_window_get_root_coords(event->button.window, x, y, &xRoot, &yRoot); 2562 event->button.x_root = xRoot; 2563 event->button.y_root = yRoot; 2564 priv->contextMenuEvent = WTFMove(event); 2565 } 2566 #endif 2548 2567 gtk_widget_grab_focus(GTK_WIDGET(webViewBase)); 2549 2568 break; … … 2604 2623 2605 2624 #if !USE(GTK4) 2625 if (priv->activeContextMenuProxy && keyval == GDK_KEY_Escape) { 2626 gtk_menu_shell_deactivate(GTK_MENU_SHELL(priv->activeContextMenuProxy->gtkWidget())); 2627 return; 2628 } 2629 2606 2630 if (keyval == GDK_KEY_Menu) { 2607 webkitWebViewBasePopupMenu(GTK_WIDGET(webViewBase)); 2631 GUniquePtr<GdkEvent> event(gdk_event_new(GDK_KEY_PRESS)); 2632 event->key.window = gtk_widget_get_window(GTK_WIDGET(webViewBase)); 2633 g_object_ref(event->key.window); 2634 event->key.time = GDK_CURRENT_TIME; 2635 event->key.keyval = keyval; 2636 event->key.state = modifiers; 2637 gdk_event_set_device(event.get(), gdk_seat_get_keyboard(gdk_display_get_default_seat(gtk_widget_get_display(GTK_WIDGET(webViewBase))))); 2638 priv->contextMenuEvent = WTFMove(event); 2639 priv->pageProxy->handleContextMenuKeyEvent(); 2608 2640 return; 2609 2641 } … … 2623 2655 2624 2656 if (type != KeyEventType::Release) { 2625 priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent( 2626 WebEvent::KeyDown, 2627 PlatformKeyboardEvent::singleCharacterString(keyval), 2628 PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval), 2629 PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode), 2630 PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyval), 2631 PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval), 2632 static_cast<int>(keyval), 2633 priv->keyBindingTranslator.commandsForKeyval(keyval, modifiers), 2634 keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9, 2635 webEventModifiers)); 2657 auto filterResult = priv->inputMethodFilter.filterKeyEvent(GDK_KEY_PRESS, keyval, keycode, modifiers); 2658 if (!filterResult.handled) { 2659 priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent( 2660 WebEvent::KeyDown, 2661 filterResult.keyText.isNull() ? PlatformKeyboardEvent::singleCharacterString(keyval) : filterResult.keyText, 2662 PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval), 2663 PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode), 2664 PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyval), 2665 PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval), 2666 static_cast<int>(keyval), 2667 priv->keyBindingTranslator.commandsForKeyval(keyval, modifiers), 2668 keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9, 2669 webEventModifiers)); 2670 } 2636 2671 } 2637 2672 2638 2673 if (type != KeyEventType::Press) { 2639 priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent( 2640 WebEvent::KeyUp, 2641 PlatformKeyboardEvent::singleCharacterString(keyval), 2642 PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval), 2643 PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode), 2644 PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyval), 2645 PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval), 2646 static_cast<int>(keyval), 2647 { }, 2648 keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9, 2649 webEventModifiers)); 2674 if (!priv->inputMethodFilter.filterKeyEvent(GDK_KEY_RELEASE, keyval, keycode, modifiers).handled) { 2675 priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent( 2676 WebEvent::KeyUp, 2677 PlatformKeyboardEvent::singleCharacterString(keyval), 2678 PlatformKeyboardEvent::keyValueForGdkKeyCode(keyval), 2679 PlatformKeyboardEvent::keyCodeForHardwareKeyCode(keycode), 2680 PlatformKeyboardEvent::keyIdentifierForGdkKeyCode(keyval), 2681 PlatformKeyboardEvent::windowsKeyCodeForGdkKeyCode(keyval), 2682 static_cast<int>(keyval), 2683 { }, 2684 keyval >= GDK_KEY_KP_Space && keyval <= GDK_KEY_KP_9, 2685 webEventModifiers)); 2686 } 2650 2687 } 2651 2688 } -
trunk/Tools/ChangeLog
r264626 r264647 1 2020-07-21 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Prepare unit tests for GTK4 4 https://bugs.webkit.org/show_bug.cgi?id=214251 5 6 Reviewed by Adrian Perez de Castro. 7 8 In GTK4 there isn't GTK_WINDOW_POPUP and we can't create GdkEvents, so we need to use toplevel windows 9 everywhere and use the new internal api to synthesize events. 10 11 * TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp: 12 (testContextMenuDownloadActions): 13 (testBlobDownload): 14 * TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp: 15 * TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp: 16 (testOptionMenuSimple): 17 (testOptionMenuGroups): 18 (testOptionMenuActivate): 19 (testOptionMenuSelect): 20 * TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp: 21 (testWebViewCreateNavigationData): 22 (testWebViewJavaScriptDialogs): 23 (testWebViewOpenWindowNoDefaultSize): 24 (testWebViewMouseTarget): 25 (testWebViewGeolocationPermissionRequests): 26 (testWebViewUserMediaEnumerateDevicesPermissionCheck): 27 (testWebViewUserMediaPermissionRequests): 28 (testWebViewAudioOnlyUserMediaPermissionRequests): 29 (testWebViewPointerLockPermissionRequest): 30 (testWebViewFileChooserRequest): 31 (testWebViewColorChooserRequest): 32 * TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp: 33 (testWebExtensionInputElementIsUserEdited): 34 (testInstallMissingPluginsPermissionRequest): 35 * TestWebKitAPI/Tests/WebKitGLib/TestWebKitFindController.cpp: 36 (testFindControllerHide): 37 * TestWebKitAPI/Tests/WebKitGLib/TestWebKitPolicyClient.cpp: 38 (testAutoplayPolicy): 39 * TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp: 40 (testWebViewFullScreen): 41 (testWebViewSubmitForm): 42 (testWebViewSnapshot): 43 (testWebViewIsPlayingAudio): 44 (testWebViewPreferredSize): 45 * TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp: 46 (testContextMenuDefaultMenu): 47 (testPopupEventSignal): 48 (testContextMenuKey): 49 (testContextMenuPopulateMenu): 50 (testContextMenuCustomMenu): 51 (testContextMenuSubMenu): 52 (testContextMenuDismissed): 53 (testContextMenuWebExtensionMenu): 54 (testContextMenuWebExtensionNode): 55 (testContextMenuLiveStream): 56 (beforeAll): 57 * TestWebKitAPI/Tests/WebKitGtk/TestDOMDOMWindow.cpp: 58 (signalsNotifyCallback): 59 * TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp: 60 (testInspectorDefault): 61 (testInspectorManualAttachDetach): 62 (testInspectorCustomContainerDestroyed): 63 * TestWebKitAPI/Tests/WebKitGtk/TestInspectorServer.cpp: 64 (testInspectorServerPageList): 65 * TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp: 66 (testPrintCustomWidget): 67 * TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp: 68 * TestWebKitAPI/glib/WebKitGLib/WebViewTest.h: 69 * TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp: 70 (WebViewTest::quitMainLoopAfterProcessingPendingEvents): 71 (WebViewTest::showInWindow): 72 (WebViewTest::mouseMoveTo): 73 (WebViewTest::clickMouseButton): 74 (WebViewTest::keyStroke): 75 * TestWebKitAPI/glib/WebKitGLib/wpe/WebViewTestWPE.cpp: 76 (WebViewTest::showInWindow): 77 * TestWebKitAPI/gtk/PlatformWebViewGtk.cpp: 78 (TestWebKitAPI::toWebKitGLibAPI): 79 (TestWebKitAPI::PlatformWebView::simulateSpacebarKeyPress): 80 (TestWebKitAPI::PlatformWebView::simulateAltKeyPress): 81 (TestWebKitAPI::PlatformWebView::simulateRightClick): 82 (TestWebKitAPI::PlatformWebView::simulateMouseMove): 83 1 84 2020-07-20 Aakash Jain <aakash_jain@apple.com> 2 85 -
trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp
r258698 r264647 560 560 } 561 561 562 #if PLATFORM(GTK) 563 static gboolean contextMenuCallback(WebKitWebView* webView, WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult* hitTestResult, WebViewDownloadTest* test) 564 { 565 g_assert_true(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult)); 566 GList* items = webkit_context_menu_get_items(contextMenu); 567 for (GList* l = items; l; l = g_list_next(l)) { 568 g_assert_true(WEBKIT_IS_CONTEXT_MENU_ITEM(l->data)); 569 auto* item = WEBKIT_CONTEXT_MENU_ITEM(l->data); 570 if (webkit_context_menu_item_get_stock_action(item) == WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_LINK_TO_DISK) { 571 test->m_contextMenuDownloadItem = item; 572 break; 573 } 574 } 575 test->quitMainLoop(); 576 return FALSE; 577 } 578 579 WebKitContextMenuItem* showContextMenuAndGetDownloadItem(int x, int y) 580 { 581 m_contextMenuDownloadItem = nullptr; 582 auto id = g_signal_connect(m_webView, "context-menu", G_CALLBACK(contextMenuCallback), this); 583 RunLoop::main().dispatch([this, x, y] { 584 clickMouseButton(x, y, 3); 585 }); 586 g_main_loop_run(m_mainLoop); 587 g_signal_handler_disconnect(m_webView, id); 588 return m_contextMenuDownloadItem.get(); 589 } 590 #endif 591 562 592 GRefPtr<WebKitDownload> m_download; 563 593 bool m_shouldDelayDecideDestination { false }; 594 #if PLATFORM(GTK) 595 GRefPtr<WebKitContextMenuItem> m_contextMenuDownloadItem; 596 #endif 564 597 }; 565 598 … … 690 723 691 724 #if PLATFORM(GTK) 692 static gboolean contextMenuCallback(WebKitWebView* webView, WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult* hitTestResult, WebViewDownloadTest* test)693 {694 g_assert_true(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult));695 g_assert_true(webkit_hit_test_result_context_is_link(hitTestResult));696 GList* items = webkit_context_menu_get_items(contextMenu);697 GRefPtr<WebKitContextMenuItem> contextMenuItem;698 for (GList* l = items; l; l = g_list_next(l)) {699 g_assert_true(WEBKIT_IS_CONTEXT_MENU_ITEM(l->data));700 auto* item = WEBKIT_CONTEXT_MENU_ITEM(l->data);701 if (webkit_context_menu_item_get_stock_action(item) == WEBKIT_CONTEXT_MENU_ACTION_DOWNLOAD_LINK_TO_DISK) {702 contextMenuItem = item;703 break;704 }705 }706 g_assert_nonnull(contextMenuItem.get());707 webkit_context_menu_remove_all(contextMenu);708 webkit_context_menu_append(contextMenu, contextMenuItem.get());709 test->quitMainLoop();710 return FALSE;711 }712 713 725 static void testContextMenuDownloadActions(WebViewDownloadTest* test, gconstpointer) 714 726 { 715 test->showInWindow AndWaitUntilMapped();727 test->showInWindow(); 716 728 717 729 static const char* linkHTMLFormat = "<html><body><a style='position:absolute; left:1; top:1' href='%s'>Download Me</a></body></html>"; … … 720 732 test->waitUntilLoadFinished(); 721 733 722 g_signal_connect(test->m_webView, "context-menu", G_CALLBACK(contextMenuCallback), test); 723 g_idle_add([](gpointer userData) -> gboolean { 724 auto* test = static_cast<WebViewDownloadTest*>(userData); 725 test->clickMouseButton(1, 1, 3); 726 return FALSE; 727 }, test); 728 g_main_loop_run(test->m_mainLoop); 729 730 g_idle_add([](gpointer userData) -> gboolean { 731 auto* test = static_cast<WebViewDownloadTest*>(userData); 732 // Select and activate the context menu action. 733 test->keyStroke(GDK_KEY_Down); 734 test->keyStroke(GDK_KEY_Return); 735 return FALSE; 736 }, test); 734 auto* item = test->showContextMenuAndGetDownloadItem(1, 1); 735 g_assert(WEBKIT_IS_CONTEXT_MENU_ITEM(item)); 736 g_action_activate(webkit_context_menu_item_get_gaction(item), nullptr); 737 737 test->waitUntilDownloadStarted(); 738 738 … … 756 756 static void testBlobDownload(WebViewDownloadTest* test, gconstpointer) 757 757 { 758 test->showInWindow AndWaitUntilMapped();758 test->showInWindow(); 759 759 760 760 static const char* linkBlobHTML = -
trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp
r258131 r264647 251 251 : m_context(adoptGRef(static_cast<WebKitInputMethodContextMock*>(g_object_new(webkit_input_method_context_mock_get_type(), nullptr)))) 252 252 { 253 WebViewTest::showInWindow(); 253 254 #if PLATFORM(GTK) 254 WebViewTest::showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);255 255 auto* defaultContext = webkit_web_view_get_input_method_context(m_webView); 256 256 g_assert_true(WEBKIT_IS_INPUT_METHOD_CONTEXT(defaultContext)); 257 257 assertObjectIsDeletedWhenTestFinishes(G_OBJECT(defaultContext)); 258 258 #elif PLATFORM(WPE) 259 WebViewTest::showInWindow();260 259 g_assert_null(webkit_web_view_get_input_method_context(m_webView)); 261 260 #endif -
trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp
r254828 r264647 123 123 " <option disabled>Baz</option>" 124 124 " </select></body></html>"; 125 test->showInWindow AndWaitUntilMapped();125 test->showInWindow(); 126 126 test->loadHtml(html, nullptr); 127 127 test->waitUntilLoadFinished(); … … 172 172 " <option>Tail</option>" 173 173 " </select></body></html>"; 174 test->showInWindow AndWaitUntilMapped();174 test->showInWindow(); 175 175 test->loadHtml(html, nullptr); 176 176 test->waitUntilLoadFinished(); … … 246 246 " <option>Baz</option>" 247 247 " </select></body></html>"; 248 test->showInWindow AndWaitUntilMapped();248 test->showInWindow(); 249 249 test->loadHtml(html, nullptr); 250 250 test->waitUntilLoadFinished(); … … 276 276 " <option>Baz</option>" 277 277 " </select></body></html>"; 278 test->showInWindow AndWaitUntilMapped();278 test->showInWindow(); 279 279 test->loadHtml(html, nullptr); 280 280 test->waitUntilLoadFinished(); -
trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp
r261473 r264647 482 482 static void testWebViewCreateNavigationData(CreateNavigationDataTest* test, gconstpointer) 483 483 { 484 #if PLATFORM(GTK) 485 test->showInWindowAndWaitUntilMapped(); 486 #endif 487 484 test->showInWindow(); 488 485 test->loadHTML( 489 486 "<html><body>" … … 591 588 static void testWebViewJavaScriptDialogs(UIClientTest* test, gconstpointer) 592 589 { 593 #if PLATFORM(GTK) 594 test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL); 595 #endif 590 test->showInWindow(); 596 591 597 592 static const char* htmlOnLoadFormat = "<html><body onLoad=\"%s\"></body></html>"; … … 722 717 // on the create signal, then new windows open with the size of the previous window. 723 718 cairo_rectangle_int_t expectedGeometry = { 0, 0, 527, 671 }; 724 test->showInWindow AndWaitUntilMapped(GTK_WINDOW_TOPLEVEL,expectedGeometry.width, expectedGeometry.height);719 test->showInWindow(expectedGeometry.width, expectedGeometry.height); 725 720 test->setExpectedWindowProperties(UIClientTest::WindowProperties(&expectedGeometry, false, false, false, false, false, true, false)); 726 721 test->loadHtml("<html><body onLoad=\"window.open('', '', 'left=0,top=0,location=no,menubar=no,status=no,toolbar=no,scrollbars=no').close();\"></body></html>", nullptr); … … 732 727 static void testWebViewMouseTarget(UIClientTest* test, gconstpointer) 733 728 { 734 test->showInWindow AndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);729 test->showInWindow(); 735 730 736 731 const char* linksHoveredHTML = … … 851 846 // Make warnings non-fatal for this test to make it pass. 852 847 Test::removeLogFatalFlag(G_LOG_LEVEL_WARNING); 853 #if PLATFORM(GTK) 854 test->showInWindowAndWaitUntilMapped(); 855 #endif 848 test->showInWindow(); 856 849 static const char* geolocationRequestHTML = 857 850 "<html>" … … 899 892 webkit_settings_set_enable_mock_capture_devices(settings, TRUE); 900 893 901 #if PLATFORM(GTK) 902 test->showInWindowAndWaitUntilMapped(); 903 #endif 894 test->showInWindow(); 904 895 static const char* userMediaRequestHTML = 905 896 "<html>" … … 944 935 webkitSettingsSetMediaCaptureRequiresSecureConnection(settings, FALSE); 945 936 946 #if PLATFORM(GTK) 947 test->showInWindowAndWaitUntilMapped(); 948 #endif 937 test->showInWindow(); 949 938 static const char* userMediaRequestHTML = "<html>" 950 939 " <script>" … … 986 975 webkitSettingsSetMediaCaptureRequiresSecureConnection(settings, FALSE); 987 976 988 #if PLATFORM(GTK) 989 test->showInWindowAndWaitUntilMapped(); 990 #endif 977 test->showInWindow(); 991 978 static const char* userMediaRequestHTML = "<html>" 992 979 " <script>" … … 1019 1006 static void testWebViewPointerLockPermissionRequest(UIClientTest* test, gconstpointer) 1020 1007 { 1021 #if PLATFORM(GTK) 1022 test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL); 1023 #endif 1024 1008 test->showInWindow(); 1025 1009 static const char* pointerLockRequestHTML = 1026 1010 "<html>" … … 1090 1074 static void testWebViewFileChooserRequest(FileChooserTest* test, gconstpointer) 1091 1075 { 1092 #if PLATFORM(GTK) 1093 test->showInWindowAndWaitUntilMapped(); 1094 #endif 1076 test->showInWindow(); 1095 1077 static const char* fileChooserHTMLFormat = "<html><body><input style='position:absolute;left:0;top:0;margin:0;padding:0' type='file' %s/></body></html>"; 1096 1078 … … 1241 1223 { 1242 1224 static const char* colorChooserHTMLFormat = "<html><body><input style='position:absolute;left:1;top:1;margin:0;padding:0;width:45;height:25' type='color' %s/></body></html>"; 1243 test->showInWindow AndWaitUntilMapped();1225 test->showInWindow(); 1244 1226 1245 1227 GUniquePtr<char> defaultColorHTML(g_strdup_printf(colorChooserHTMLFormat, "")); -
trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp
r251181 r264647 74 74 static void testWebExtensionInputElementIsUserEdited(WebViewTest* test, gconstpointer) 75 75 { 76 test->showInWindow AndWaitUntilMapped();76 test->showInWindow(); 77 77 test->loadHtml("<html><body id='body'><input id='input'></input><textarea id='textarea'></textarea></body></html>", nullptr); 78 78 test->waitUntilLoadFinished(); … … 263 263 nullptr, G_DBUS_CALL_FLAGS_NONE, -1, nullptr, nullptr)); 264 264 265 test->showInWindow AndWaitUntilMapped();265 test->showInWindow(); 266 266 267 267 gulong permissionRequestSignalID = g_signal_connect(test->m_webView, "permission-request", G_CALLBACK(permissionRequestCallback), test); -
trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitFindController.cpp
r239772 r264647 266 266 test->waitUntilLoadFinished(); 267 267 268 test->showInWindow AndWaitUntilMapped();268 test->showInWindow(); 269 269 270 270 cairo_surface_t* originalSurface = cairo_surface_reference( -
trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitPolicyClient.cpp
r263095 r264647 312 312 static void testAutoplayPolicy(PolicyClientTest* test, gconstpointer) 313 313 { 314 #if PLATFORM(GTK)315 314 // The web view must be realized for the video to start playback. 316 test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL); 317 #endif 315 test->showInWindow(); 318 316 319 317 test->m_policyDecisionTypeFilter = WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION; -
trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp
r263095 r264647 465 465 static void testWebViewFullScreen(FullScreenClientTest* test, gconstpointer) 466 466 { 467 #if PLATFORM(GTK) 468 test->showInWindowAndWaitUntilMapped(); 469 #endif 467 test->showInWindow(); 470 468 test->loadHtml("<html><body>FullScreen test</body></html>", 0); 471 469 test->waitUntilLoadFinished(); … … 571 569 static void testWebViewSubmitForm(FormClientTest* test, gconstpointer) 572 570 { 573 test->showInWindow AndWaitUntilMapped();571 test->showInWindow(); 574 572 575 573 const char* formHTML = … … 822 820 823 821 // Show the WebView in a popup widow of 50x50 and try again with WEBKIT_SNAPSHOT_REGION_VISIBLE. 824 test->showInWindow AndWaitUntilMapped(GTK_WINDOW_POPUP,50, 50);822 test->showInWindow(50, 50); 825 823 surface1 = cairo_surface_reference(test->getSnapshotAndWaitUntilReady(WEBKIT_SNAPSHOT_REGION_VISIBLE, WEBKIT_SNAPSHOT_OPTIONS_NONE)); 826 824 g_assert_nonnull(surface1); … … 1107 1105 static void testWebViewIsPlayingAudio(IsPlayingAudioWebViewTest* test, gconstpointer) 1108 1106 { 1109 #if PLATFORM(GTK)1110 1107 // The web view must be realized for the video to start playback and 1111 1108 // trigger changes in WebKitWebView::is-playing-audio. 1112 test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL); 1113 #endif 1109 test->showInWindow(); 1114 1110 1115 1111 // Initially, web views should always report no audio being played. … … 1197 1193 test->loadHtml("<html style='width: 325px; height: 615px'></html>", nullptr); 1198 1194 test->waitUntilLoadFinished(); 1199 test->showInWindow AndWaitUntilMapped();1195 test->showInWindow(); 1200 1196 GtkRequisition minimunSize, naturalSize; 1201 1197 gtk_widget_get_preferred_size(GTK_WIDGET(test->m_webView), &minimunSize, &naturalSize); -
trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp
r261800 r264647 531 531 static void testContextMenuDefaultMenu(ContextMenuDefaultTest* test, gconstpointer) 532 532 { 533 test->showInWindowAndWaitUntilMapped(); 534 533 test->showInWindow(); 535 534 prepareContextMenuTestView(test); 536 535 … … 579 578 static void testPopupEventSignal(ContextMenuDefaultTest* test, gconstpointer) 580 579 { 581 test->showInWindowAndWaitUntilMapped(); 582 580 test->showInWindow(); 583 581 prepareContextMenuTestView(test); 584 582 … … 589 587 static void testContextMenuKey(ContextMenuDefaultTest* test, gconstpointer) 590 588 { 591 test->showInWindowAndWaitUntilMapped(); 592 589 test->showInWindow(); 593 590 prepareContextMenuTestView(test); 594 591 … … 747 744 static void testContextMenuPopulateMenu(ContextMenuCustomTest* test, gconstpointer) 748 745 { 749 test->showInWindowAndWaitUntilMapped(); 750 746 test->showInWindow(); 751 747 test->loadHtml("<html><body>WebKitGTK Context menu tests</body></html>", "file:///"); 752 748 test->waitUntilLoadFinished(); … … 870 866 static void testContextMenuCustomMenu(ContextMenuCustomFullTest* test, gconstpointer) 871 867 { 872 test->showInWindowAndWaitUntilMapped(); 873 868 test->showInWindow(); 874 869 test->loadHtml("<html><body>WebKitGTK Context menu tests</body></html>", "file:///"); 875 870 test->waitUntilLoadFinished(); 876 871 877 test->showContextMenuAndWaitUntilFinished();878 }879 880 class ContextMenuDisabledTest: public ContextMenuTest {881 public:882 MAKE_GLIB_TEST_FIXTURE(ContextMenuDisabledTest);883 884 enum DisableMode {885 IgnoreClicks,886 IgnoreDefaultMenu887 };888 889 static gboolean buttonPressEventCallback(GtkWidget*, GdkEvent* event, ContextMenuDisabledTest* test)890 {891 if (event->button.button != 3)892 return FALSE;893 return test->rightButtonPressed();894 }895 896 ContextMenuDisabledTest()897 : m_disableMode(IgnoreClicks)898 {899 g_signal_connect(m_webView, "button-press-event", G_CALLBACK(buttonPressEventCallback), this);900 }901 902 bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult*)903 {904 if (m_disableMode == IgnoreClicks)905 g_assert_not_reached();906 else907 quitMainLoop();908 909 return true;910 }911 912 bool rightButtonPressed()913 {914 if (m_disableMode == IgnoreClicks) {915 quitMainLoopAfterProcessingPendingEvents();916 return true;917 }918 return false;919 }920 921 DisableMode m_disableMode;922 };923 924 static void testContextMenuDisableMenu(ContextMenuDisabledTest* test, gconstpointer)925 {926 test->showInWindowAndWaitUntilMapped();927 928 test->loadHtml("<html><body>WebKitGTK Context menu tests</body></html>", "file:///");929 test->waitUntilLoadFinished();930 931 test->m_disableMode = ContextMenuDisabledTest::IgnoreDefaultMenu;932 test->showContextMenuAndWaitUntilFinished();933 934 test->m_disableMode = ContextMenuDisabledTest::IgnoreClicks;935 872 test->showContextMenuAndWaitUntilFinished(); 936 873 } … … 977 914 static void testContextMenuSubMenu(ContextMenuSubmenuTest* test, gconstpointer) 978 915 { 979 test->showInWindowAndWaitUntilMapped(); 980 916 test->showInWindow(); 981 917 test->loadHtml("<html><body>WebKitGTK Context menu tests</body></html>", "file:///"); 982 918 test->waitUntilLoadFinished(); … … 1018 954 static void testContextMenuDismissed(ContextMenuDismissedTest* test, gconstpointer) 1019 955 { 1020 test->showInWindowAndWaitUntilMapped(); 1021 956 test->showInWindow(); 1022 957 test->loadHtml("<html><body>WebKitGTK Context menu tests</body></html>", "file:///"); 1023 958 test->waitUntilLoadFinished(); … … 1068 1003 static void testContextMenuWebExtensionMenu(ContextMenuWebExtensionTest* test, gconstpointer) 1069 1004 { 1070 test->showInWindow AndWaitUntilMapped();1005 test->showInWindow(); 1071 1006 test->loadHtml("<html><body>WebKitGTK Context menu tests<br>" 1072 1007 "<a style='position:absolute; left:1; top:10' href='http://www.webkitgtk.org'>WebKitGTK Website</a></body></html>", … … 1158 1093 static void testContextMenuWebExtensionNode(ContextMenuWebExtensionNodeTest* test, gconstpointer) 1159 1094 { 1160 test->showInWindow AndWaitUntilMapped();1095 test->showInWindow(); 1161 1096 test->loadHtml("<html><body><p style='position:absolute; left:1; top:1'>WebKitGTK Context menu tests</p><br>" 1162 1097 "<a style='position:absolute; left:1; top:100' href='http://www.webkitgtk.org'>WebKitGTK Website</a></body></html>", … … 1228 1163 static void testContextMenuLiveStream(ContextMenuDefaultTest* test, gconstpointer) 1229 1164 { 1230 test->showInWindowAndWaitUntilMapped(); 1231 1165 test->showInWindow(); 1232 1166 test->loadURI(kServer->getURIForPath("/live-stream").data()); 1233 1167 test->waitUntilLoadFinished(); … … 1248 1182 ContextMenuCustomTest::add("WebKitWebView", "populate-menu", testContextMenuPopulateMenu); 1249 1183 ContextMenuCustomFullTest::add("WebKitWebView", "custom-menu", testContextMenuCustomMenu); 1250 ContextMenuDisabledTest::add("WebKitWebView", "disable-menu", testContextMenuDisableMenu);1251 1184 ContextMenuSubmenuTest::add("WebKitWebView", "submenu", testContextMenuSubMenu); 1252 1185 ContextMenuDismissedTest::add("WebKitWebView", "menu-dismissed", testContextMenuDismissed); -
trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestDOMDOMWindow.cpp
r239772 r264647 48 48 if (g_str_equal(key, "loaded")) { 49 49 status.loaded = TRUE; 50 status.test->showInWindow AndWaitUntilMapped();50 status.test->showInWindow(); 51 51 52 52 // Click in a known location where the text is -
trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp
r246790 r264647 168 168 static void testInspectorDefault(InspectorTest* test, gconstpointer) 169 169 { 170 test->showInWindow AndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);170 test->showInWindow(); 171 171 test->resizeView(200, 200); 172 172 test->loadHtml("<html><body><p>WebKitGTK Inspector test</p></body></html>", 0); … … 299 299 static void testInspectorManualAttachDetach(CustomInspectorTest* test, gconstpointer) 300 300 { 301 test->showInWindow AndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);301 test->showInWindow(); 302 302 test->resizeView(200, 200); 303 303 test->loadHtml("<html><body><p>WebKitGTK Inspector test</p></body></html>", 0); … … 341 341 static void testInspectorCustomContainerDestroyed(CustomInspectorTest* test, gconstpointer) 342 342 { 343 test->showInWindow AndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);343 test->showInWindow(); 344 344 test->resizeView(200, 200); 345 345 test->loadHtml("<html><body><p>WebKitGTK Inspector test</p></body></html>", 0); -
trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestInspectorServer.cpp
r264390 r264647 139 139 GUniqueOutPtr<GError> error; 140 140 141 test->showInWindow AndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);141 test->showInWindow(); 142 142 g_assert_true(test->getPageList()); 143 143 -
trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp
r258698 r264647 422 422 static void testPrintCustomWidget(PrintCustomWidgetTest* test, gconstpointer) 423 423 { 424 test->showInWindowAndWaitUntilMapped(GTK_WINDOW_TOPLEVEL, 0, 0); 425 424 test->showInWindow(); 426 425 test->loadHtml("<html><body>Text</body></html>", 0); 427 426 test->waitUntilLoadFinished(); -
trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp
r261855 r264647 35 35 , m_editorState(nullptr) 36 36 { 37 showInWindow AndWaitUntilMapped(GTK_WINDOW_TOPLEVEL);37 showInWindow(); 38 38 loadURI("about:blank"); 39 39 waitUntilLoadFinished(); -
trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.h
r263095 r264647 66 66 void keyStroke(unsigned keyVal, unsigned keyModifiers = 0); 67 67 68 void showInWindow(int width = 0, int height = 0); 69 68 70 #if PLATFORM(GTK) 69 void showInWindow(GtkWindowType = GTK_WINDOW_POPUP);70 void showInWindowAndWaitUntilMapped(GtkWindowType = GTK_WINDOW_POPUP, int width = 0, int height = 0);71 71 void emitPopupMenuSignal(); 72 #endif73 74 #if PLATFORM(WPE)75 void showInWindowAndWaitUntilMapped() { showInWindow(); };76 void showInWindow();77 72 #endif 78 73 … … 120 115 GtkWidget* m_parentWindow { nullptr }; 121 116 #endif 122 123 private:124 #if PLATFORM(GTK)125 void doMouseButtonEvent(GdkEventType, int, int, unsigned, unsigned);126 #endif127 117 }; -
trunk/Tools/TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp
r260255 r264647 22 22 #include "WebViewTest.h" 23 23 24 #include "WebKitWebViewBaseInternal.h" 24 25 #include <WebCore/GUniquePtrGtk.h> 25 26 #include <WebCore/GtkVersioning.h> … … 41 42 void WebViewTest::quitMainLoopAfterProcessingPendingEvents() 42 43 { 43 while (g tk_events_pending())44 g tk_main_iteration();44 while (g_main_context_pending(nullptr)) 45 g_main_context_iteration(nullptr, TRUE); 45 46 quitMainLoop(); 46 47 } … … 62 63 } 63 64 64 static gboolean parentWindowMapped(GtkWidget* widget, GdkEvent*, WebViewTest* test) 65 { 66 g_signal_handlers_disconnect_by_func(widget, reinterpret_cast<void*>(parentWindowMapped), test); 67 g_main_loop_quit(test->m_mainLoop); 68 69 return FALSE; 70 } 71 72 void WebViewTest::showInWindow(GtkWindowType windowType) 65 void WebViewTest::showInWindow(int width, int height) 73 66 { 74 67 g_assert_null(m_parentWindow); 75 m_parentWindow = gtk_window_new(windowType); 68 m_parentWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); 69 if (width && height) 70 gtk_window_set_default_size(GTK_WINDOW(m_parentWindow), width, height); 76 71 gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView)); 77 72 gtk_widget_show(GTK_WIDGET(m_webView)); 78 73 gtk_widget_show(m_parentWindow); 79 }80 74 81 void WebViewTest::showInWindowAndWaitUntilMapped(GtkWindowType windowType, int width, int height) 82 { 83 g_assert_null(m_parentWindow); 84 m_parentWindow = gtk_window_new(windowType); 85 if (width && height) 86 gtk_window_resize(GTK_WINDOW(m_parentWindow), width, height); 87 gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView)); 88 gtk_widget_show(GTK_WIDGET(m_webView)); 89 90 g_signal_connect(m_parentWindow, "map-event", G_CALLBACK(parentWindowMapped), this); 91 gtk_widget_show(m_parentWindow); 92 g_main_loop_run(m_mainLoop); 75 while (g_main_context_pending(nullptr)) 76 g_main_context_iteration(nullptr, TRUE); 93 77 } 94 78 … … 96 80 { 97 81 g_assert_nonnull(m_parentWindow); 98 GtkWidget* viewWidget = GTK_WIDGET(m_webView); 99 g_assert_true(gtk_widget_get_realized(viewWidget)); 100 101 GUniquePtr<GdkEvent> event(gdk_event_new(GDK_MOTION_NOTIFY)); 102 event->motion.x = x; 103 event->motion.y = y; 104 105 event->motion.time = GDK_CURRENT_TIME; 106 event->motion.window = gtk_widget_get_window(viewWidget); 107 g_object_ref(event->motion.window); 108 event->motion.device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(viewWidget))); 109 event->motion.state = mouseModifiers; 110 event->motion.axes = 0; 111 112 int xRoot, yRoot; 113 gdk_window_get_root_coords(gtk_widget_get_window(viewWidget), x, y, &xRoot, &yRoot); 114 event->motion.x_root = xRoot; 115 event->motion.y_root = yRoot; 116 gtk_main_do_event(event.get()); 82 webkitWebViewBaseSynthesizeMouseEvent(WEBKIT_WEB_VIEW_BASE(m_webView), MouseEventType::Motion, 0, 0, x, y, mouseModifiers, 0); 117 83 } 118 84 119 85 void WebViewTest::clickMouseButton(int x, int y, unsigned button, unsigned mouseModifiers) 120 86 { 121 doMouseButtonEvent(GDK_BUTTON_PRESS, x, y, button, mouseModifiers);122 doMouseButtonEvent(GDK_BUTTON_RELEASE, x, y, button, mouseModifiers);87 webkitWebViewBaseSynthesizeMouseEvent(WEBKIT_WEB_VIEW_BASE(m_webView), MouseEventType::Press, button, 1 << (8 + button - 1), x, y, mouseModifiers, 1); 88 webkitWebViewBaseSynthesizeMouseEvent(WEBKIT_WEB_VIEW_BASE(m_webView), MouseEventType::Release, button, 0, x, y, mouseModifiers, 0); 123 89 } 124 90 … … 135 101 { 136 102 g_assert_nonnull(m_parentWindow); 137 GtkWidget* viewWidget = GTK_WIDGET(m_webView); 138 g_assert_true(gtk_widget_get_realized(viewWidget)); 139 140 GUniquePtr<GdkEvent> event(gdk_event_new(GDK_KEY_PRESS)); 141 event->key.keyval = keyVal; 142 143 event->key.time = GDK_CURRENT_TIME; 144 event->key.window = gtk_widget_get_window(viewWidget); 145 g_object_ref(event->key.window); 146 GdkDisplay* display = gtk_widget_get_display(viewWidget); 147 gdk_event_set_device(event.get(), gdk_seat_get_pointer(gdk_display_get_default_seat(display))); 148 event->key.state = keyModifiers; 149 150 // When synthesizing an event, an invalid hardware_keycode value can cause it to be badly processed by GTK+. 151 GUniqueOutPtr<GdkKeymapKey> keys; 152 int keysCount; 153 if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_for_display(display), keyVal, &keys.outPtr(), &keysCount) && keysCount) 154 event->key.hardware_keycode = keys.get()[0].keycode; 155 156 gtk_main_do_event(event.get()); 157 event->key.type = GDK_KEY_RELEASE; 158 gtk_main_do_event(event.get()); 103 webkitWebViewBaseSynthesizeKeyEvent(WEBKIT_WEB_VIEW_BASE(m_webView), KeyEventType::Insert, keyVal, keyModifiers, ShouldTranslateKeyboardState::No); 159 104 } 160 161 void WebViewTest::doMouseButtonEvent(GdkEventType eventType, int x, int y, unsigned button, unsigned mouseModifiers)162 {163 g_assert_nonnull(m_parentWindow);164 GtkWidget* viewWidget = GTK_WIDGET(m_webView);165 g_assert_true(gtk_widget_get_realized(viewWidget));166 167 GUniquePtr<GdkEvent> event(gdk_event_new(eventType));168 event->button.window = gtk_widget_get_window(viewWidget);169 g_object_ref(event->button.window);170 171 event->button.time = GDK_CURRENT_TIME;172 event->button.x = x;173 event->button.y = y;174 event->button.axes = 0;175 event->button.state = mouseModifiers;176 event->button.button = button;177 178 event->button.device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(viewWidget)));179 180 int xRoot, yRoot;181 gdk_window_get_root_coords(gtk_widget_get_window(viewWidget), x, y, &xRoot, &yRoot);182 event->button.x_root = xRoot;183 event->button.y_root = yRoot;184 gtk_main_do_event(event.get());185 } -
trunk/Tools/TestWebKitAPI/glib/WebKitGLib/wpe/WebViewTestWPE.cpp
r253749 r264647 42 42 } 43 43 44 void WebViewTest::showInWindow( )44 void WebViewTest::showInWindow(int, int) 45 45 { 46 46 auto* backend = webkit_web_view_backend_get_wpe_backend(webkit_web_view_get_backend(m_webView)); -
trunk/Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp
r260255 r264647 27 27 #include "PlatformWebView.h" 28 28 29 #include "WebKitWebViewBaseInternal.h" 29 30 #include <WebCore/GUniquePtrGtk.h> 30 31 #include <WebCore/GtkVersioning.h> … … 84 85 } 85 86 86 static void doKeyStroke(GtkWidget* viewWidget, unsigned int keyVal)87 static inline WebKitWebViewBase* toWebKitGLibAPI(PlatformWKView view) 87 88 { 88 GUniquePtr<GdkEvent> event(gdk_event_new(GDK_KEY_PRESS)); 89 event->key.keyval = keyVal; 90 event->key.time = GDK_CURRENT_TIME; 91 event->key.state = 0; 92 event->key.window = gtk_widget_get_window(viewWidget); 93 g_object_ref(event->key.window); 94 GdkDisplay* display = gtk_widget_get_display(viewWidget); 95 gdk_event_set_device(event.get(), gdk_seat_get_pointer(gdk_display_get_default_seat(display))); 96 97 // When synthesizing an event, an invalid hardware_keycode value can cause it to be badly processed by GTK+. 98 GUniqueOutPtr<GdkKeymapKey> keys; 99 int keysCount; 100 if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_for_display(display), keyVal, &keys.outPtr(), &keysCount) && keysCount) 101 event->key.hardware_keycode = keys.get()[0].keycode; 102 103 gtk_main_do_event(event.get()); 104 event->key.type = GDK_KEY_RELEASE; 105 gtk_main_do_event(event.get()); 89 return const_cast<WebKitWebViewBase*>(reinterpret_cast<const WebKitWebViewBase*>(view)); 106 90 } 107 91 … … 111 95 if (!gtk_widget_get_realized(viewWidget)) 112 96 gtk_widget_show(m_window); 113 doKeyStroke(viewWidget, GDK_KEY_KP_Space);97 webkitWebViewBaseSynthesizeKeyEvent(toWebKitGLibAPI(m_view), KeyEventType::Insert, GDK_KEY_KP_Space, 0, ShouldTranslateKeyboardState::No); 114 98 } 115 99 … … 119 103 if (!gtk_widget_get_realized(viewWidget)) 120 104 gtk_widget_show(m_window); 121 doKeyStroke(viewWidget, GDK_KEY_Alt_L); 122 } 123 124 static void doMouseButtonEvent(GtkWidget* viewWidget, GdkEventType eventType, int x, int y, unsigned int button) 125 { 126 GUniquePtr<GdkEvent> event(gdk_event_new(eventType)); 127 event->button.x = x; 128 event->button.y = y; 129 event->button.button = button; 130 event->button.time = GDK_CURRENT_TIME; 131 event->button.axes = 0; 132 event->button.state = 0; 133 event->button.window = gtk_widget_get_window(viewWidget); 134 g_object_ref(event->button.window); 135 event->button.device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(viewWidget))); 136 137 int xRoot, yRoot; 138 gdk_window_get_root_coords(gtk_widget_get_window(viewWidget), x, y, &xRoot, &yRoot); 139 event->button.x_root = xRoot; 140 event->button.y_root = yRoot; 141 gtk_main_do_event(event.get()); 105 webkitWebViewBaseSynthesizeKeyEvent(toWebKitGLibAPI(m_view), KeyEventType::Insert, GDK_KEY_Alt_L, 0, ShouldTranslateKeyboardState::No); 142 106 } 143 107 … … 147 111 if (!gtk_widget_get_realized(viewWidget)) 148 112 gtk_widget_show(m_window); 149 doMouseButtonEvent(viewWidget, GDK_BUTTON_PRESS, x, y, 3);150 doMouseButtonEvent(viewWidget, GDK_BUTTON_RELEASE, x, y, 3);113 webkitWebViewBaseSynthesizeMouseEvent(toWebKitGLibAPI(m_view), MouseEventType::Press, 3, 0, x, y, 0, 1); 114 webkitWebViewBaseSynthesizeMouseEvent(toWebKitGLibAPI(m_view), MouseEventType::Release, 3, 0, x, y, 0, 0); 151 115 } 152 116 153 117 void PlatformWebView::simulateMouseMove(unsigned x, unsigned y, WKEventModifiers) 154 118 { 155 GUniquePtr<GdkEvent> event(gdk_event_new(GDK_MOTION_NOTIFY)); 156 event->motion.x = x; 157 event->motion.y = y; 158 event->motion.time = GDK_CURRENT_TIME; 159 event->motion.state = 0; 160 event->motion.axes = 0; 161 162 GtkWidget* viewWidget = GTK_WIDGET(m_view); 163 if (!gtk_widget_get_realized(viewWidget)) 164 gtk_widget_show(m_window); 165 event->motion.window = gtk_widget_get_window(viewWidget); 166 g_object_ref(event->motion.window); 167 event->motion.device = gdk_seat_get_pointer(gdk_display_get_default_seat(gtk_widget_get_display(viewWidget))); 168 169 int xRoot, yRoot; 170 gdk_window_get_root_coords(gtk_widget_get_window(viewWidget), x, y, &xRoot, &yRoot); 171 event->motion.x_root = xRoot; 172 event->motion.y_root = yRoot; 173 gtk_main_do_event(event.get()); 119 webkitWebViewBaseSynthesizeMouseEvent(toWebKitGLibAPI(m_view), MouseEventType::Motion, 0, 0, x, y, 0, 0); 174 120 } 175 121
Note:
See TracChangeset
for help on using the changeset viewer.