diff options
author | Peter Hofmann <scm@uninformativ.de> | 2019-03-31 09:23:25 +0200 |
---|---|---|
committer | Peter Hofmann <scm@uninformativ.de> | 2019-03-31 09:23:25 +0200 |
commit | 2f392f33c9366218c12f283b349b8000edf89e0a (patch) | |
tree | 2a7be4790c9b8a36e3fa9b7f110c470b67ee8ae8 | |
parent | 054e92a9688058e15a2fa0af4623e095bb346008 (diff) | |
download | lariza-2f392f33c9366218c12f283b349b8000edf89e0a.tar.gz |
No longer use WebKit's deprecated JavaScript API
-rw-r--r-- | BUGS | 5 | ||||
-rw-r--r-- | CHANGES | 4 | ||||
-rw-r--r-- | browser.c | 31 |
3 files changed, 21 insertions, 19 deletions
@@ -1,5 +0,0 @@ -Deprecated JS functions in WebKit -================================= - -'webkit_javascript_result_get_global_context' and -'webkit_javascript_result_get_value' are deprecated. @@ -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. @@ -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, |