]> git.armaanb.net Git - chorizo.git/commitdiff
No longer use WebKit's deprecated JavaScript API
authorPeter Hofmann <scm@uninformativ.de>
Sun, 31 Mar 2019 07:23:25 +0000 (09:23 +0200)
committerPeter Hofmann <scm@uninformativ.de>
Sun, 31 Mar 2019 07:23:25 +0000 (09:23 +0200)
BUGS [deleted file]
CHANGES
browser.c

diff --git a/BUGS b/BUGS
deleted file mode 100644 (file)
index 1bf801c..0000000
--- a/BUGS
+++ /dev/null
@@ -1,5 +0,0 @@
-Deprecated JS functions in WebKit
-=================================
-
-'webkit_javascript_result_get_global_context' and
-'webkit_javascript_result_get_value' are deprecated.
diff --git a/CHANGES b/CHANGES
index 07e1fc6cc5264985e534c38147deaa618eba47a6..06f7080d13b0f966a0fb2c5cf5665e9e50f44484 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,9 @@
 Release history for lariza
 
+next
+  [Fixed]
+  - We no longer use WebKit's deprecated JavaScript API.
+
 v18.07  2018-07-29
   [Added]
   - The input bar now shows an indicator for web feeds.
index ed1457501d1dff75d214eb1799d808b5c355c414..6d022e543faf9952504218d92175b2f306b46174 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -678,17 +678,18 @@ grab_feeds_finished(GObject *object, GAsyncResult *result, gpointer data)
 {
     struct Client *c = (struct Client *)data;
     WebKitJavascriptResult *js_result;
-    JSValueRef value;
-    JSGlobalContextRef context;
+    JSCValue *value;
+    JSCException *exception;
     GError *err = NULL;
-    JSStringRef js_str_value;
-    gsize str_length;
+    gchar *str_value;
 
     g_free(c->feed_html);
     c->feed_html = NULL;
 
     /* This was taken almost verbatim from the example in WebKit's
-     * documentation. */
+     * documentation:
+     *
+     * https://webkitgtk.org/reference/webkit2gtk/stable/WebKitWebView.html#webkit-web-view-run-javascript-finish */
 
     js_result = webkit_web_view_run_javascript_finish(WEBKIT_WEB_VIEW(object),
                                                       result, &err);
@@ -699,16 +700,18 @@ grab_feeds_finished(GObject *object, GAsyncResult *result, gpointer data)
         return;
     }
 
-    context = webkit_javascript_result_get_global_context(js_result);
-    value = webkit_javascript_result_get_value(js_result);
-
-    if (JSValueIsString(context, value))
+    value = webkit_javascript_result_get_js_value(js_result);
+    if (jsc_value_is_string(value))
     {
-        js_str_value = JSValueToStringCopy(context, value, NULL);
-        str_length = JSStringGetMaximumUTF8CStringSize(js_str_value);
-        c->feed_html = (gchar *)g_malloc(str_length);
-        JSStringGetUTF8CString(js_str_value, c->feed_html, str_length);
-        JSStringRelease(js_str_value);
+        str_value = jsc_value_to_string(value);
+        exception = jsc_context_get_exception(jsc_value_get_context(value));
+        if (exception != NULL)
+        {
+            fprintf(stderr, __NAME__": Error running javascript: %s\n",
+                    jsc_exception_get_message(exception));
+        }
+        else
+            c->feed_html = str_value;
 
         gtk_entry_set_icon_from_icon_name(GTK_ENTRY(c->location),
                                           GTK_ENTRY_ICON_PRIMARY,