WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch for landing
wkgtk4-api-tests.diff (text/plain), 52.26 KB, created by
Carlos Garcia Campos
on 2020-07-30 01:27:52 PDT
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Carlos Garcia Campos
Created:
2020-07-30 01:27:52 PDT
Size:
52.26 KB
patch
obsolete
>diff --git a/ChangeLog b/ChangeLog >index 8f25ddab0d43..98e07eae54fd 100644 >--- a/ChangeLog >+++ b/ChangeLog >@@ -1,3 +1,14 @@ >+2020-07-15 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [GTK4] Enable API tests >+ https://bugs.webkit.org/show_bug.cgi?id=214344 >+ >+ Reviewed by Adrian Perez de Castro. >+ >+ Build API tests for GTK4 too. >+ >+ * Source/cmake/OptionsGTK.cmake: >+ > 2020-07-29 Adrian Perez de Castro <aperez@igalia.com> > > Unreviewed. Update OptionsWPE.cmake and NEWS for the 2.29.2 release >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 811a208f75e1..e288c5c25a76 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,22 @@ >+2020-07-15 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [GTK4] Enable API tests >+ https://bugs.webkit.org/show_bug.cgi?id=214344 >+ >+ Reviewed by Adrian Perez de Castro. >+ >+ Use a custom KeyEvent struct to pass to the IM filter as a fake GdkEvent to be able to test input methods with >+ GTK4. >+ >+ * UIProcess/API/glib/InputMethodFilter.h: >+ * UIProcess/API/gtk/InputMethodFilterGtk.cpp: >+ (WebKit::InputMethodFilter::platformEventKeyIsKeyPress const): >+ (WebKit::InputMethodFilter::filterKeyEvent): >+ * UIProcess/API/gtk/WebKitWebViewBaseInternal.h: >+ * UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp: >+ (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::start): >+ (WebKit::DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::stop): >+ > 2020-07-29 Megan Gardner <megan_gardner@apple.com> > > Highlight color does not switch after being set it system preferences. >diff --git a/Source/WebKit/UIProcess/API/glib/InputMethodFilter.h b/Source/WebKit/UIProcess/API/glib/InputMethodFilter.h >index 70a7d0c06bec..33a45bcbff0a 100644 >--- a/Source/WebKit/UIProcess/API/glib/InputMethodFilter.h >+++ b/Source/WebKit/UIProcess/API/glib/InputMethodFilter.h >@@ -112,6 +112,9 @@ private: > struct { > bool isActive { false }; > bool preeditChanged { false }; >+#if PLATFORM(GTK) && USE(GTK4) >+ bool isFakeKeyEventForTesting { false }; >+#endif > } m_filteringContext; > > String m_compositionResult; >diff --git a/Source/WebKit/UIProcess/API/gtk/InputMethodFilterGtk.cpp b/Source/WebKit/UIProcess/API/gtk/InputMethodFilterGtk.cpp >index 4ce6663ba74b..7ab4bb693bb4 100644 >--- a/Source/WebKit/UIProcess/API/gtk/InputMethodFilterGtk.cpp >+++ b/Source/WebKit/UIProcess/API/gtk/InputMethodFilterGtk.cpp >@@ -20,10 +20,13 @@ > #include "config.h" > #include "InputMethodFilter.h" > >+#include "WebKitInputMethodContextImplGtk.h" > #include "WebKitInputMethodContextPrivate.h" >+#include "WebKitWebViewBaseInternal.h" > #include <WebCore/GUniquePtrGtk.h> > #include <WebCore/IntRect.h> > #include <gdk/gdk.h> >+#include <wtf/SetForScope.h> > > namespace WebKit { > using namespace WebCore; >@@ -39,6 +42,10 @@ IntRect InputMethodFilter::platformTransformCursorRectToViewCoordinates(const In > > bool InputMethodFilter::platformEventKeyIsKeyPress(PlatformEventKey* event) const > { >+#if USE(GTK4) >+ if (UNLIKELY(m_filteringContext.isFakeKeyEventForTesting)) >+ return reinterpret_cast<KeyEvent*>(event)->type == GDK_KEY_PRESS; >+#endif > return gdk_event_get_event_type(event) == GDK_KEY_PRESS; > } > >@@ -47,7 +54,17 @@ InputMethodFilter::FilterResult InputMethodFilter::filterKeyEvent(unsigned type, > if (!isEnabled() || !m_context) > return { }; > >-#if !USE(GTK4) >+#if USE(GTK4) >+ if (WEBKIT_IS_INPUT_METHOD_CONTEXT_IMPL_GTK(m_context.get())) >+ return { }; >+ >+ // In GTK4 we can't create GdkEvents, so here we create a custom KeyEvent struct that is passed >+ // as a GdkEvent to the filter. This is only called from tests, and tests know they are receiving >+ // a KeyEvent struct instead of an actual GdkEvent. >+ SetForScope<bool> isFakeKeyEventForTesting(m_filteringContext.isFakeKeyEventForTesting, true); >+ KeyEvent event { type, keyval, modifiers }; >+ return filterKeyEvent(reinterpret_cast<GdkEvent*>(&event)); >+#else > auto* webView = webkitInputMethodContextGetWebView(m_context.get()); > ASSERT(webView); > >@@ -60,8 +77,6 @@ InputMethodFilter::FilterResult InputMethodFilter::filterKeyEvent(unsigned type, > event->key.state = modifiers; > gdk_event_set_device(event.get(), gdk_seat_get_keyboard(gdk_display_get_default_seat(gtk_widget_get_display(GTK_WIDGET(webView))))); > return filterKeyEvent(event.get()); >-#else >- return { }; > #endif > } > >diff --git a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBaseInternal.h b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBaseInternal.h >index ed49d582c72b..b6695186281e 100644 >--- a/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBaseInternal.h >+++ b/Source/WebKit/UIProcess/API/gtk/WebKitWebViewBaseInternal.h >@@ -27,6 +27,12 @@ > > typedef struct _WebKitWebViewBase WebKitWebViewBase; > >+struct KeyEvent { >+ unsigned type { 0 }; >+ unsigned keyval { 0 }; >+ unsigned modifiers { 0 }; >+}; >+ > enum class MouseEventType { Press, Release, Motion }; > void webkitWebViewBaseSynthesizeMouseEvent(WebKitWebViewBase*, MouseEventType type, unsigned button, unsigned short buttons, int x, int y, unsigned modifiers, int clickCount); > >diff --git a/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp b/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp >index 6bbd1cabd27a..61e3f6050d7f 100644 >--- a/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp >+++ b/Source/WebKit/UIProcess/CoordinatedGraphics/DrawingAreaProxyCoordinatedGraphics.cpp >@@ -411,8 +411,12 @@ void DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::start(WTF::Function<vo > m_callback = WTFMove(callback); > #if PLATFORM(GTK) > gtk_widget_queue_draw(m_webPage.viewWidget()); >+#if USE(GTK4) >+ m_timer.startOneShot(16_ms); >+#else > g_signal_connect_swapped(m_webPage.viewWidget(), "draw", reinterpret_cast<GCallback>(webViewDrawCallback), this); > m_timer.startOneShot(100_ms); >+#endif > #else > m_timer.startOneShot(0_s); > #endif >@@ -421,7 +425,7 @@ void DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::start(WTF::Function<vo > void DrawingAreaProxyCoordinatedGraphics::DrawingMonitor::stop() > { > m_timer.stop(); >-#if PLATFORM(GTK) >+#if PLATFORM(GTK) && !USE(GTK4) > g_signal_handlers_disconnect_by_func(m_webPage.viewWidget(), reinterpret_cast<gpointer>(webViewDrawCallback), this); > #endif > m_startTime = MonotonicTime(); >diff --git a/Source/cmake/OptionsGTK.cmake b/Source/cmake/OptionsGTK.cmake >index d58c7fc3fffb..26cf56ee4619 100644 >--- a/Source/cmake/OptionsGTK.cmake >+++ b/Source/cmake/OptionsGTK.cmake >@@ -120,11 +120,7 @@ WEBKIT_OPTION_DEPEND(USE_WPE_RENDERER ENABLE_WAYLAND_TARGET) > SET_AND_EXPOSE_TO_BUILD(ENABLE_DEVELOPER_MODE ${DEVELOPER_MODE}) > if (DEVELOPER_MODE) > WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MINIBROWSER PUBLIC ON) >- if (USE_GTK4) >- WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS PRIVATE OFF) >- else () >- WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS PRIVATE ON) >- endif () >+ WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS PRIVATE ON) > else () > WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MINIBROWSER PUBLIC OFF) > WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_API_TESTS PRIVATE OFF) >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index b38bd8bd12a7..b2b52c24ab27 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,57 @@ >+2020-07-15 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [GTK4] Enable API tests >+ https://bugs.webkit.org/show_bug.cgi?id=214344 >+ >+ Reviewed by Adrian Perez de Castro. >+ >+ Port API tests to GTK4. Context menu and option menu tests are still disabled for GTK4 because we plan to change >+ the API for GTK4 in those cases. >+ >+ * TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp: >+ (beforeAll): >+ * TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp: >+ (webkitInputMethodContextMockFilterKeyEvent): >+ * TestWebKitAPI/Tests/WebKitGLib/TestMultiprocess.cpp: >+ * TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp: >+ (beforeAll): >+ * TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp: >+ (checkMimeTypeForFilter): >+ * TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp: >+ (testWebExtensionInputElementIsUserEdited): >+ * TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp: >+ (testWebKitSettings): >+ * TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp: >+ * TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp: >+ * TestWebKitAPI/Tests/WebKitGtk/InspectorTestServer.cpp: >+ (main): >+ * TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp: >+ (testContextMenuPopulateMenu): >+ (beforeAll): >+ * TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp: >+ * TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp: >+ * TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp: >+ (Clipboard::Clipboard): >+ (Clipboard::clear): >+ (Clipboard::containsText const): >+ (Clipboard::waitForText): >+ (Clipboard::readText): >+ (testWebViewEditorCutCopyPasteNonEditable): >+ (testWebViewEditorCutCopyPasteEditable): >+ (testWebViewEditorSelectAllNonEditable): >+ (testWebViewEditorSelectAllEditable): >+ (loadContentsAndTryToCutSelection): >+ * TestWebKitAPI/glib/WebKitGLib/TestMain.h: >+ (Test::Test): >+ * TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp: >+ (WebViewTest::platformDestroy): >+ (WebViewTest::showInWindow): >+ * TestWebKitAPI/gtk/PlatformUtilitiesGtk.cpp: >+ (TestWebKitAPI::Util::isKeyDown): >+ * TestWebKitAPI/gtk/PlatformWebViewGtk.cpp: >+ (TestWebKitAPI::PlatformWebView::~PlatformWebView): >+ (TestWebKitAPI::PlatformWebView::initialize): >+ > 2020-07-29 Darin Adler <darin@apple.com> > > Add script to help us count uses of non-inclusive terms >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp >index b0f1b85028aa..a21729bd2d05 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestDownloads.cpp >@@ -807,7 +807,10 @@ void beforeAll() > DownloadTest::add("Downloads", "mime-type", testDownloadMIMEType); > // FIXME: Implement keyStroke in WPE. > #if PLATFORM(GTK) >+#if !USE(GTK4) >+ // FIXME: Rework context menu API in GTK4 to not expose GdkEvent. > WebViewDownloadTest::add("Downloads", "contex-menu-download-actions", testContextMenuDownloadActions); >+#endif > // FIXME: Implement mouse click in WPE. > WebViewDownloadTest::add("Downloads", "blob-download", testBlobDownload); > #endif >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp >index 3d1b582b6498..3b10bd7d3acb 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestInputMethodContext.cpp >@@ -24,7 +24,13 @@ > #include <wtf/glib/GUniquePtr.h> > > #if PLATFORM(GTK) >+#include <WebCore/GtkVersioning.h> >+#if USE(GTK4) >+#include "WebKitWebViewBaseInternal.h" >+using PlatformEventKey = GdkEvent; >+#else > using PlatformEventKey = GdkEventKey; >+#endif > #define KEY(x) GDK_KEY_##x > #define CONTROL_MASK GDK_CONTROL_MASK > #define SHIFT_MASK GDK_SHIFT_MASK >@@ -92,11 +98,18 @@ static gboolean webkitInputMethodContextMockFilterKeyEvent(WebKitInputMethodCont > return FALSE; > > #if PLATFORM(GTK) >+#if USE(GTK4) >+ auto* event = reinterpret_cast<KeyEvent*>(keyEvent); >+ unsigned keyval = event->keyval; >+ auto state = static_cast<GdkModifierType>(event->modifiers); >+ bool isKeyPress = event->type == GDK_KEY_PRESS; >+#else > GdkModifierType state; > guint keyval; > if (!gdk_event_get_state(reinterpret_cast<GdkEvent*>(keyEvent), &state) || !gdk_event_get_keyval(reinterpret_cast<GdkEvent*>(keyEvent), &keyval)) > return FALSE; > bool isKeyPress = gdk_event_get_event_type(reinterpret_cast<GdkEvent*>(keyEvent)) == GDK_KEY_PRESS; >+#endif > gunichar character = gdk_keyval_to_unicode(keyval); > #elif PLATFORM(WPE) > uint32_t state = keyEvent->modifiers; >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestMultiprocess.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestMultiprocess.cpp >index 552e392ef920..3aa12ef544de 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestMultiprocess.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestMultiprocess.cpp >@@ -99,7 +99,11 @@ public: > auto* connection = s_dbusConnectionPageMap.get(webkit_web_view_get_page_id(m_webViews[index].get())); > g_assert_nonnull(connection); > g_signal_connect_swapped(connection, "closed", G_CALLBACK(g_main_loop_quit), m_mainLoop); >+#if USE(GTK4) >+ g_object_run_dispose(G_OBJECT(m_webViews[index].get())); >+#else > gtk_widget_destroy(GTK_WIDGET(m_webViews[index].get())); >+#endif > g_main_loop_run(m_mainLoop); > } > #endif >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp >index 7bcc89453696..7d3dbb8ea95d 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestOptionMenu.cpp >@@ -304,10 +304,13 @@ static void testOptionMenuSelect(OptionMenuTest* test, gconstpointer) > > void beforeAll() > { >+#if !PLATFORM(GTK) || !USE(GTK4) >+ // FIXME: Rework option menu API in GTK4 to not expose GdkEvent. > OptionMenuTest::add("WebKitWebView", "option-menu-simple", testOptionMenuSimple); > OptionMenuTest::add("WebKitWebView", "option-menu-groups", testOptionMenuGroups); > OptionMenuTest::add("WebKitWebView", "option-menu-activate", testOptionMenuActivate); > OptionMenuTest::add("WebKitWebView", "option-menu-select", testOptionMenuSelect); >+#endif > } > > void afterAll() >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp >index 666bea570c08..c2bf7eae4bb4 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp >@@ -317,8 +317,8 @@ public: > void setCreateNewWebViewsInWindowsWithDefaultSize(int width = 800, int height = 600) > { > m_shouldCreateWebViewsInNewWindowsAutomatically = true; >- m_DefaultGeometryNewWindows.width = width; >- m_DefaultGeometryNewWindows.height = height; >+ m_defaultGeometryNewWindows.width = width; >+ m_defaultGeometryNewWindows.height = height; > } > #endif > >@@ -338,8 +338,8 @@ public: > #if PLATFORM(GTK) > keyStroke(GDK_KEY_a); > keyStroke(GDK_KEY_b); >- while (gtk_events_pending()) >- gtk_main_iteration(); >+ while (g_main_context_pending(nullptr)) >+ g_main_context_iteration(nullptr, TRUE); > #endif > } > >@@ -367,10 +367,15 @@ public: > #if PLATFORM(GTK) > if (m_shouldCreateWebViewsInNewWindowsAutomatically) { > g_assert_null(m_parentWindow); >+#if USE(GTK4) >+ m_parentWindow = gtk_window_new(); >+ gtk_window_set_child(GTK_WINDOW(m_parentWindow), GTK_WIDGET(newWebView)); >+#else > m_parentWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); >- gtk_window_set_default_size(GTK_WINDOW(m_parentWindow), m_DefaultGeometryNewWindows.width, m_DefaultGeometryNewWindows.height); > gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(newWebView)); > gtk_widget_show(GTK_WIDGET(newWebView)); >+#endif >+ gtk_window_set_default_size(GTK_WINDOW(m_parentWindow), m_defaultGeometryNewWindows.width, m_defaultGeometryNewWindows.height); > gtk_widget_show(m_parentWindow); > } > #endif >@@ -416,7 +421,7 @@ public: > > #if PLATFORM(GTK) > bool m_shouldCreateWebViewsInNewWindowsAutomatically { false }; >- cairo_rectangle_int_t m_DefaultGeometryNewWindows; >+ cairo_rectangle_int_t m_defaultGeometryNewWindows; > #endif > }; > >@@ -521,10 +526,16 @@ static void testWebViewCreateNavigationData(CreateNavigationDataTest* test, gcon > #if PLATFORM(GTK) > static gboolean checkMimeTypeForFilter(GtkFileFilter* filter, const gchar* mimeType) > { >+#if USE(GTK4) >+ GRefPtr<GFileInfo> filterInfo = adoptGRef(g_file_info_new()); >+ g_file_info_set_content_type(filterInfo.get(), mimeType); >+ return gtk_filter_match(GTK_FILTER(filter), filterInfo.get()); >+#else > GtkFileFilterInfo filterInfo; > filterInfo.contains = GTK_FILE_FILTER_MIME_TYPE; > filterInfo.mime_type = mimeType; > return gtk_file_filter_filter(filter, &filterInfo); >+#endif > } > #endif > >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp >index 5f7cfd8b23f4..7974fb11aae3 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebExtensions.cpp >@@ -83,8 +83,8 @@ static void testWebExtensionInputElementIsUserEdited(WebViewTest* test, gconstpo > g_assert_false(inputElementIsUserEdited(proxy.get(), pageID, "input")); > test->runJavaScriptAndWaitUntilFinished("document.getElementById('input').focus()", nullptr); > test->keyStroke(GDK_KEY_a); >- while (gtk_events_pending()) >- gtk_main_iteration(); >+ while (g_main_context_pending(nullptr)) >+ g_main_context_iteration(nullptr, TRUE); > GUniquePtr<char> resultString; > do { > auto* result = test->runJavaScriptAndWaitUntilFinished("document.getElementById('input').value", nullptr); >@@ -95,8 +95,8 @@ static void testWebExtensionInputElementIsUserEdited(WebViewTest* test, gconstpo > g_assert_false(inputElementIsUserEdited(proxy.get(), pageID, "textarea")); > test->runJavaScriptAndWaitUntilFinished("document.getElementById('textarea').focus()", nullptr); > test->keyStroke(GDK_KEY_b); >- while (gtk_events_pending()) >- gtk_main_iteration(); >+ while (g_main_context_pending(nullptr)) >+ g_main_context_iteration(nullptr, TRUE); > do { > auto* result = test->runJavaScriptAndWaitUntilFinished("document.getElementById('textarea').value", nullptr); > resultString.reset(WebViewTest::javascriptResultToCString(result)); >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp >index da04725cdb83..31270b2625ab 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp >@@ -349,6 +349,7 @@ static void testWebKitSettings(Test*, gconstpointer) > g_assert_cmpstr(nullptr, ==, webkit_settings_get_media_content_types_requiring_hardware_support(settings)); > > #if PLATFORM(GTK) >+#if !USE(GTK4) > // Ondemand is the default hardware acceleration policy. > g_assert_cmpuint(webkit_settings_get_hardware_acceleration_policy(settings), ==, WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND); > webkit_settings_set_hardware_acceleration_policy(settings, WEBKIT_HARDWARE_ACCELERATION_POLICY_NEVER); >@@ -357,6 +358,7 @@ static void testWebKitSettings(Test*, gconstpointer) > g_assert_cmpuint(webkit_settings_get_hardware_acceleration_policy(settings), ==, WEBKIT_HARDWARE_ACCELERATION_POLICY_ALWAYS); > webkit_settings_set_hardware_acceleration_policy(settings, WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND); > g_assert_cmpuint(webkit_settings_get_hardware_acceleration_policy(settings), ==, WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND); >+#endif > > // Back-forward navigation gesture is disabled by default > g_assert_false(webkit_settings_get_enable_back_forward_navigation_gestures(settings)); >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp >index ac708489c9f3..f522616876a2 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp >@@ -444,9 +444,10 @@ public: > > static gboolean leaveFullScreenIdle(FullScreenClientTest* test) > { >- // FIXME: Implement key strokes in WPE > #if PLATFORM(GTK) > test->keyStroke(GDK_KEY_Escape); >+#else >+ test->keyStroke(WPE_KEY_Escape); > #endif > return FALSE; > } >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp b/Tools/TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp >index 0b0ba8b1b4bf..c82aab84699e 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGtk/AccessibilityTestServer.cpp >@@ -21,6 +21,7 @@ > > #include <WebCore/GtkVersioning.h> > #include <webkit2/webkit2.h> >+#include <wtf/glib/GRefPtr.h> > > static const char introspectionXML[] = > "<node>" >@@ -70,11 +71,16 @@ int main(int argc, char** argv) > gtk_init(&argc, &argv); > > GtkWidget* webView = webkit_web_view_new(); >- >+#if USE(GTK4) >+ GtkWidget* window = gtk_window_new(); >+ gtk_window_set_child(GTK_WINDOW(window), GTK_WIDGET(webView)); >+#else > GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); > g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), nullptr); > gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(webView)); >- gtk_widget_show_all(window); >+ gtk_widget_show(GTK_WIDGET(webView)); >+#endif >+ gtk_widget_show(window); > > g_dbus_connection_new_for_address(argv[1], G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, nullptr, nullptr, > [](GObject*, GAsyncResult* result, gpointer userData) { >@@ -88,5 +94,10 @@ int main(int argc, char** argv) > &interfaceVirtualTable, userData, nullptr, nullptr); > }, webView); > >+#if USE(GTK4) >+ GRefPtr<GMainLoop> loop = adoptGRef(g_main_loop_new(nullptr, TRUE)); >+ g_main_loop_run(loop.get()); >+#else > gtk_main(); >+#endif > } >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGtk/InspectorTestServer.cpp b/Tools/TestWebKitAPI/Tests/WebKitGtk/InspectorTestServer.cpp >index bccc29c4ff2d..fe701151df35 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGtk/InspectorTestServer.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGtk/InspectorTestServer.cpp >@@ -26,6 +26,7 @@ > > #include <WebCore/GtkVersioning.h> > #include <webkit2/webkit2.h> >+#include <wtf/glib/GRefPtr.h> > > int main(int argc, char** argv) > { >@@ -40,6 +41,14 @@ int main(int argc, char** argv) > "<html><body><p>WebKitGTK Inspector Test Server</p></body></html>", > "http://127.0.0.1:2999/"); > >+#if USE(GTK4) >+ GtkWidget* window = gtk_window_new(); >+ gtk_window_set_child(GTK_WINDOW(window), GTK_WIDGET(webView)); >+ gtk_widget_show(window); >+ >+ GRefPtr<GMainLoop> loop = adoptGRef(g_main_loop_new(nullptr, TRUE)); >+ g_main_loop_run(loop.get()); >+#else > GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); > gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(webView)); > gtk_widget_show_all(window); >@@ -47,4 +56,5 @@ int main(int argc, char** argv) > g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), 0); > > gtk_main(); >+#endif > } >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp b/Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp >index 7bd9ddbd7b4d..515bc00d6f72 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp >@@ -26,30 +26,6 @@ > > static WebKitTestServer* kServer; > >-#if USE(GTK4) >-struct LookupWidgetsData { >- void (*walkChildren)(GtkContainer*, GtkCallback, void*); >- Function<bool(GtkWidget*)> predicate; >- Vector<GtkWidget*> result; >-}; >- >-static void lookupWidgetsWalkChild(GtkWidget* child, void* userdata) >-{ >- auto& data = *reinterpret_cast<LookupWidgetsData*>(userdata); >- if (data.predicate(child)) >- data.result.append(child); >- else if (GTK_IS_CONTAINER(child)) >- data.walkChildren(GTK_CONTAINER(child), lookupWidgetsWalkChild, userdata); >-} >- >-static Vector<GtkWidget*> lookupWidgets(GtkWidget* widget, Function<bool(GtkWidget*)>&& predicate, bool internal = false) >-{ >- LookupWidgetsData data = {internal ? gtk_container_forall : gtk_container_foreach, WTFMove(predicate)}; >- lookupWidgetsWalkChild(widget, &data); >- return WTFMove(data.result); >-} >-#endif // USE(GTK4) >- > class ContextMenuTest: public WebViewTest { > public: > enum ContextMenuItemStateFlags { >@@ -61,6 +37,7 @@ public: > void checkContextMenuEvent(GdkEvent* event) > { > g_assert_nonnull(event); >+#if !USE(GTK4) > g_assert_cmpint(event->type, ==, m_expectedEventType); > > switch (m_expectedEventType) { >@@ -79,6 +56,7 @@ public: > default: > g_assert_not_reached(); > } >+#endif > } > > static gboolean contextMenuCallback(WebKitWebView* webView, WebKitContextMenu* contextMenu, GdkEvent* event, WebKitHitTestResult* hitTestResult, ContextMenuTest* test) >@@ -126,18 +104,7 @@ public: > continue; > > #if USE(GTK4) >- // Popovers are internal to the GtkContainer where the webview resides, >- // gtk_container_forall() is the only way to enumerate internal children. >- GtkPopover *popover = nullptr; >- gtk_container_forall(GTK_CONTAINER(iter->data), >- [](GtkWidget* child, void* data) { >- auto** popover = reinterpret_cast<GtkPopover**>(data); >- if (GTK_IS_POPOVER_MENU(child) && !*popover) >- *popover = GTK_POPOVER(child); >- }, &popover); >- >- if (popover && gtk_popover_get_relative_to(popover) == GTK_WIDGET(m_webView)) >- return popover; >+ return nullptr; > #else > GtkWidget* child = gtk_bin_get_child(GTK_BIN(iter->data)); > if (!GTK_IS_MENU(child)) >@@ -176,10 +143,12 @@ public: > WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(items->data); > assertObjectIsDeletedWhenTestFinishes(G_OBJECT(item)); > >+#if !USE(GTK4) > G_GNUC_BEGIN_IGNORE_DEPRECATIONS; > GtkAction* action = webkit_context_menu_item_get_action(item); > g_assert_true(GTK_IS_ACTION(action)); > G_GNUC_END_IGNORE_DEPRECATIONS; >+#endif > > GAction* gAction = webkit_context_menu_item_get_gaction(item); > g_assert_true(G_IS_ACTION(gAction)); >@@ -199,12 +168,15 @@ public: > WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(items->data); > assertObjectIsDeletedWhenTestFinishes(G_OBJECT(item)); > >+#if !USE(GTK4) > G_GNUC_BEGIN_IGNORE_DEPRECATIONS; > GtkAction* action = webkit_context_menu_item_get_action(item); > g_assert_true(GTK_IS_ACTION(action)); >+#endif > > GAction* gAction = webkit_context_menu_item_get_gaction(item); > g_assert_true(G_IS_ACTION(gAction)); >+#if !USE(GTK4) > g_assert_cmpstr(gtk_action_get_name(action), ==, g_action_get_name(gAction)); > g_assert_cmpint(gtk_action_get_sensitive(action), ==, g_action_get_enabled(gAction)); > if (GTK_IS_TOGGLE_ACTION(action)) { >@@ -217,6 +189,7 @@ public: > g_assert_cmpint(webkit_context_menu_item_get_stock_action(item), ==, WEBKIT_CONTEXT_MENU_ACTION_CUSTOM); > g_assert_cmpstr(gtk_action_get_label(action), ==, label); > G_GNUC_END_IGNORE_DEPRECATIONS; >+#endif > > checkActionState(gAction, state); > >@@ -231,11 +204,13 @@ public: > WebKitContextMenuItem* item = WEBKIT_CONTEXT_MENU_ITEM(items->data); > assertObjectIsDeletedWhenTestFinishes(G_OBJECT(item)); > >+#if !USE(GTK4) > G_GNUC_BEGIN_IGNORE_DEPRECATIONS; > GtkAction* action = webkit_context_menu_item_get_action(item); > g_assert_true(GTK_IS_ACTION(action)); > g_assert_cmpstr(gtk_action_get_label(action), ==, label); > G_GNUC_END_IGNORE_DEPRECATIONS; >+#endif > > GAction* gAction = webkit_context_menu_item_get_gaction(item); > g_assert_true(G_IS_ACTION(gAction)); >@@ -301,7 +276,9 @@ public: > > void showContextMenuTriggeredByPopupEventAndWaitUntilFinished() > { >+#if !USE(GTK4) > m_expectedEventType = GDK_NOTHING; >+#endif > g_idle_add(reinterpret_cast<GSourceFunc>(emitPopupMenuSignalIdleCallback), this); > g_main_loop_run(m_mainLoop); > } >@@ -600,12 +577,14 @@ public: > bool contextMenu(WebKitContextMenu* contextMenu, GdkEvent*, WebKitHitTestResult* hitTestResult) > { > // Append our custom item to the default menu. >+#if !USE(GTK4) > G_GNUC_BEGIN_IGNORE_DEPRECATIONS; > if (m_action) > webkit_context_menu_append(contextMenu, webkit_context_menu_item_new(m_action.get())); > else if (m_gAction) > webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_from_gaction(m_gAction.get(), m_gActionTitle.data(), m_expectedTarget.get())); > G_GNUC_END_IGNORE_DEPRECATIONS; >+#endif > quitMainLoop(); > > return false; >@@ -614,22 +593,7 @@ public: > #if USE(GTK4) > GtkButton* getMenuItem(GtkWidget* popover, const gchar* itemLabel) > { >- auto items = lookupWidgets(popover, >- [itemLabel](GtkWidget* widget) { >- if (!GTK_IS_BUTTON(widget)) >- return false; >- const char* label = gtk_button_get_label(GTK_BUTTON(widget)); >- if (!label) { >- const auto labels = lookupWidgets(GTK_WIDGET(widget), >- [](GtkWidget* child) { return GTK_IS_LABEL(child); }); >- g_assert_cmpuint(1, ==, labels.size()); >- label = gtk_label_get_label(GTK_LABEL(labels[0])); >- } >- return GTK_IS_BUTTON(widget) && g_strcmp0(label, itemLabel) == 0; >- }, true); >- >- g_assert_cmpuint(items.size(), >, 0); >- return items.size() ? GTK_BUTTON(items[0]) : nullptr; >+ return nullptr; > } > #else > GtkMenuItem* getMenuItem(GtkWidget* menu, const gchar* itemLabel) >@@ -651,8 +615,7 @@ public: > auto* menu = getContextMenuWidget(); > auto* item = getMenuItem(menu, m_itemToActivateLabel); > #if USE(GTK4) >- // GTK4 uses a popover, which contains buttons. >- gtk_button_clicked(item); >+ > #else > // GTK3 uses a menu, which contains menu items. > gtk_menu_shell_activate_item(GTK_MENU_SHELL(menu), GTK_WIDGET(item), TRUE); >@@ -700,12 +663,6 @@ public: > static void actionToggledCallback(ContextMenuCustomTest* test) > { > test->m_toggled = true; >- >-#if USE(GTK4) >- // For toggle actions the popover menu is NOT dismissed automatically, as to show visual feedback to the user >- // (i.e. the check marker). Dismiss it here to trigger contextMenuDismissedCallback() and continue the test. >- gtk_popover_popdown(test->getPopoverMenu()); >-#endif // USE(GTK4) > } > > void setAction(GtkAction* action) >@@ -713,12 +670,14 @@ public: > m_action = action; > m_gAction = nullptr; > m_expectedTarget = nullptr; >+#if !USE(GTK4) > G_GNUC_BEGIN_IGNORE_DEPRECATIONS; > if (GTK_IS_TOGGLE_ACTION(action)) > g_signal_connect_swapped(action, "toggled", G_CALLBACK(actionToggledCallback), this); > else > g_signal_connect_swapped(action, "activate", G_CALLBACK(actionActivatedCallback), this); > G_GNUC_END_IGNORE_DEPRECATIONS; >+#endif > } > > void setAction(GAction* action, const char* title, GVariant* target = nullptr) >@@ -747,6 +706,7 @@ static void testContextMenuPopulateMenu(ContextMenuCustomTest* test, gconstpoint > test->loadHtml("<html><body>WebKitGTK Context menu tests</body></html>", "file:///"); > test->waitUntilLoadFinished(); > >+#if !USE(GTK4) > G_GNUC_BEGIN_IGNORE_DEPRECATIONS; > // Create a custom menu item. > GRefPtr<GtkAction> action = adoptGRef(gtk_action_new("WebKitGTKCustomAction", "Custom _Action", nullptr, nullptr)); >@@ -764,6 +724,7 @@ static void testContextMenuPopulateMenu(ContextMenuCustomTest* test, gconstpoint > g_assert_false(test->m_activated); > g_assert_true(test->m_toggled); > G_GNUC_END_IGNORE_DEPRECATIONS; >+#endif > > // Create a custom menu item using GAction. > GRefPtr<GAction> gAction = adoptGRef(G_ACTION(g_simple_action_new("WebKitGTKCustomGAction", nullptr))); >@@ -805,6 +766,7 @@ public: > webkit_context_menu_insert(contextMenu, webkit_context_menu_item_new_separator(), 2); > > // Add custom actions. >+#if !USE(GTK4) > G_GNUC_BEGIN_IGNORE_DEPRECATIONS; > GRefPtr<GtkAction> action = adoptGRef(gtk_action_new("WebKitGTKCustomAction", "Custom _Action", nullptr, nullptr)); > gtk_action_set_sensitive(action.get(), FALSE); >@@ -813,6 +775,7 @@ public: > gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(toggleAction.get()), TRUE); > webkit_context_menu_append(contextMenu, webkit_context_menu_item_new(toggleAction.get())); > webkit_context_menu_append(contextMenu, webkit_context_menu_item_new_separator()); >+#endif > GRefPtr<GAction> gAction = adoptGRef(G_ACTION(g_simple_action_new("WebKitGTKCustomGAction", nullptr))); > g_simple_action_set_enabled(G_SIMPLE_ACTION(gAction.get()), FALSE); > webkit_context_menu_insert(contextMenu, webkit_context_menu_item_new_from_gaction(gAction.get(), "Custom _GAction", nullptr), -1); >@@ -1175,6 +1138,8 @@ void beforeAll() > kServer = new WebKitTestServer(); > kServer->run(serverCallback); > >+#if !USE(GTK4) >+ // FIXME: Rework context menu API in GTK4 to not expose GdkEvent. > ContextMenuDefaultTest::add("WebKitWebView", "default-menu", testContextMenuDefaultMenu); > ContextMenuDefaultTest::add("WebKitWebView", "context-menu-key", testContextMenuKey); > ContextMenuDefaultTest::add("WebKitWebView", "popup-event-signal", testPopupEventSignal); >@@ -1185,6 +1150,7 @@ void beforeAll() > ContextMenuDismissedTest::add("WebKitWebView", "menu-dismissed", testContextMenuDismissed); > ContextMenuWebExtensionTest::add("WebKitWebPage", "context-menu", testContextMenuWebExtensionMenu); > ContextMenuWebExtensionNodeTest::add("WebKitWebPage", "context-menu-node", testContextMenuWebExtensionNode); >+#endif > } > > void afterAll() >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp b/Tools/TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp >index e4ce8d35b744..cd04e4944d23 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGtk/TestInspector.cpp >@@ -226,28 +226,40 @@ public: > > ~CustomInspectorTest() > { >+#if USE(GTK4) >+ if (m_inspectorWindow) >+ gtk_window_destroy(GTK_WINDOW(m_inspectorWindow)); >+#else > if (m_inspectorWindow) > gtk_widget_destroy(m_inspectorWindow); >+#endif > } > > bool openWindow() > { > g_assert_null(m_inspectorWindow); >- m_inspectorWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); > WebKitWebViewBase* inspectorView = webkit_web_inspector_get_web_view(m_inspector); > g_assert_nonnull(inspectorView); >+#if USE(GTK4) >+ m_inspectorWindow = gtk_window_new(); >+ gtk_window_set_child(GTK_WINDOW(m_inspectorWindow), GTK_WIDGET(inspectorView)); >+#else >+ m_inspectorWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); > gtk_container_add(GTK_CONTAINER(m_inspectorWindow), GTK_WIDGET(inspectorView)); >- gtk_widget_show_all(m_inspectorWindow); >+ gtk_widget_show(GTK_WIDGET(inspectorView)); >+#endif >+ gtk_widget_show(m_inspectorWindow); > > return InspectorTest::openWindow(); > } > > void closed() > { >- if (m_inspectorWindow) { >- gtk_widget_destroy(m_inspectorWindow); >- m_inspectorWindow = 0; >- } >+#if USE(GTK4) >+ g_clear_pointer(&m_inspectorWindow, gtk_window_destroy); >+#else >+ g_clear_pointer(&m_inspectorWindow, gtk_widget_destroy); >+#endif > > return InspectorTest::closed(); > } >@@ -256,12 +268,29 @@ public: > { > GRefPtr<WebKitWebViewBase> inspectorView = webkit_web_inspector_get_web_view(m_inspector); > if (m_inspectorWindow) { >+#if USE(GTK4) >+ gtk_window_set_child(GTK_WINDOW(m_inspectorWindow), nullptr); >+ gtk_window_destroy(GTK_WINDOW(m_inspectorWindow)); >+#else > gtk_container_remove(GTK_CONTAINER(m_inspectorWindow), GTK_WIDGET(inspectorView.get())); > gtk_widget_destroy(m_inspectorWindow); >- m_inspectorWindow = 0; >+#endif >+ m_inspectorWindow = nullptr; > } > > GtkWidget* pane; >+#if USE(GTK4) >+ if (gtk_window_get_child(GTK_WINDOW(m_parentWindow)) == GTK_WIDGET(m_webView)) { >+ GRefPtr<WebKitWebView> inspectedView = m_webView; >+ gtk_window_set_child(GTK_WINDOW(m_parentWindow), nullptr); >+ pane = gtk_paned_new(GTK_ORIENTATION_VERTICAL); >+ gtk_paned_set_start_child(GTK_PANED(pane), GTK_WIDGET(m_webView)); >+ gtk_window_set_child(GTK_WINDOW(m_parentWindow), pane); >+ } else >+ pane = gtk_window_get_child(GTK_WINDOW(m_parentWindow)); >+ gtk_paned_set_position(GTK_PANED(pane), webkit_web_inspector_get_attached_height(m_inspector)); >+ gtk_paned_set_end_child(GTK_PANED(pane), GTK_WIDGET(inspectorView.get())); >+#else > if (gtk_bin_get_child(GTK_BIN(m_parentWindow)) == GTK_WIDGET(m_webView)) { > GRefPtr<WebKitWebView> inspectedView = m_webView; > gtk_container_remove(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView)); >@@ -273,6 +302,7 @@ public: > pane = gtk_bin_get_child(GTK_BIN(m_parentWindow)); > gtk_paned_set_position(GTK_PANED(pane), webkit_web_inspector_get_attached_height(m_inspector)); > gtk_paned_add2(GTK_PANED(pane), GTK_WIDGET(inspectorView.get())); >+#endif > > return InspectorTest::attach(); > } >@@ -280,17 +310,26 @@ public: > bool detach() > { > GRefPtr<WebKitWebViewBase> inspectorView = webkit_web_inspector_get_web_view(m_inspector); >+#if USE(GTK4) >+ GtkWidget* pane = gtk_window_get_child(GTK_WINDOW(m_parentWindow)); >+ g_assert_true(GTK_IS_PANED(pane)); >+ gtk_paned_set_end_child(GTK_PANED(pane), nullptr); >+#else > GtkWidget* pane = gtk_bin_get_child(GTK_BIN(m_parentWindow)); > g_assert_true(GTK_IS_PANED(pane)); > gtk_container_remove(GTK_CONTAINER(pane), GTK_WIDGET(inspectorView.get())); >+#endif > return InspectorTest::detach(); > } > > void destroyWindow() > { > g_assert_nonnull(m_inspectorWindow); >- gtk_widget_destroy(m_inspectorWindow); >- m_inspectorWindow = 0; >+#if USE(GTK4) >+ g_clear_pointer(&m_inspectorWindow, gtk_window_destroy); >+#else >+ g_clear_pointer(&m_inspectorWindow, gtk_widget_destroy); >+#endif > } > > GtkWidget* m_inspectorWindow; >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp b/Tools/TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp >index 7d93c79c9119..533d00479d39 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGtk/TestPrinting.cpp >@@ -19,6 +19,7 @@ > > #include "config.h" > #include "WebViewTest.h" >+#include <WebCore/GtkVersioning.h> > #include <glib/gstdio.h> > #include <wtf/glib/GRefPtr.h> > >diff --git a/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp b/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp >index 752e804c7066..578f4812339e 100644 >--- a/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp >+++ b/Tools/TestWebKitAPI/Tests/WebKitGtk/TestWebViewEditor.cpp >@@ -21,23 +21,102 @@ > #include "WebViewTest.h" > #include <wtf/glib/GRefPtr.h> > >+class Clipboard { >+public: >+ Clipboard(GMainLoop* loop) >+ : m_mainLoop(loop) >+#if USE(GTK4) >+ , m_clipboard(gdk_display_get_clipboard(gdk_display_get_default())) >+#else >+ , m_clipboard(gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD)) >+#endif >+ { >+ } >+ >+ void clear() >+ { >+#if USE(GTK4) >+ g_assert_true(gdk_clipboard_set_content(m_clipboard, nullptr)); >+#else >+ gtk_clipboard_clear(m_clipboard); >+#endif >+ m_text = nullptr; >+ } >+ >+ bool containsText() const >+ { >+#if USE(GTK4) >+ return gdk_content_formats_contain_gtype(gdk_clipboard_get_formats(m_clipboard), G_TYPE_STRING); >+#else >+ return gtk_clipboard_wait_is_text_available(m_clipboard); >+#endif >+ } >+ >+ bool waitForText() >+ { >+ // There's no way to know when the selection has been written to >+ // the clipboard, so use a timeout source to query the clipboard. >+ static const unsigned kClipboardWaitTimeout = 50; >+ static const unsigned kClipboardWaitMaxTries = 2; >+ m_triesCount = 0; >+ g_timeout_add(kClipboardWaitTimeout, [](gpointer userData) -> gboolean { >+ auto* clipboard = static_cast<Clipboard*>(userData); >+ clipboard->m_triesCount++; >+ if (clipboard->containsText() || clipboard->m_triesCount > kClipboardWaitMaxTries) { >+ g_main_loop_quit(clipboard->m_mainLoop); >+ return FALSE; >+ } >+ return TRUE; >+ }, this); >+ g_main_loop_run(m_mainLoop); >+ return containsText(); >+ } >+ >+ const char* readText() >+ { >+ m_text = nullptr; >+ if (waitForText()) { >+#if USE(GTK4) >+ gdk_clipboard_read_text_async(m_clipboard, nullptr, [](GObject* gdkClipboard, GAsyncResult* result, gpointer userData) { >+ auto* clipboard = static_cast<Clipboard*>(userData); >+ clipboard->m_text.reset(gdk_clipboard_read_text_finish(GDK_CLIPBOARD(gdkClipboard), result, nullptr)); >+ g_main_loop_quit(clipboard->m_mainLoop); >+ }, this); >+ g_main_loop_run(m_mainLoop); >+#else >+ m_text.reset(gtk_clipboard_wait_for_text(m_clipboard)); >+#endif >+ } >+ return m_text.get(); >+ } >+ >+private: >+ GMainLoop* m_mainLoop { nullptr }; >+#if USE(GTK4) >+ GdkClipboard* m_clipboard { nullptr }; >+#else >+ GtkClipboard* m_clipboard { nullptr }; >+#endif >+ GUniquePtr<char> m_text; >+ unsigned m_triesCount { 0 }; >+}; >+ > class EditorTest: public WebViewTest { > public: > MAKE_GLIB_TEST_FIXTURE(EditorTest); > >- static const unsigned kClipboardWaitTimeout = 50; >- static const unsigned kClipboardWaitMaxTries = 2; >- > EditorTest() >- : m_clipboard(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD)) >- , m_canExecuteEditingCommand(false) >- , m_triesCount(0) >- , m_editorState(nullptr) >+ : m_clipboard(m_mainLoop) > { > showInWindow(); >+ m_clipboard.clear(); > loadURI("about:blank"); > waitUntilLoadFinished(); >- gtk_clipboard_clear(m_clipboard); >+ } >+ >+ ~EditorTest() >+ { >+ m_clipboard.clear(); > } > > static gboolean webViewDrawCallback(GMainLoop* mainLoop) >@@ -48,10 +127,20 @@ public: > > void flushEditorState() > { >+#if USE(GTK4) >+ auto* surface = gtk_native_get_surface(gtk_widget_get_native(GTK_WIDGET(m_webView))); >+ auto* clock = gdk_surface_get_frame_clock(surface); >+ auto signalID = g_signal_connect_swapped(clock, "paint", G_CALLBACK(webViewDrawCallback), m_mainLoop); >+#else > auto signalID = g_signal_connect_swapped(m_webView, "draw", G_CALLBACK(webViewDrawCallback), m_mainLoop); >+#endif > gtk_widget_queue_draw(GTK_WIDGET(m_webView)); > g_main_loop_run(m_mainLoop); >+#if USE(GTK4) >+ g_signal_handler_disconnect(clock, signalID); >+#else > g_signal_handler_disconnect(m_webView, signalID); >+#endif > } > > static void canExecuteEditingCommandReadyCallback(GObject*, GAsyncResult* result, EditorTest* test) >@@ -84,41 +173,20 @@ public: > return m_canExecuteEditingCommand; > } > >- static gboolean waitForClipboardText(EditorTest* test) >- { >- test->m_triesCount++; >- if (gtk_clipboard_wait_is_text_available(test->m_clipboard) || test->m_triesCount > kClipboardWaitMaxTries) { >- g_main_loop_quit(test->m_mainLoop); >- return FALSE; >- } >- >- return TRUE; >- } >- >- void copyClipboard() >+ const char* copyClipboard() > { > webkit_web_view_execute_editing_command(m_webView, WEBKIT_EDITING_COMMAND_COPY); >- // There's no way to know when the selection has been copied to >- // the clipboard, so use a timeout source to query the clipboard. >- m_triesCount = 0; >- g_timeout_add(kClipboardWaitTimeout, reinterpret_cast<GSourceFunc>(waitForClipboardText), this); >- g_main_loop_run(m_mainLoop); >+ return m_clipboard.readText(); > } > >- gchar* cutSelection() >+ const char* cutSelection() > { > g_assert_true(canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT)); > g_assert_true(canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE)); > g_assert_true(canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE_AS_PLAIN_TEXT)); > > webkit_web_view_execute_editing_command(m_webView, WEBKIT_EDITING_COMMAND_CUT); >- // There's no way to know when the selection has been cut to >- // the clipboard, so use a timeout source to query the clipboard. >- m_triesCount = 0; >- g_timeout_add(kClipboardWaitTimeout, reinterpret_cast<GSourceFunc>(waitForClipboardText), this); >- g_main_loop_run(m_mainLoop); >- >- return gtk_clipboard_wait_for_text(m_clipboard); >+ return m_clipboard.readText(); > } > > WebKitEditorState* editorState() >@@ -149,10 +217,9 @@ public: > return typingAttributes(); > } > >- GtkClipboard* m_clipboard; >- bool m_canExecuteEditingCommand; >- size_t m_triesCount; >- WebKitEditorState* m_editorState; >+ Clipboard m_clipboard; >+ bool m_canExecuteEditingCommand { false }; >+ WebKitEditorState* m_editorState { nullptr }; > }; > > static const char* selectedSpanHTMLFormat = >@@ -182,9 +249,7 @@ static void testWebViewEditorCutCopyPasteNonEditable(EditorTest* test, gconstpoi > g_assert_false(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE)); > g_assert_false(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE_AS_PLAIN_TEXT)); > >- test->copyClipboard(); >- GUniquePtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard)); >- g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull"); >+ g_assert_cmpstr(test->copyClipboard(), ==, "make Jack a dull"); > } > > static void testWebViewEditorCutCopyPasteEditable(EditorTest* test, gconstpointer) >@@ -210,9 +275,7 @@ static void testWebViewEditorCutCopyPasteEditable(EditorTest* test, gconstpointe > g_assert_true(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE)); > g_assert_true(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE_AS_PLAIN_TEXT)); > >- test->copyClipboard(); >- GUniquePtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard)); >- g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull"); >+ g_assert_cmpstr(test->copyClipboard(), ==, "make Jack a dull"); > } > > static void testWebViewEditorSelectAllNonEditable(EditorTest* test, gconstpointer) >@@ -226,18 +289,12 @@ static void testWebViewEditorSelectAllNonEditable(EditorTest* test, gconstpointe > > g_assert_true(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL)); > >- test->copyClipboard(); >- GUniquePtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard)); >- > // Initially only the subspan is selected. >- g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull"); >+ g_assert_cmpstr(test->copyClipboard(), ==, "make Jack a dull"); > > webkit_web_view_execute_editing_command(test->m_webView, WEBKIT_EDITING_COMMAND_SELECT_ALL); >- test->copyClipboard(); >- clipboardText.reset(gtk_clipboard_wait_for_text(test->m_clipboard)); >- > // The mainspan should be selected after calling SELECT_ALL. >- g_assert_cmpstr(clipboardText.get(), ==, "All work and no play make Jack a dull boy."); >+ g_assert_cmpstr(test->copyClipboard(), ==, "All work and no play make Jack a dull boy."); > } > > static void testWebViewEditorSelectAllEditable(EditorTest* test, gconstpointer) >@@ -255,18 +312,12 @@ static void testWebViewEditorSelectAllEditable(EditorTest* test, gconstpointer) > > g_assert_true(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_SELECT_ALL)); > >- test->copyClipboard(); >- GUniquePtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard)); >- > // Initially only the subspan is selected. >- g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull"); >+ g_assert_cmpstr(test->copyClipboard(), ==, "make Jack a dull"); > > webkit_web_view_execute_editing_command(test->m_webView, WEBKIT_EDITING_COMMAND_SELECT_ALL); >- test->copyClipboard(); >- clipboardText.reset(gtk_clipboard_wait_for_text(test->m_clipboard)); >- > // The mainspan should be selected after calling SELECT_ALL. >- g_assert_cmpstr(clipboardText.get(), ==, "All work and no play make Jack a dull boy."); >+ g_assert_cmpstr(test->copyClipboard(), ==, "All work and no play make Jack a dull boy."); > } > > static void loadContentsAndTryToCutSelection(EditorTest* test, bool contentEditable) >@@ -286,8 +337,7 @@ static void loadContentsAndTryToCutSelection(EditorTest* test, bool contentEdita > test->flushEditorState(); > > // Cut the selection to the clipboard to see if the view is indeed editable. >- GUniquePtr<char> clipboardText(test->cutSelection()); >- g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull"); >+ g_assert_cmpstr(test->cutSelection(), ==, "make Jack a dull"); > > // Reset the editable for next test. > test->setEditable(false); >diff --git a/Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.h b/Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.h >index e0f6cea96134..1445311f6f86 100644 >--- a/Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.h >+++ b/Tools/TestWebKitAPI/glib/WebKitGLib/TestMain.h >@@ -138,7 +138,9 @@ public: > "website-data-manager", websiteDataManager.get(), > #if PLATFORM(GTK) > "process-swap-on-cross-site-navigation-enabled", TRUE, >+#if !USE(GTK4) > "use-system-appearance-for-scrollbars", FALSE, >+#endif > #endif > nullptr))); > assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_webContext.get())); >diff --git a/Tools/TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp b/Tools/TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp >index 03cf90481b57..51bf38a11e6d 100644 >--- a/Tools/TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp >+++ b/Tools/TestWebKitAPI/glib/WebKitGLib/gtk/WebViewTestGtk.cpp >@@ -28,8 +28,13 @@ > > void WebViewTest::platformDestroy() > { >+#if USE(GTK4) >+ if (m_parentWindow) >+ gtk_window_destroy(GTK_WINDOW(m_parentWindow)); >+#else > if (m_parentWindow) > gtk_widget_destroy(m_parentWindow); >+#endif > } > > void WebViewTest::platformInitializeWebView() >@@ -65,11 +70,18 @@ void WebViewTest::hideView() > void WebViewTest::showInWindow(int width, int height) > { > g_assert_null(m_parentWindow); >+#if USE(GTK4) >+ m_parentWindow = gtk_window_new(); >+ gtk_window_set_child(GTK_WINDOW(m_parentWindow), GTK_WIDGET(m_webView)); >+#else > m_parentWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); >- if (width && height) >- gtk_window_set_default_size(GTK_WINDOW(m_parentWindow), width, height); > gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView)); > gtk_widget_show(GTK_WIDGET(m_webView)); >+#endif >+ >+ if (width && height) >+ gtk_window_set_default_size(GTK_WINDOW(m_parentWindow), width, height); >+ > gtk_widget_show(m_parentWindow); > > while (g_main_context_pending(nullptr)) >diff --git a/Tools/TestWebKitAPI/gtk/PlatformUtilitiesGtk.cpp b/Tools/TestWebKitAPI/gtk/PlatformUtilitiesGtk.cpp >index 3fac9d7d7fe2..3773ee2b07ee 100644 >--- a/Tools/TestWebKitAPI/gtk/PlatformUtilitiesGtk.cpp >+++ b/Tools/TestWebKitAPI/gtk/PlatformUtilitiesGtk.cpp >@@ -68,7 +68,7 @@ WKURLRef URLForNonExistentResource() > > bool isKeyDown(WKNativeEventPtr event) > { >- return event->type == GDK_KEY_PRESS; >+ return gdk_event_get_event_type(const_cast<GdkEvent*>(event)) == GDK_KEY_PRESS; > } > > } // namespace Util >diff --git a/Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp b/Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp >index 5293296dc748..5b3ec6fe3a29 100644 >--- a/Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp >+++ b/Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp >@@ -62,15 +62,24 @@ PlatformWebView::PlatformWebView(WKPageRef relatedPage) > > PlatformWebView::~PlatformWebView() > { >+#if USE(GTK4) >+ gtk_window_destroy(GTK_WINDOW(m_window)); >+#else > gtk_widget_destroy(m_window); >+#endif > } > > void PlatformWebView::initialize(WKPageConfigurationRef configuration) > { >- m_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); > m_view = WKViewCreate(configuration); >+#if USE(GTK4) >+ m_window = gtk_window_new(); >+ gtk_window_set_child(GTK_WINDOW(m_window), GTK_WIDGET(m_view)); >+#else >+ m_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); > gtk_container_add(GTK_CONTAINER(m_window), GTK_WIDGET(m_view)); > gtk_widget_show(GTK_WIDGET(m_view)); >+#endif > gtk_widget_show(m_window); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 214344
:
404327
|
405556
| 405557