[packages/gtk-webkit5] backport more glib api fixes

atler atler at pld-linux.org
Sun Jan 19 17:56:54 CET 2025


commit 7624f77baa8a13c9cf0a068f58068019e8f687a3
Author: Jan Palus <atler at pld-linux.org>
Date:   Sun Jan 19 17:28:24 2025 +0100

    backport more glib api fixes

 glib-api-closure.patch => glib-api.patch | 192 +++++++++++++++++++++++++++++++
 gtk-webkit5.spec                         |   4 +-
 2 files changed, 194 insertions(+), 2 deletions(-)
---
diff --git a/gtk-webkit5.spec b/gtk-webkit5.spec
index f33a1b0..99aebde 100644
--- a/gtk-webkit5.spec
+++ b/gtk-webkit5.spec
@@ -32,7 +32,7 @@ Patch2:		%{name}-parallel-gir.patch
 Patch3:		%{name}-driver-version-suffix.patch
 Patch4:		%{name}-gcc13.patch
 Patch5:		icu76.patch
-Patch6:		glib-api-closure.patch
+Patch6:		glib-api.patch
 Patch7:		libxml-2.12.patch
 URL:		https://webkitgtk.org/
 BuildRequires:	/usr/bin/ld.gold
@@ -54,7 +54,7 @@ BuildRequires:	gettext-tools
 BuildRequires:	gi-docgen
 BuildRequires:	glib2-devel >= 1:2.67.1
 BuildRequires:	glibc-misc
-%{?with_introspection:BuildRequires:	gobject-introspection-devel >= 1.32.0}
+%{?with_introspection:BuildRequires:	gobject-introspection-devel >= 1.79.2}
 BuildRequires:	gperf >= 3.0.1
 BuildRequires:	gstreamer-devel >= 1.14
 BuildRequires:	gstreamer-gl-devel >= 1.10.0
diff --git a/glib-api-closure.patch b/glib-api.patch
similarity index 76%
rename from glib-api-closure.patch
rename to glib-api.patch
index 08ce6b7..666869b 100644
--- a/glib-api-closure.patch
+++ b/glib-api.patch
@@ -512,3 +512,195 @@ index efc7ddddeacbe..60d7b1f2009ce 100644
   *
   * Send @message to the #WebKitWebView corresponding to @web_page. If @message is floating, it's consumed.
   *
+From 910ab18a82d45d05c146999c32b0c517bf78b56a Mon Sep 17 00:00:00 2001
+From: Michael Catanzaro <mcatanzaro at redhat.com>
+Date: Tue, 12 Mar 2024 17:19:44 -0700
+Subject: [PATCH] [WPE][GTK] Warning: WebKit2: Couldn't find
+ 'run_async_javascript_function_in_world_finish' for the corresponding async
+ function: 'run_async_javascript_function_in_world'
+ https://bugs.webkit.org/show_bug.cgi?id=269377
+
+Reviewed by Adrian Perez de Castro.
+
+We need to use the new finish-func annotation so that language bindings
+can figure out how to complete the async call, due to our nonstandard
+naming for the finish function. It seems trying to reuse the same finish
+function for multiple async calls was not such a good idea.
+
+Unfortunately, with older gobject-introspection, we cannot use this
+new annotation or the build will fail due to the unrecognized
+annotation. So we will need to conditionalize the entire doc comment.
+
+Finally, I've also fixed the nullability of the world_name parameter,
+which was broken due to a missing colon.
+
+* Source/WebKit/PlatformGTK.cmake:
+* Source/WebKit/PlatformWPE.cmake:
+* Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp:
+* Source/WebKit/UIProcess/API/glib/WebKitWebView.h.in:
+
+Canonical link: https://commits.webkit.org/276012@main
+---
+ Source/WebKit/PlatformGTK.cmake               |   8 +
+ Source/WebKit/PlatformWPE.cmake               |   8 +
+ .../UIProcess/API/glib/WebKitWebView.cpp      |  69 ---------
+ .../UIProcess/API/glib/WebKitWebView.h.in     | 142 ++++++++++++++++++
+ 4 files changed, 158 insertions(+), 69 deletions(-)
+
+diff --git a/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp b/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
+index 989bea31f5a05..b309ffff12b14 100644
+--- a/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
++++ b/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
+@@ -4489,73 +4489,6 @@ void webkit_web_view_run_javascript_in_world(WebKitWebView* webView, const gchar
+     });
+ }
+ 
+-/*
+- * webkit_web_view_run_async_javascript_function_in_world:
+- * @web_view: a #WebKitWebView
+- * @body: the JavaScript function body
+- * @arguments: a #GVariant with format `{&sv}` storing the function arguments. Function argument values must be one of the following types, or contain only the following GVariant types: number, string, array, and dictionary.
+- * @world_name (nullable): the name of a #WebKitScriptWorld, if no name (i.e. %NULL) is provided, the default world is used. Any value that is not %NULL is a distinct world.
+- * @cancellable: (allow-none): a #GCancellable or %NULL to ignore
+- * @callback: (scope async): a #GAsyncReadyCallback to call when the script finished
+- * @user_data: the data to pass to callback function
+- *
+- * Asynchronously run @body in the script world with name @world_name of the current page context in
+- * @web_view. If WebKitSettings:enable-javascript is FALSE, this method will do nothing. This API
+- * differs from webkit_web_view_run_javascript_in_world() in that the JavaScript function can return a
+- * Promise and its result will be properly passed to the callback.
+- *
+- * When the operation is finished, @callback will be called. You can then call
+- * webkit_web_view_run_javascript_in_world_finish() to get the result of the operation.
+- *
+- * For instance here is a dummy example that shows how to pass arguments to a JS function that
+- * returns a Promise that resolves with the passed argument:
+- *
+- * ```c
+- * static void
+- * web_view_javascript_finished (GObject      *object,
+- *                               GAsyncResult *result,
+- *                               gpointer      user_data)
+- * {
+- *     WebKitJavascriptResult *js_result;
+- *     JSCValue               *value;
+- *     GError                 *error = NULL;
+- *
+- *     js_result = webkit_web_view_run_javascript_finish (WEBKIT_WEB_VIEW (object), result, &error);
+- *     if (!js_result) {
+- *         g_warning ("Error running javascript: %s", error->message);
+- *         g_error_free (error);
+- *         return;
+- *     }
+- *
+- *     value = webkit_javascript_result_get_js_value (js_result);
+- *     if (jsc_value_is_number (value)) {
+- *         gint32        int_value = jsc_value_to_string (value);
+- *         JSCException *exception = jsc_context_get_exception (jsc_value_get_context (value));
+- *         if (exception)
+- *             g_warning ("Error running javascript: %s", jsc_exception_get_message (exception));
+- *         else
+- *             g_print ("Script result: %d\n", int_value);
+- *         g_free (str_value);
+- *     } else {
+- *         g_warning ("Error running javascript: unexpected return value");
+- *     }
+- *     webkit_javascript_result_unref (js_result);
+- * }
+- *
+- * static void
+- * web_view_evaluate_promise (WebKitWebView *web_view)
+- * {
+- *     GVariantDict dict;
+- *     g_variant_dict_init (&dict, NULL);
+- *     g_variant_dict_insert (&dict, "count", "u", 42);
+- *     GVariant *args = g_variant_dict_end (&dict);
+- *     const gchar *body = "return new Promise((resolve) => { resolve(count); });";
+- *     webkit_web_view_run_async_javascript_function_in_world (web_view, body, arguments, NULL, NULL, web_view_javascript_finished, NULL);
+- * }
+- * ```
+- *
+- * Since: 2.38
+- */
+ void webkit_web_view_run_async_javascript_function_in_world(WebKitWebView* webView, const gchar* body, GVariant* arguments, const char* worldName, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
+ {
+     g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+diff --git a/Source/WebKit/UIProcess/API/glib/WebKitWebView.h.in b/Source/WebKit/UIProcess/API/glib/WebKitWebView.h.in
+index 959dd985c1664..f385fd67b1074 100644
+--- a/Source/WebKit/UIProcess/API/gtk/WebKitWebView.h
++++ b/Source/WebKit/UIProcess/API/gtk/WebKitWebView.h
+@@ -905,6 +905,74 @@ webkit_web_view_get_web_extension_mode               (WebKitWebView
+ WEBKIT_API const gchar*
+ webkit_web_view_get_default_content_security_policy  (WebKitWebView             *web_view);
+ 
++/*
++ * webkit_web_view_run_async_javascript_function_in_world: (finish-func webkit_web_view_run_javascript_in_world_finish)
++ * @web_view: a #WebKitWebView
++ * @body: the JavaScript function body
++ * @arguments: a #GVariant with format `{&sv}` storing the function arguments. Function argument values must be one of the following types, or contain only the following GVariant types: number, string, array, and dictionary.
++ * @world_name: (nullable): the name of a #WebKitScriptWorld, if no name (i.e. %NULL) is provided, the default world is used. Any value that is not %NULL is a distinct world.
++ * @cancellable: (allow-none): a #GCancellable or %NULL to ignore
++ * @callback: (scope async): a #GAsyncReadyCallback to call when the script finished
++ * @user_data: the data to pass to callback function
++ *
++ * Asynchronously run @body in the script world with name @world_name of the current page context in
++ * @web_view. If WebKitSettings:enable-javascript is FALSE, this method will do nothing. This API
++ * differs from webkit_web_view_run_javascript_in_world() in that the JavaScript function can return a
++ * Promise and its result will be properly passed to the callback.
++ *
++ * When the operation is finished, @callback will be called. You can then call
++ * webkit_web_view_run_javascript_in_world_finish() to get the result of the operation.
++ *
++ * For instance here is a dummy example that shows how to pass arguments to a JS function that
++ * returns a Promise that resolves with the passed argument:
++ *
++ * ```c
++ * static void
++ * web_view_javascript_finished (GObject      *object,
++ *                               GAsyncResult *result,
++ *                               gpointer      user_data)
++ * {
++ *     WebKitJavascriptResult *js_result;
++ *     JSCValue               *value;
++ *     GError                 *error = NULL;
++ *
++ *     js_result = webkit_web_view_run_javascript_finish (WEBKIT_WEB_VIEW (object), result, &error);
++ *     if (!js_result) {
++ *         g_warning ("Error running javascript: %s", error->message);
++ *         g_error_free (error);
++ *         return;
++ *     }
++ *
++ *     value = webkit_javascript_result_get_js_value (js_result);
++ *     if (jsc_value_is_number (value)) {
++ *         gint32        int_value = jsc_value_to_string (value);
++ *         JSCException *exception = jsc_context_get_exception (jsc_value_get_context (value));
++ *         if (exception)
++ *             g_warning ("Error running javascript: %s", jsc_exception_get_message (exception));
++ *         else
++ *             g_print ("Script result: %d\n", int_value);
++ *         g_free (str_value);
++ *     } else {
++ *         g_warning ("Error running javascript: unexpected return value");
++ *     }
++ *     webkit_javascript_result_unref (js_result);
++ * }
++ *
++ * static void
++ * web_view_evaluate_promise (WebKitWebView *web_view)
++ * {
++ *     GVariantDict dict;
++ *     g_variant_dict_init (&dict, NULL);
++ *     g_variant_dict_insert (&dict, "count", "u", 42);
++ *     GVariant *args = g_variant_dict_end (&dict);
++ *     const gchar *body = "return new Promise((resolve) => { resolve(count); });";
++ *     webkit_web_view_run_async_javascript_function_in_world (web_view, body, arguments, NULL, NULL, web_view_javascript_finished, NULL);
++ * }
++ * ```
++ *
++ * Since: 2.38
++ */
++
+ G_END_DECLS
+ 
+ #endif
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/gtk-webkit5.git/commitdiff/7624f77baa8a13c9cf0a068f58068019e8f687a3



More information about the pld-cvs-commit mailing list