From 4476bd646dfe661f6b6fe26c08bb9b8b4c3ee5ea Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 21 Oct 2017 23:14:43 +0200 Subject: [PATCH] Get rid of separate JSResultToString() function This function was used only once and didn't really help understanding the code and just required extra casts when passing arguments to it, for some reason. Just merge it into RunScriptSync() itself. --- src/gtk/webview_webkit2.cpp | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/gtk/webview_webkit2.cpp b/src/gtk/webview_webkit2.cpp index 47afb82094..e451f6f236 100644 --- a/src/gtk/webview_webkit2.cpp +++ b/src/gtk/webview_webkit2.cpp @@ -1107,10 +1107,23 @@ static void wxgtk_run_javascript_cb(WebKitWebView *, *res_out = res; } -bool JSResultToString(GObject *object, GAsyncResult *result, wxString* output) +// Run the given script synchronously and return its result in output. +bool wxWebViewWebKit::RunScriptSync(const wxString& javascript, wxString* output) { + GAsyncResult *result = NULL; + webkit_web_view_run_javascript(m_web_view, + javascript, + NULL, + (GAsyncReadyCallback)wxgtk_run_javascript_cb, + &result); + + GMainContext *main_context = g_main_context_get_thread_default(); + + while ( !result ) + g_main_context_iteration(main_context, TRUE); + wxGtkError error; - wxWebKitJavascriptResult js_result(webkit_web_view_run_javascript_finish(WEBKIT_WEB_VIEW (object), + wxWebKitJavascriptResult js_result(webkit_web_view_run_javascript_finish(WEBKIT_WEB_VIEW (m_web_view), (GAsyncResult *)result, error.Out())); if ( !js_result ) @@ -1141,24 +1154,6 @@ bool JSResultToString(GObject *object, GAsyncResult *result, wxString* output) return true; } -// Run the given script synchronously and return its result in output. -bool wxWebViewWebKit::RunScriptSync(const wxString& javascript, wxString* output) -{ - GAsyncResult *result = NULL; - webkit_web_view_run_javascript(m_web_view, - javascript, - NULL, - (GAsyncReadyCallback)wxgtk_run_javascript_cb, - &result); - - GMainContext *main_context = g_main_context_get_thread_default(); - - while ( !result ) - g_main_context_iteration(main_context, TRUE); - - return JSResultToString((GObject*)m_web_view, result, output); -} - bool wxWebViewWebKit::RunScript(const wxString& javascript, wxString* output) { wxJSScriptWrapper wrapJS(javascript, &m_runScriptCount);