diff --git a/build/cmake/files.cmake b/build/cmake/files.cmake index 455e2d2f11..0f0adadf14 100644 --- a/build/cmake/files.cmake +++ b/build/cmake/files.cmake @@ -2869,6 +2869,10 @@ set(WEBVIEW_GTK_SRC src/gtk/webview_webkit.cpp ) +set(WEBVIEW2_GTK_SRC + src/gtk/webview_webkit2.cpp +) + set(XRC_SRC src/xrc/xh_activityindicator.cpp src/xrc/xh_animatctrl.cpp diff --git a/build/cmake/init.cmake b/build/cmake/init.cmake index 292440380f..0c9e420f75 100644 --- a/build/cmake/init.cmake +++ b/build/cmake/init.cmake @@ -225,8 +225,19 @@ if(wxUSE_GUI) if(wxUSE_WEBVIEW AND WXGTK) find_package(LibSoup) - find_package(Webkit) - if(NOT WEBKIT_FOUND OR NOT LIBSOUP_FOUND) + if(WXGTK2) + find_package(Webkit 1.0) + elseif(WXGTK3) + find_package(Webkit 3.0) + find_package(Webkit2) + if(NOT WEBKIT2_FOUND) + wx_option_force_value(wxUSE_WEBVIEW_WEBKIT2 OFF) + endif() + endif() + if(NOT WEBKIT_FOUND) + wx_option_force_value(wxUSE_WEBVIEW_WEBKIT OFF) + endif() + if((NOT WEBKIT_FOUND AND NOT WEBKIT2_FOUND) OR NOT LIBSOUP_FOUND) message(WARNING "webkit not found, wxWebview won't be available") wx_option_force_value(wxUSE_WEBVIEW OFF) endif() diff --git a/build/cmake/lib/webview/CMakeLists.txt b/build/cmake/lib/webview/CMakeLists.txt index 317bb1be62..c7055be359 100644 --- a/build/cmake/lib/webview/CMakeLists.txt +++ b/build/cmake/lib/webview/CMakeLists.txt @@ -14,25 +14,39 @@ wx_append_sources(WEBVIEW_FILES WEBVIEW_CMN) if(WXMSW) wx_append_sources(WEBVIEW_FILES WEBVIEW_MSW) elseif(WXGTK) - wx_append_sources(WEBVIEW_FILES WEBVIEW_GTK) + if(wxUSE_WEBVIEW_WEBKIT2) + wx_append_sources(WEBVIEW_FILES WEBVIEW2_GTK) + elseif(wxUSE_WEBVIEW_WEBKIT) + wx_append_sources(WEBVIEW_FILES WEBVIEW_GTK) + endif() elseif(APPLE) wx_append_sources(WEBVIEW_FILES WEBVIEW_OSX_SHARED) endif() wx_add_library(webview ${WEBVIEW_FILES}) + +if(wxUSE_WEBVIEW_WEBKIT2) + wx_lib_compile_definitions(webview PRIVATE + -DWX_WEB_EXTENSIONS_DIRECTORY="${CMAKE_INSTALL_PREFIX}/web-extensions" + ) +endif() + if(APPLE) wx_lib_link_libraries(webview PUBLIC "-framework WebKit" ) elseif(WXGTK) - wx_lib_include_directories(webview PUBLIC - ${WEBKIT_INCLUDE_DIR} - ${LIBSOUP_INCLUDE_DIRS} - ) - wx_lib_link_libraries(webview PUBLIC - ${WEBKIT_LIBRARIES} - ${LIBSOUP_LIBRARIES} - ) + if(LIBSOUP_FOUND) + wx_lib_include_directories(webview PUBLIC ${LIBSOUP_INCLUDE_DIRS}) + wx_lib_link_libraries(webview PUBLIC ${LIBSOUP_LIBRARIES}) + endif() + if(wxUSE_WEBVIEW_WEBKIT2) + wx_lib_include_directories(webview PUBLIC ${WEBKIT2_INCLUDE_DIR}) + wx_lib_link_libraries(webview PUBLIC ${WEBKIT2_LIBRARIES}) + elseif(wxUSE_WEBVIEW_WEBKIT) + wx_lib_include_directories(webview PUBLIC ${WEBKIT_INCLUDE_DIR}) + wx_lib_link_libraries(webview PUBLIC ${WEBKIT_LIBRARIES}) + endif() endif() wx_finalize_lib(webview) diff --git a/build/cmake/modules/FindWebkit.cmake b/build/cmake/modules/FindWebkit.cmake index 1bb331cf69..8b6e6ccef7 100644 --- a/build/cmake/modules/FindWebkit.cmake +++ b/build/cmake/modules/FindWebkit.cmake @@ -1,16 +1,18 @@ -# - Find Webkit-3.0 -# Find the Webkit-3.0 includes and library +# - Find Webkit +# Find the Webkit includes and library # # WEBKIT_INCLUDE_DIR - Where to find webkit include sub-directory. -# WEBKIT_LIBRARIES - List of libraries when using Webkit-3.0. -# WEBKIT_FOUND - True if Webkit-3.0 found. +# WEBKIT_LIBRARIES - List of libraries when using Webkit. +# WEBKIT_FOUND - True if Webkit found. -SET( WEBKIT_VERSION "1.0") +SET(WEBKIT_VERSION 1.0) +if(DEFINED Webkit_FIND_VERSION) + SET(WEBKIT_VERSION ${Webkit_FIND_VERSION}) +endif() -IF (WEBKIT_INCLUDE_DIR) - # Already in cache, be silent. - SET(WEBKIT_FIND_QUIETLY TRUE) -ENDIF (WEBKIT_INCLUDE_DIR) +SET(WEBKIT_INCLUDE_DIR WEBKIT_INCLUDE_DIR-NOTFOUND) +SET(WEBKIT_LIBRARY WEBKIT_LIBRARY-NOTFOUND) +SET(WEBKIT_LIBRARIES WEBKIT_LIBRARIES-NOTFOUND) FIND_PATH(WEBKIT_INCLUDE_DIR webkit/webkit.h PATH_SUFFIXES "webkitgtk-${WEBKIT_VERSION}" @@ -35,4 +37,4 @@ ELSE(WEBKIT_FOUND) SET( WEBKIT_LIBRARIES ) ENDIF(WEBKIT_FOUND) -MARK_AS_ADVANCED( WEBKIT_LIBRARY WEBKIT_INCLUDE_DIR ) +MARK_AS_ADVANCED(WEBKIT_LIBRARY WEBKIT_LIBRARIES WEBKIT_INCLUDE_DIR) diff --git a/build/cmake/modules/FindWebkit2.cmake b/build/cmake/modules/FindWebkit2.cmake new file mode 100644 index 0000000000..33a8e4a863 --- /dev/null +++ b/build/cmake/modules/FindWebkit2.cmake @@ -0,0 +1,37 @@ +# - Find Webkit2 +# Find the Webkit2 includes and library +# +# WEBKIT2_INCLUDE_DIR - Where to find Webkit2 include sub-directory. +# WEBKIT2_LIBRARIES - List of libraries when using Webkit2. +# WEBKIT2_FOUND - True if Webkit2 found. + +SET( WEBKIT2_VERSION 4.0) + +set(WEBKIT2_INCLUDE_DIR WEBKIT2_INCLUDE_DIR-NOTFOUND) +set(WEBKIT2_LIBRARY WEBKIT2_LIBRARY-NOTFOUND) +set(WEBKIT2_LIBRARIES WEBKIT2_LIBRARIES-NOTFOUND) + +FIND_PATH(WEBKIT2_INCLUDE_DIR webkit2/webkit2.h + PATH_SUFFIXES "webkitgtk-${WEBKIT2_VERSION}" +) + +SET(WEBKIT2_NAMES "webkit2gtk-${WEBKIT2_VERSION}") +FIND_LIBRARY(WEBKIT2_LIBRARY + NAMES ${WEBKIT2_NAMES} +) + +# Handle the QUIETLY and REQUIRED arguments and set WEBKIT2_FOUND to +# TRUE if all listed variables are TRUE. +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( + WEBKIT2 DEFAULT_MSG + WEBKIT2_LIBRARY WEBKIT2_INCLUDE_DIR +) + +IF(WEBKIT2_FOUND) + SET( WEBKIT2_LIBRARIES ${WEBKIT2_LIBRARY} ) +ELSE(WEBKIT2_FOUND) + SET( WEBKIT2_LIBRARIES ) +ENDIF(WEBKIT2_FOUND) + +MARK_AS_ADVANCED(WEBKIT2_LIBRARY WEBKIT2_LIBRARIES WEBKIT2_INCLUDE_DIR) diff --git a/build/cmake/options.cmake b/build/cmake/options.cmake index 0cf3740002..a972de41da 100644 --- a/build/cmake/options.cmake +++ b/build/cmake/options.cmake @@ -356,7 +356,7 @@ wx_option(wxUSE_DRAGIMAGE "use wxDragImage") wx_option(wxUSE_UIACTIONSIMULATOR "use wxUIActionSimulator (experimental)") wx_option(wxUSE_DC_TRANSFORM_MATRIX "use wxDC::SetTransformMatrix and related") wx_option(wxUSE_WEBVIEW_WEBKIT "use wxWebView WebKit backend") -# TODO: wxUSE_WEBVIEW_WEBKIT2 +wx_option(wxUSE_WEBVIEW_WEBKIT2 "use wxWebView WebKit2 backend") if(WIN32 OR APPLE) set(wxUSE_PRIVATE_FONTS_DEFAULT ON) else() diff --git a/build/files b/build/files index 93c9fec7dd..fa83ae8e71 100644 --- a/build/files +++ b/build/files @@ -2812,6 +2812,9 @@ WEBVIEW_GTK_HDR = WEBVIEW_GTK_SRC = src/gtk/webview_webkit.cpp +WEBVIEW2_GTK_SRC = + src/gtk/webview_webkit2.cpp + # wxXRC XRC_SRC =