Skip to content

Commit

Permalink
[WebKitBrowser] Updating methods deprecated since 2.42 WebKit API (#267)
Browse files Browse the repository at this point in the history
* webkit_console_message_get_text() is deprecated with 2.42 and there is no substitute so far

* webkit_web_view_run_javascript() replaced by webkit_web_view_evaluate_javascript() in 2.42
  • Loading branch information
VeithMetro authored Dec 1, 2023
1 parent 23434bf commit 7715e00
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions WebKitBrowser/Extension/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,17 @@ static class PluginHost {
G_CALLBACK(didStartProvisionalLoadForFrame), nullptr);
#endif
}

PUSH_WARNING(DISABLE_WARNING_DEPRECATED_USE)
static void consoleMessageSentCallback(VARIABLE_IS_NOT_USED WebKitWebPage* page, WebKitConsoleMessage* message, PluginHost* host)
{
string messageString = Core::ToString(webkit_console_message_get_text(message));
uint64_t line = static_cast<uint64_t>(webkit_console_message_get_line(message));

TRACE_GLOBAL(BrowserConsoleLog, (host->_consoleLogPrefix, messageString, line, 0));
}
POP_WARNING()

static gboolean userMessageReceivedCallback(WebKitWebPage* page, WebKitUserMessage* message)
{
const char* name = webkit_user_message_get_name(message);
Expand Down
7 changes: 7 additions & 0 deletions WebKitBrowser/WebKitImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,14 @@ static GSourceFuncs _handlerIntervention =
WebKitImplementation* object = std::get<0>(data);
auto& script = std::get<1>(data);
#ifdef WEBKIT_GLIB_API

#if WEBKIT_CHECK_VERSION(2, 42, 0)
// length: size of script, or -1 if script is a nul-terminated string
webkit_web_view_evaluate_javascript(object->_view, script.c_str(), -1, nullptr, nullptr, nullptr, nullptr, nullptr);
#else
webkit_web_view_run_javascript(object->_view, script.c_str(), nullptr, nullptr, nullptr);
#endif

#else
auto scriptRef = WKStringCreateWithUTF8CString(script.c_str());
WKPageRunJavaScriptInMainFrame(object->_page, scriptRef, nullptr, [](WKSerializedScriptValueRef, WKErrorRef, void*){});
Expand Down

0 comments on commit 7715e00

Please sign in to comment.