Add support for building WebView with libwebkit2gtk-4.1

libwebkit2gtk-4.1 has the same API as libwebkit2gtk-4.0, except that the
former links with libsoup-3.0 and the latter links with libsoup-2.4.

Fixes #23630.

(cherry picked from commit 1b8664426603376b68f8ca3c54de97ec630e5940)
This commit is contained in:
Scott Talbert 2023-06-12 20:28:35 -04:00 committed by Vadim Zeitlin
parent be772c284f
commit df46add116
6 changed files with 129 additions and 15 deletions

View File

@ -453,15 +453,21 @@ if(wxUSE_GUI)
if(wxUSE_WEBVIEW) if(wxUSE_WEBVIEW)
if(WXGTK) if(WXGTK)
if(wxUSE_WEBVIEW_WEBKIT) if(wxUSE_WEBVIEW_WEBKIT)
find_package(LIBSOUP) set(WEBKIT_LIBSOUP_VERSION 2.4)
if(WXGTK2) if(WXGTK2)
find_package(WEBKIT 1.0) find_package(WEBKIT 1.0)
elseif(WXGTK3) elseif(WXGTK3)
find_package(WEBKIT2) find_package(WEBKIT2 4.1 QUIET)
if(WEBKIT2_FOUND)
set(WEBKIT_LIBSOUP_VERSION 3.0)
else()
find_package(WEBKIT2 4.0)
endif()
if(NOT WEBKIT2_FOUND) if(NOT WEBKIT2_FOUND)
find_package(WEBKIT 3.0) find_package(WEBKIT 3.0)
endif() endif()
endif() endif()
find_package(LIBSOUP ${WEBKIT_LIBSOUP_VERSION})
endif() endif()
set(wxUSE_WEBVIEW_WEBKIT OFF) set(wxUSE_WEBVIEW_WEBKIT OFF)
set(wxUSE_WEBVIEW_WEBKIT2 OFF) set(wxUSE_WEBVIEW_WEBKIT2 OFF)

View File

@ -31,19 +31,27 @@
# LibSoup does not provide an easy way to retrieve its version other than its # LibSoup does not provide an easy way to retrieve its version other than its
# .pc file, so we need to rely on PC_LIBSOUP_VERSION and REQUIRE the .pc file # .pc file, so we need to rely on PC_LIBSOUP_VERSION and REQUIRE the .pc file
# to be found. # to be found.
SET(LIBSOUP_VERSION 2.4)
if(DEFINED LIBSOUP_FIND_VERSION)
SET(LIBSOUP_VERSION ${LIBSOUP_FIND_VERSION})
endif()
set(LIBSOUP_INCLUDE_DIRS LIBSOUP_INCLUDE_DIRS-NOTFOUND)
set(LIBSOUP_LIBRARIES LIBSOUP_LIBRARIES-NOTFOUND)
FIND_PACKAGE(PkgConfig) FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PC_LIBSOUP QUIET libsoup-2.4) PKG_CHECK_MODULES(PC_LIBSOUP QUIET libsoup-${LIBSOUP_VERSION})
if(PC_LIBSOUP_FOUND) if(PC_LIBSOUP_FOUND)
FIND_PATH(LIBSOUP_INCLUDE_DIRS FIND_PATH(LIBSOUP_INCLUDE_DIRS
NAMES libsoup/soup.h NAMES libsoup/soup.h
HINTS ${PC_LIBSOUP_INCLUDEDIR} HINTS ${PC_LIBSOUP_INCLUDEDIR}
${PC_LIBSOUP_INCLUDE_DIRS} ${PC_LIBSOUP_INCLUDE_DIRS}
PATH_SUFFIXES libsoup-2.4 PATH_SUFFIXES libsoup-${LIBSOUP_VERSION}
) )
FIND_LIBRARY(LIBSOUP_LIBRARIES FIND_LIBRARY(LIBSOUP_LIBRARIES
NAMES soup-2.4 NAMES soup-${LIBSOUP_VERSION}
HINTS ${PC_LIBSOUP_LIBDIR} HINTS ${PC_LIBSOUP_LIBDIR}
${PC_LIBSOUP_LIBRARY_DIRS} ${PC_LIBSOUP_LIBRARY_DIRS}
) )

View File

@ -6,6 +6,9 @@
# WEBKIT2_FOUND - True if Webkit2 found. # WEBKIT2_FOUND - True if Webkit2 found.
SET(WEBKIT2_VERSION 4.0) SET(WEBKIT2_VERSION 4.0)
if(DEFINED WEBKIT2_FIND_VERSION)
SET(WEBKIT2_VERSION ${WEBKIT2_FIND_VERSION})
endif()
set(WEBKIT2_INCLUDE_DIR WEBKIT2_INCLUDE_DIR-NOTFOUND) set(WEBKIT2_INCLUDE_DIR WEBKIT2_INCLUDE_DIR-NOTFOUND)
set(WEBKIT2_LIBRARY WEBKIT2_LIBRARY-NOTFOUND) set(WEBKIT2_LIBRARY WEBKIT2_LIBRARY-NOTFOUND)

89
configure vendored
View File

@ -41832,6 +41832,86 @@ pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for WEBKIT" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for WEBKIT" >&5
$as_echo_n "checking for WEBKIT... " >&6; } $as_echo_n "checking for WEBKIT... " >&6; }
if test -n "$PKG_CONFIG"; then
if test -n "$WEBKIT_CFLAGS"; then
pkg_cv_WEBKIT_CFLAGS="$WEBKIT_CFLAGS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"webkit2gtk-4.1\""; } >&5
($PKG_CONFIG --exists --print-errors "webkit2gtk-4.1") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_WEBKIT_CFLAGS=`$PKG_CONFIG --cflags "webkit2gtk-4.1" 2>/dev/null`
else
pkg_failed=yes
fi
fi
else
pkg_failed=untried
fi
if test -n "$PKG_CONFIG"; then
if test -n "$WEBKIT_LIBS"; then
pkg_cv_WEBKIT_LIBS="$WEBKIT_LIBS"
else
if test -n "$PKG_CONFIG" && \
{ { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"webkit2gtk-4.1\""; } >&5
($PKG_CONFIG --exists --print-errors "webkit2gtk-4.1") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then
pkg_cv_WEBKIT_LIBS=`$PKG_CONFIG --libs "webkit2gtk-4.1" 2>/dev/null`
else
pkg_failed=yes
fi
fi
else
pkg_failed=untried
fi
if test $pkg_failed = yes; then
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
_pkg_short_errors_supported=yes
else
_pkg_short_errors_supported=no
fi
if test $_pkg_short_errors_supported = yes; then
WEBKIT_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "webkit2gtk-4.1"`
else
WEBKIT_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "webkit2gtk-4.1"`
fi
# Put the nasty error message in config.log where it belongs
echo "$WEBKIT_PKG_ERRORS" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: webkit2gtk-4.1 not found, falling back to webkit2gtk-4.0" >&5
$as_echo "$as_me: WARNING: webkit2gtk-4.1 not found, falling back to webkit2gtk-4.0" >&2;}
elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: webkit2gtk-4.1 not found, falling back to webkit2gtk-4.0" >&5
$as_echo "$as_me: WARNING: webkit2gtk-4.1 not found, falling back to webkit2gtk-4.0" >&2;}
else
WEBKIT_CFLAGS=$pkg_cv_WEBKIT_CFLAGS
WEBKIT_LIBS=$pkg_cv_WEBKIT_LIBS
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
USE_WEBVIEW_WEBKIT2=1
CXXFLAGS="$CXXFLAGS $WEBKIT_CFLAGS"
EXTRALIBS_WEBVIEW="$WEBKIT_LIBS"
fi
if test "$USE_WEBVIEW_WEBKIT2" = 0; then
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for WEBKIT" >&5
$as_echo_n "checking for WEBKIT... " >&6; }
if test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG"; then
if test -n "$WEBKIT_CFLAGS"; then if test -n "$WEBKIT_CFLAGS"; then
pkg_cv_WEBKIT_CFLAGS="$WEBKIT_CFLAGS" pkg_cv_WEBKIT_CFLAGS="$WEBKIT_CFLAGS"
@ -41887,13 +41967,13 @@ fi
echo "$WEBKIT_PKG_ERRORS" >&5 echo "$WEBKIT_PKG_ERRORS" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: webkit2gtk not found, falling back to webkitgtk" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: webkit2gtk-4.0 not found, falling back to webkitgtk" >&5
$as_echo "$as_me: WARNING: webkit2gtk not found, falling back to webkitgtk" >&2;} $as_echo "$as_me: WARNING: webkit2gtk-4.0 not found, falling back to webkitgtk" >&2;}
elif test $pkg_failed = untried; then elif test $pkg_failed = untried; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: webkit2gtk not found, falling back to webkitgtk" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: webkit2gtk-4.0 not found, falling back to webkitgtk" >&5
$as_echo "$as_me: WARNING: webkit2gtk not found, falling back to webkitgtk" >&2;} $as_echo "$as_me: WARNING: webkit2gtk-4.0 not found, falling back to webkitgtk" >&2;}
else else
WEBKIT_CFLAGS=$pkg_cv_WEBKIT_CFLAGS WEBKIT_CFLAGS=$pkg_cv_WEBKIT_CFLAGS
@ -41905,6 +41985,7 @@ $as_echo "yes" >&6; }
CXXFLAGS="$CXXFLAGS $WEBKIT_CFLAGS" CXXFLAGS="$CXXFLAGS $WEBKIT_CFLAGS"
EXTRALIBS_WEBVIEW="$WEBKIT_LIBS" EXTRALIBS_WEBVIEW="$WEBKIT_LIBS"
fi
fi fi
fi fi
if test "$USE_WEBVIEW_WEBKIT2" = 0; then if test "$USE_WEBVIEW_WEBKIT2" = 0; then

View File

@ -7528,6 +7528,17 @@ if test "$wxUSE_WEBVIEW" = "yes"; then
if test "$wxUSE_WEBVIEW_WEBKIT" = "yes"; then if test "$wxUSE_WEBVIEW_WEBKIT" = "yes"; then
if test "$wxUSE_GTK" = 1; then if test "$wxUSE_GTK" = 1; then
if test "$WXGTK3" = 1; then if test "$WXGTK3" = 1; then
PKG_CHECK_MODULES([WEBKIT],
[webkit2gtk-4.1],
[
USE_WEBVIEW_WEBKIT2=1
CXXFLAGS="$CXXFLAGS $WEBKIT_CFLAGS"
EXTRALIBS_WEBVIEW="$WEBKIT_LIBS"
],
[
AC_MSG_WARN([webkit2gtk-4.1 not found, falling back to webkit2gtk-4.0])
])
if test "$USE_WEBVIEW_WEBKIT2" = 0; then
PKG_CHECK_MODULES([WEBKIT], PKG_CHECK_MODULES([WEBKIT],
[webkit2gtk-4.0], [webkit2gtk-4.0],
[ [
@ -7536,9 +7547,10 @@ if test "$wxUSE_WEBVIEW" = "yes"; then
EXTRALIBS_WEBVIEW="$WEBKIT_LIBS" EXTRALIBS_WEBVIEW="$WEBKIT_LIBS"
], ],
[ [
AC_MSG_WARN([webkit2gtk not found, falling back to webkitgtk]) AC_MSG_WARN([webkit2gtk-4.0 not found, falling back to webkitgtk])
]) ])
fi fi
fi
if test "$USE_WEBVIEW_WEBKIT2" = 0; then if test "$USE_WEBVIEW_WEBKIT2" = 0; then
webkitgtk=webkit-1.0 webkitgtk=webkit-1.0
if test "$WXGTK3" = 1; then if test "$WXGTK3" = 1; then

View File

@ -173,15 +173,18 @@ wxgtk_webview_webkit_load_failed(WebKitWebView *,
{ {
switch (error->code) switch (error->code)
{ {
#if SOUP_MAJOR_VERSION < 3
case SOUP_STATUS_CANCELLED: case SOUP_STATUS_CANCELLED:
type = wxWEBVIEW_NAV_ERR_USER_CANCELLED; type = wxWEBVIEW_NAV_ERR_USER_CANCELLED;
break; break;
case SOUP_STATUS_CANT_RESOLVE: case SOUP_STATUS_CANT_RESOLVE:
#endif
case SOUP_STATUS_NOT_FOUND: case SOUP_STATUS_NOT_FOUND:
type = wxWEBVIEW_NAV_ERR_NOT_FOUND; type = wxWEBVIEW_NAV_ERR_NOT_FOUND;
break; break;
#if SOUP_MAJOR_VERSION < 3
case SOUP_STATUS_CANT_RESOLVE_PROXY: case SOUP_STATUS_CANT_RESOLVE_PROXY:
case SOUP_STATUS_CANT_CONNECT: case SOUP_STATUS_CANT_CONNECT:
case SOUP_STATUS_CANT_CONNECT_PROXY: case SOUP_STATUS_CANT_CONNECT_PROXY:
@ -193,6 +196,7 @@ wxgtk_webview_webkit_load_failed(WebKitWebView *,
case SOUP_STATUS_MALFORMED: case SOUP_STATUS_MALFORMED:
type = wxWEBVIEW_NAV_ERR_REQUEST; type = wxWEBVIEW_NAV_ERR_REQUEST;
break; break;
#endif
case SOUP_STATUS_BAD_REQUEST: case SOUP_STATUS_BAD_REQUEST:
type = wxWEBVIEW_NAV_ERR_REQUEST; type = wxWEBVIEW_NAV_ERR_REQUEST;