diff options
38 files changed, 648 insertions, 379 deletions
diff --git a/configure.pri b/configure.pri index 9a5b8af4a..b592220a7 100644 --- a/configure.pri +++ b/configure.pri @@ -114,21 +114,17 @@ defineTest(qtwebengine_platformError) { defineTest(qtConfTest_detectPlatform) { QT_FOR_CONFIG += gui-private - !linux:!win32:!macos:!ios { - qtwebengine_platformError("Unknown platform. Qt WebEngine only supports Linux, Windows, and macOS.") - } else { - linux:qtwebengine_isLinuxPlatformSupported() { - $${1}.platform = "linux" - } - win32:qtwebengine_isWindowsPlatformSupported() { - $${1}.platform = "windows" - } - macos:qtwebengine_isMacOsPlatformSupported() { - $${1}.platform = "macos" - } - ios:qtwebengine_isMacOsPlatformSupported() { - $${1}.platform = "ios" - } + linux:qtwebengine_isLinuxPlatformSupported() { + $${1}.platform = "linux" + } + win32:qtwebengine_isWindowsPlatformSupported() { + $${1}.platform = "windows" + } + macos:qtwebengine_isMacOsPlatformSupported() { + $${1}.platform = "macos" + } + ios:qtwebengine_isMacOsPlatformSupported() { + $${1}.platform = "ios" } !isEmpty(platformError) { @@ -201,6 +197,19 @@ defineTest(qtConfTest_detectGn) { return(false) } +defineTest(qtConfTest_detectNodeJS) { + nodejs = $$qtConfFindInPath("nodejs$$EXE_SUFFIX") + isEmpty(nodejs) { + qtLog("'nodejs$$EXE_SUFFIX' not found in PATH. Checking for 'node$$EXE_SUFFIX'.") + nodejs = $$qtConfFindInPath("node$$EXE_SUFFIX") + isEmpty(nodejs) { + qtLog("'node$$EXE_SUFFIX' not found in PATH. Giving up.") + return(false) + } + } + return(true) +} + defineTest(qtConfTest_detectEmbedded) { lessThan(QT_MINOR_VERSION, 9) { cross_compile: return(true) @@ -391,19 +400,24 @@ defineTest(qtConfTest_detectNoWhitespace) { return(true) } -defineTest(qtwebengine_confCheckError) { +defineTest(qtwebengine_confCheckWebEngineCoreError) { + QT_FOR_CONFIG += buildtools-private gui-private + return($$qtwebengine_checkWebEngineCoreError()) +} + +defineTest(qtwebengine_confCheckPdfError) { QT_FOR_CONFIG += buildtools-private gui-private - return($$qtwebengine_checkError()) + return($$qtwebengine_checkPdfError()) } defineTest(qtwebengine_isLinuxPlatformSupported) { !gcc|intel_icc { - qtwebengine_platformError("Qt WebEngine on Linux requires clang or GCC.") + qtwebengine_platformError("requires clang or GCC.") return(false) } gcc:!clang:!qtwebengine_isGCCVersionSupported(): return(false) gcc:!qtConfig(c++14) { - qtwebengine_platformError("C++14 support is required in order to build chromium.") + qtwebengine_platformError("requires c++14 support.") return(false) } return(true) @@ -411,19 +425,19 @@ defineTest(qtwebengine_isLinuxPlatformSupported) { defineTest(qtwebengine_isWindowsPlatformSupported) { winrt { - qtwebengine_platformError("WinRT is not supported.") + qtwebengine_platformError("for WinRT is not supported.") return(false) } qtwebengine_isBuildingOnWin32() { - qtwebengine_platformError("Qt WebEngine on Windows must be built on a 64-bit machine.") + qtwebengine_platformError("must be built on a 64-bit machine.") return(false) } !msvc|intel_icl { - qtwebengine_platformError("Qt WebEngine on Windows requires MSVC or Clang (MSVC mode).") + qtwebengine_platformError("requires MSVC or Clang (MSVC mode).") return(false) } !qtwebengine_isMinWinSDKVersion(10, 18362): { - qtwebengine_platformError("Qt WebEngine on Windows requires a Windows SDK version 10.0.18362 or newer.") + qtwebengine_platformError("requires a Windows SDK version 10.0.18362 or newer.") return(false) } return(true) @@ -431,21 +445,21 @@ defineTest(qtwebengine_isWindowsPlatformSupported) { defineTest(qtwebengine_isMacOsPlatformSupported) { !qtwebengine_isMinXcodeVersion(10, 0, 0) { - qtwebengine_platformError("Using Xcode version $$QMAKE_XCODE_VERSION, but at least version 10.0.0 is required to build Qt WebEngine or Qt Pdf.") + qtwebengine_platformError("requires at least version 10.0.0, but using Xcode version $${QMAKE_XCODE_VERSION}.") return(false) } !clang|intel_icc { - qtwebengine_platformError("Qt WebEngine and Qt Pdf requires Clang.") + qtwebengine_platformError("requires Clang.") return(false) } # We require macOS 10.13 (darwin version 17.0.0) or newer. darwin_major_version = $$section(QMAKE_HOST.version, ., 0, 0) lessThan(darwin_major_version, 17) { - qtwebengine_platformError("Building Qt WebEngine or Qt Pdf requires macOS version 10.13 or newer.") + qtwebengine_platformError("requires macOS version 10.13 or newer.") return(false) } !qtwebengine_isMinOSXSDKVersion(10, 13): { - qtwebengine_platformError("Building Qt WebEngine or Qt Pdf requires a macOS SDK version of 10.13 or newer. Current version is $${WEBENGINE_OSX_SDK_PRODUCT_VERSION}.") + qtwebengine_platformError("requires a macOS SDK version of 10.13 or newer. Current version is $${WEBENGINE_OSX_SDK_PRODUCT_VERSION}.") return(false) } return(true) @@ -455,7 +469,7 @@ defineTest(qtwebengine_isGCCVersionSupported) { # Keep in sync with src/webengine/doc/src/qtwebengine-platform-notes.qdoc greaterThan(QMAKE_GCC_MAJOR_VERSION, 4):return(true) - qtwebengine_platformError("Using gcc version "$$QMAKE_GCC_MAJOR_VERSION"."$$QMAKE_GCC_MINOR_VERSION", but at least gcc version 5 is required to build Qt WebEngine.") + qtwebengine_platformError("requires at least gcc version 5, but using gcc version $${QMAKE_GCC_MAJOR_VERSION}.$${QMAKE_GCC_MINOR_VERSION}.") return(false) } @@ -476,7 +490,7 @@ defineTest(qtwebengine_isMinOSXSDKVersion) { WEBENGINE_OSX_SDK_PRODUCT_VERSION = $$system("/usr/bin/xcodebuild -sdk $$QMAKE_MAC_SDK -version ProductVersion 2>/dev/null") export(WEBENGINE_OSX_SDK_PRODUCT_VERSION) isEmpty(WEBENGINE_OSX_SDK_PRODUCT_VERSION) { - qtwebengine_platformError("Could not resolve SDK product version for \'$$QMAKE_MAC_SDK\'.") + qtwebengine_platformError("requires SDK product version, but could not resolve it for \'$$QMAKE_MAC_SDK\'.") return(false) } major_version = $$section(WEBENGINE_OSX_SDK_PRODUCT_VERSION, ., 0, 0) @@ -517,7 +531,7 @@ defineTest(qtwebengine_isMinWinSDKVersion) { WIN_SDK_VERSION = $$(WindowsSDKVersion) isEmpty(WIN_SDK_VERSION)|equals(WIN_SDK_VERSION, "\\") { - qtwebengine_platformError("Could not detect Windows SDK version (\'WindowsSDKVersion\' environment variable is not set).") + qtwebengine_platformError("requires Windows SDK version, but could not detect it (\'WindowsSDKVersion\' environment variable is not set).") return(false) } diff --git a/examples/examples.pro b/examples/examples.pro index b4f411aeb..c62d7c04d 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,9 +1,25 @@ -TEMPLATE=subdirs -qtHaveModule(webengine): SUBDIRS += webengine +include($$QTWEBENGINE_OUT_ROOT/src/buildtools/qtbuildtools-config.pri) +include($$QTWEBENGINE_OUT_ROOT/src/webengine/qtwebengine-config.pri) +include($$QTWEBENGINE_OUT_ROOT/src/webenginewidgets/qtwebenginewidgets-config.pri) +include($$QTWEBENGINE_OUT_ROOT/src/pdf/qtpdf-config.pri) +include($$QTWEBENGINE_OUT_ROOT/src/pdfwidgets/qtpdfwidgets-config.pri) + +QT_FOR_CONFIG += \ + buildtools-private \ + webengine-private \ + webenginewidgets-private \ + pdf-private \ + pdfwidgets-private -qtHaveModule(webenginewidgets): SUBDIRS += webenginewidgets +TEMPLATE=subdirs -qtHaveModule(pdfwidgets): SUBDIRS += pdfwidgets +qtConfig(build-qtwebengine-core):qtConfig(webengine-core-support) { + qtConfig(webengine-qml): SUBDIRS += webengine + qtConfig(webengine-widgets): SUBDIRS += webenginewidgets +} -qtHaveModule(quick): qtHaveModule(pdf): qtHaveModule(pdfwidgets): SUBDIRS += pdf +qtConfig(build-qtpdf):qtConfig(webengine-qtpdf-support) { + SUDIRS += pdf + qtConfig(pdf-widgets): SUBDIRS += pdfwidgets +} diff --git a/mkspecs/features/functions.prf b/mkspecs/features/functions.prf index 36af78f33..b7509d4d0 100644 --- a/mkspecs/features/functions.prf +++ b/mkspecs/features/functions.prf @@ -74,11 +74,29 @@ defineReplace(gnPath) { return($$out) } -defineReplace(gnArgs) { +defineReplace(gnWebEngineArgs) { + linux { + include($$QTWEBENGINE_ROOT/src/buildtools/config/linux.pri) + include($$QTWEBENGINE_ROOT/src/core/config/linux.pri) + } + macos { + include($$QTWEBENGINE_ROOT/src/buildtools/config/mac_osx.pri) + include($$QTWEBENGINE_ROOT/src/core/config/mac_osx.pri) + } + win32 { + include($$QTWEBENGINE_ROOT/src/buildtools/config/windows.pri) + include($$QTWEBENGINE_ROOT/src/core/config/windows.pri) + } + isEmpty(gn_args): error(No gn_args found please make sure you have valid configuration.) + return($$gn_args) +} + +defineReplace(gnPdfArgs) { linux: include($$QTWEBENGINE_ROOT/src/buildtools/config/linux.pri) macos: include($$QTWEBENGINE_ROOT/src/buildtools/config/mac_osx.pri) - ios: include($$QTWEBENGINE_ROOT/src/buildtools/config/ios.pri) + ios: include($$QTWEBENGINE_ROOT/src/pdf/config/ios.pri) win32: include($$QTWEBENGINE_ROOT/src/buildtools/config/windows.pri) + include($$QTWEBENGINE_ROOT/src/pdf/config/common.pri) isEmpty(gn_args): error(No gn_args found please make sure you have valid configuration.) return($$gn_args) } diff --git a/src/3rdparty b/src/3rdparty -Subproject 7b2f027ea83c372c33d5b50deb65a2d98244aa0 +Subproject 15a42873b9a4bda657e7a435f25241a05b8bd1c diff --git a/src/buildtools/config/common.pri b/src/buildtools/config/common.pri index 9824897f0..8aeeb3894 100644 --- a/src/buildtools/config/common.pri +++ b/src/buildtools/config/common.pri @@ -42,44 +42,6 @@ greaterThan(QMAKE_JUMBO_MERGE_LIMIT,0) { gn_args += jumbo_build_excluded="[\"browser\"]" } -qtConfig(build-qtwebengine-core):qtConfig(webengine-printing-and-pdf) { - gn_args += enable_basic_printing=true enable_print_preview=true - gn_args += enable_pdf=true -} else { - gn_args += enable_basic_printing=false enable_print_preview=false - gn_args += enable_pdf=false -} - -qtConfig(build-qtwebengine-core):qtConfig(webengine-pepper-plugins) { - gn_args += enable_plugins=true -} else { - gn_args += enable_plugins=false -} - -qtConfig(build-qtwebengine-core):qtConfig(webengine-spellchecker) { - gn_args += enable_spellcheck=true -} else { - gn_args += enable_spellcheck=false -} - -qtConfig(build-qtwebengine-core):qtConfig(webengine-webrtc) { - gn_args += enable_webrtc=true -} else { - gn_args += enable_webrtc=false audio_processing_in_audio_service_supported=false -} - -qtConfig(build-qtwebengine-core):qtConfig(webengine-proprietary-codecs) { - gn_args += proprietary_codecs=true ffmpeg_branding=\"Chrome\" -} else { - gn_args += proprietary_codecs=false -} - -qtConfig(build-qtwebengine-core):qtConfig(webengine-extensions) { - gn_args += enable_extensions=true -} else { - gn_args += enable_extensions=false -} - precompile_header { gn_args += enable_precompiled_headers=true } else { @@ -129,15 +91,8 @@ optimize_size: gn_args += optimize_for_size=true sanitize_undefined: gn_args += is_ubsan=true is_ubsan_vptr=true } -qtConfig(build-qtwebengine-core):qtConfig(webengine-kerberos) { - gn_args += use_kerberos=true -} else { - gn_args += use_kerberos=false -} - ccache { gn_args += cc_wrapper=\"ccache\" } qtConfig(force_asserts): gn_args += dcheck_always_on=true - diff --git a/src/buildtools/config/linux.pri b/src/buildtools/config/linux.pri index 455a2e3c6..56c18bdb5 100644 --- a/src/buildtools/config/linux.pri +++ b/src/buildtools/config/linux.pri @@ -24,10 +24,6 @@ gn_args += \ ozone_platform=\"qt\" \ ozone_extra_path=\"$$QTWEBENGINE_ROOT/src/core/ozone/ozone_extra.gni\" -qtConfig(build-qtwebengine-core):qtConfig(webengine-embedded-build) { - gn_args += is_desktop_linux=false -} - use_gold_linker: gn_args += use_gold=true else: gn_args += use_gold=false @@ -90,7 +86,7 @@ contains(QT_ARCH, "arm") { } } - qtConfig(build-qtwebengine-core):qtConfig(webengine-arm-thumb) { + qtConfig(webengine-arm-thumb) { gn_args += arm_use_thumb=true # this adds -mthumb } else { gn_args += arm_use_thumb=false @@ -156,16 +152,13 @@ host_build { qtConfig(webengine-system-zlib) { qtConfig(webengine-system-minizip): gn_args += use_system_zlib=true use_system_minizip=true - qtConfig(build-qtpdf) || qtConfig(webengine-printing-and-pdf) { - gn_args += pdfium_use_system_zlib=true - } + gn_args += pdfium_use_system_zlib=true } + qtConfig(webengine-system-png) { - gn_args += use_system_libpng=true - qtConfig(build-qtpdf) || qtConfig(webengine-printing-and-pdf) { - gn_args += pdfium_use_system_libpng=true - } + gn_args += use_system_libpng=true pdfium_use_system_libpng=true } + qtConfig(webengine-system-jpeg) { gn_args += use_system_libjpeg=true } else { @@ -182,38 +175,4 @@ host_build { gn_args += use_system_harfbuzz=false } gn_args += use_glib=false - qtConfig(build-qtwebengine-core):qtConfig(webengine-pulseaudio) { - gn_args += use_pulseaudio=true - } else { - gn_args += use_pulseaudio=false - } - qtConfig(build-qtwebengine-core):qtConfig(webengine-alsa) { - gn_args += use_alsa=true - } else { - gn_args += use_alsa=false - } - !packagesExist(libpci): gn_args += use_libpci=false - - qtConfig(build-qtwebengine-core):qtConfig(webengine-ozone-x11) { - gn_args += ozone_platform_x11=true - gn_args += use_xkbcommon=true - packagesExist(xscrnsaver): gn_args += use_xscrnsaver=true - qtConfig(webengine-webrtc): gn_args += rtc_use_x11=true - } - - qtConfig(webengine-system-libevent): gn_args += use_system_libevent=true - qtConfig(webengine-system-libwebp): gn_args += use_system_libwebp=true - qtConfig(webengine-system-libxml2): gn_args += use_system_libxml=true use_system_libxslt=true - qtConfig(webengine-system-opus): gn_args += use_system_opus=true - qtConfig(webengine-system-snappy): gn_args += use_system_snappy=true - qtConfig(webengine-system-libvpx): gn_args += use_system_libvpx=true - qtConfig(webengine-system-icu): gn_args += use_system_icu=true icu_use_data_file=false - qtConfig(webengine-system-ffmpeg): gn_args += use_system_ffmpeg=true - qtConfig(webengine-system-re2): gn_args += use_system_re2=true - qtConfig(webengine-system-lcms2): gn_args += use_system_lcms2=true - - # FIXME: - #qtConfig(webengine-system-protobuf): gn_args += use_system_protobuf=true - #qtConfig(webengine-system-jsoncpp): gn_args += use_system_jsoncpp=true - #qtConfig(webengine-system-libsrtp: gn_args += use_system_libsrtp=true } diff --git a/src/buildtools/config/mac_osx.pri b/src/buildtools/config/mac_osx.pri index 9373928de..b53f91706 100644 --- a/src/buildtools/config/mac_osx.pri +++ b/src/buildtools/config/mac_osx.pri @@ -36,9 +36,3 @@ gn_args += \ use_external_popup_menu=false \ angle_enable_vulkan=false -qtConfig(build-qtwebengine-core):qtConfig(webengine-spellchecker) { - qtConfig(webengine-native-spellchecker): gn_args += use_browser_spellchecker=true - else: gn_args += use_browser_spellchecker=false -} else { - gn_args += use_browser_spellchecker=false -} diff --git a/src/buildtools/config/pdf.pri b/src/buildtools/config/pdf.pri deleted file mode 100644 index 4a1cf08e0..000000000 --- a/src/buildtools/config/pdf.pri +++ /dev/null @@ -1,36 +0,0 @@ -include($$QTWEBENGINE_OUT_ROOT/src/pdf/qtpdf-config.pri) -QT_FOR_CONFIG += pdf-private - -qtConfig(build-qtpdf) { - qtConfig(pdf-v8) { - gn_args += pdf_enable_v8=true - } else { - gn_args += pdf_enable_v8=false - } - qtConfig(pdf-xfa) { - gn_args += pdf_enable_xfa=true - } else { - gn_args += pdf_enable_xfa=false - } - qtConfig(pdf-xfa-bmp) { - gn_args += pdf_enable_xfa_bmp=true - } else { - gn_args += pdf_enable_xfa_bmp=false - } - qtConfig(pdf-xfa-gif) { - gn_args += pdf_enable_xfa_gif=true - } else { - gn_args += pdf_enable_xfa_gif=false - } - qtConfig(pdf-xfa-png) { - gn_args += pdf_enable_xfa_png=true - } else { - gn_args += pdf_enable_xfa_png=false - } - qtConfig(pdf-xfa-tiff) { - gn_args += pdf_enable_xfa_tiff=true - } else { - gn_args += pdf_enable_xfa_tiff=false - } -} - diff --git a/src/buildtools/config/support.pri b/src/buildtools/config/support.pri index 8077b12ff..80f291500 100644 --- a/src/buildtools/config/support.pri +++ b/src/buildtools/config/support.pri @@ -1,147 +1,250 @@ defineTest(qtwebengine_skipBuild) { - isEmpty(skipBuildReason): skipBuildReason = $$1 - else: skipBuildReason = "$$skipBuildReason $${EOL}$$1" + skipBuildReason = $$1 export(skipBuildReason) } -defineReplace(qtwebengine_checkError) { +# this should match webengine-core-support +defineReplace(qtwebengine_checkWebEngineCoreError) { + !qtwebengine_checkForBuildSupport(QtWebEngine):return(false) + static { + qtwebengine_skipBuild("Static builds of QtWebEngine are not supported.") + return(false) + } + !qtwebengine_checkForGui(QtWebEngine):return(false) + !qtwebengine_checkForSubmodule(QtWebEngine):return(false) + !qtwebengine_checkForWhiteSpace(QtWebEngine):return(false) + !qtwebengine_checkForPlatform(QtWebEngine):return(false) + !qtwebengine_checkForArch(QtWebEngine):return(false) + !qtwebengine_checkForGperf(QtWebEngine):return(false) + !qtwebengine_checkForBison(QtWebEngine):return(false) + !qtwebengine_checkForFlex(QtWebEngine):return(false) + !qtwebengine_checkForPython2(QtWebengine):return(false) + !qtwebengine_checkForSanitizer(QtWebEngine):return(false) + linux:!qtwebengine_checkForPkgCfg(QtWebEngine):return(false) + linux:!qtwebengine_checkForHostPkgCfg(QtWebEngine):return(false) + linux:!qtwebengine_checkForGlibc(QtWebEngine):return(false) + linux:!qtwebengine_checkForKhronos(QtWebEngine):return(false) + linux:!qtwebengine_checkForPackage(QtWebEngine,nss):return(false) + linux:!qtwebengine_checkForPackage(QtWebEngine,dbus):return(false) + linux:!qtwebengine_checkForPackage(QtWebEngine,fontconfig):return(false) + linux:!qtwebengine_checkForQpaXcb(QtWebEngine):return(false) + win32:!qtwebengine_checkForCompiler64(QtWebEngine):return(false) + win32:!qtwebengine_checkForWinVersion(QtWebEngine):return(false) + return(true) +} +# this shuold match webengine-qtpdf-support +defineReplace(qtwebengine_checkPdfError) { + !qtwebengine_checkForBuildSupport(QtPdf):return(false) + !qtwebengine_checkForGui(QtPdf):return(false) + !qtwebengine_checkForSubmodule(QtPdf):return(false) + !qtwebengine_checkForWhiteSpace(QtPdf):return(false) + !qtwebengine_checkForPlatform(QtPdf):return(false) + !qtwebengine_checkForArch(QtPdf):return(false) + !qtwebengine_checkForGperf(QtPdf):return(false) + !qtwebengine_checkForBison(QtPdf):return(false) + !qtwebengine_checkForFlex(QtPdf):return(false) + !qtwebengine_checkForPython2(QtPdf):return(false) + !qtwebengine_checkForSanitizer(QtPdf):return(false) + linux:!qtwebengine_checkForPkgCfg(QtPdf):return(false) + linux:!qtwebengine_checkForHostPkgCfg(QtPdf):return(false) + win32:!qtwebengine_checkForWinVersion(QtPdf):return(false) + return(true) +} + +defineTest(qtwebengine_checkForBuildSupport) { + module = $$1 + !linux:!win32:!macos { + qtwebengine_skipBuild("$${module} can be build only on Linux, Windows or macOS.") + return(false) + } + return(true) +} + +defineTest(qtwebengine_checkForGui) { + module = $$1 !qtHaveModule(gui) { - qtwebengine_skipBuild("QtWebEngine requires QtGui.") + qtwebengine_skipBuild("$${module} requires QtGui.") return(false) } + return(true) +} +defineTest(qtwebengine_checkForSubmodule) { + module = $$1 !qtConfig(webengine-submodule) { - qtwebengine_skipBuild("QtWebEngine required submodule qtwebengine-chromium does not exist. Run 'git submodule update --init'.") + qtwebengine_skipBuild("$${module} required submodule qtwebengine-chromium does not exist. Run 'git submodule update --init'.") return(false) } + return(true) +} +defineTest(qtwebengine_checkForWhiteSpace) { + module = $$1 !qtConfig(webengine-nowhitespace) { - qtwebengine_skipBuild("QtWebEngine cannot be built in a path that contains whitespace characters.") + qtwebengine_skipBuild("$${module} cannot be built in a path that contains whitespace characters.") return(false) } + return(true) +} +defineTest(qtwebengine_checkForPlatform) { + module = $$1 qtConfig(webengine-no-platform-support) { !isEmpty(platformError) { - qtwebengine_skipBuild($$platformError) + qtwebengine_skipBuild("$${module} $${platformError}") return(false) } !isEmpty(QTWEBENGINE_OUT_ROOT) { include($$QTWEBENGINE_OUT_ROOT/src/buildtools/qtbuildtools-config.pri) QT_FOR_CONFIG += buildtools-private - qtwebengine_skipBuild($$PLATFORM_ERROR) - return(false) + !isEmpty(PLATFORM_ERROR) { + qtwebengine_skipBuild("$${module} $${PLATFORM_ERROR}") + return(false) + } } - qtwebengine_skipBuild("QtWebEngine will not be built. Platform unsupported.") # re-run of configure when topLevel build + qtwebengine_skipBuild("$${module} will not be built. Platform unsupported.") return(false): } + return(true) +} +defineTest(qtwebengine_checkForArch) { + module = $$1 !qtConfig(webengine-arch-support) { - qtwebengine_skipBuild("QtWebEngine can only be built for x86, x86-64, ARM, Aarch64, and MIPSel architectures.") + qtwebengine_skipBuild("$${module} can only be built for x86, x86-64, ARM, Aarch64, and MIPSel architectures.") return(false) } + return(true) +} +defineTest(qtwebengine_checkForGperf) { + module = $$1 !qtConfig(webengine-gperf) { - qtwebengine_skipBuild("Tool gperf is required to build QtWebEngine.") + qtwebengine_skipBuild("Tool gperf is required to build $${module}.") return(false) } + return(true) +} +defineTest(qtwebengine_checkForBison) { + module = $$1 !qtConfig(webengine-bison) { - qtwebengine_skipBuild("Tool bison is required to build QtWebEngine.") + qtwebengine_skipBuild("Tool bison is required to build $${module}.") return(false) } + return(true) +} +defineTest(qtwebengine_checkForFlex) { + module = $$1 !qtConfig(webengine-flex) { - qtwebengine_skipBuild("Tool flex is required to build QtWebEngine.") + qtwebengine_skipBuild("Tool flex is required to build $${module}.") return(false) } + return(true) +} +defineTest(qtwebengine_checkForPython2) { + module = $$1 !qtConfig(webengine-python2) { - qtwebengine_skipBuild("Python version 2 (2.7.5 or later) is required to build QtWebEngine.") + qtwebengine_skipBuild("Python version 2 (2.7.5 or later) is required to build $${module}.") return(false) } - - linux:!qtwebengine_checkErrorForLinux():return(false) - win32:!qtwebengine_checkErrorForWindows():return(false) - macos:!qtwebengine_checkErrorForMacOS():return(false) - - sanitizer: !qtConfig(webengine-sanitizer) { - qtwebengine_skipBuild("Chosen sanitizer configuration is not supported for QtWebEngine. Check config.log for details or use -feature-webengine-sanitizer to force build with the chosen sanitizer configuration.") - return(false); - } - return(true) } -defineTest(qtwebengine_checkErrorFoMacOS) { - static { - qtwebengine_skipBuild("Static builds of QtWebEngine are not supported.") - return(false) +defineTest(qtwebengine_checkForSanitizer) { + module = $$1 + sanitizer:!qtConfig(webengine-sanitizer) { + qtwebengine_skipBuild("Chosen sanitizer configuration is not supported for $${module}." \ + "Check config.log for details or use -feature-webengine-sanitizer to force build with the chosen sanitizer configuration.") + return(false); } + return(true) } -defineTest(qtwebengine_checkErrorForLinux) { - - static { - qtwebengine_skipBuild("Static builds of QtWebEngine are not supported.") - return(false) - } - +defineTest(qtwebengine_checkForPkgCfg) { + module = $$1 !qtConfig(pkg-config) { - qtwebengine_skipBuild("A pkg-config support is required to build QtWebEngine.") + qtwebengine_skipBuild("A pkg-config support is required to build $${module}.") return(false) } + return(true) +} +defineTest(qtwebengine_checkForHostPkgCfg) { + module = $$1 !qtConfig(webengine-host-pkg-config) { - qtwebengine_skipBuild("Host pkg-config is required to build QtWebEngine.") + qtwebengine_skipBuild("Host pkg-config is required to build $${module}.") return(false) } + return(true) +} +defineTest(qtwebengine_checkForGlibc) { + module = $$1 !qtConfig(webengine-system-glibc) { - qtwebengine_skipBuild("A suitable version >= 2.27 of libc required to build QtWebEngine could not be found.") + qtwebengine_skipBuild("A suitable version >= 2.27 of libc required to build $${module} could not be found.") return(false) } + return(true) +} +defineTest(qtwebengine_checkForKhronos) { + module = $$1 !qtConfig(webengine-system-khr) { - qtwebengine_skipBuild("Khronos development headers required to build QtWebEngine are missing (see mesa/libegl1-mesa-dev)") + qtwebengine_skipBuild("Khronos development headers required to build $${module} are missing (see mesa/libegl1-mesa-dev)") return(false) } + return(true) +} - for(package, $$list("nss dbus fontconfig")) { - !qtConfig(webengine-system-$$package) { - qtwebengine_skipBuild("A suitable version of $$package required to build QtWebEngine could not be found.") - return(false) - } +defineTest(qtwebengine_checkForPackage) { + module = $$1 + package = $$2 + !qtConfig(webengine-system-$$package) { + qtwebengine_skipBuild("A suitable version of $$package required to build QtWebEngine could not be found.") + return(false) } + return(true) +} +defineTest(qtwebengine_checkForQpaXcb) { + module = $$1 qtConfig(pkg-config):qtConfig(xcb):!qtConfig(webengine-ozone-x11) { - qtwebengine_skipBuild("Could not find all necessary libraries for qpa-xcb support in QtWebEngine.") + qtwebengine_skipBuild("Could not find all necessary libraries for qpa-xcb support in $${module}.") return(false) } return(true) } -defineTest(qtwebengine_checkErrorForWindows) { - - static { - qtwebengine_skipBuild("Static builds of QtWebEngine are not supported.") - return(false) - } - +defineTest(qtwebengine_checkForCompiler64) { + module = $$1 !qtConfig(webengine-win-compiler64) { - qtwebengine_skipBuild("64-bit cross-building or native toolchain required to build QtWebEngine could not be found.") + qtwebengine_skipBuild("64-bit cross-building or native toolchain required to build $${module} could not be found.") return(false) } + return(true) +} +defineTest(qtwebengine_checkForWinVersion) { + module = $$1 !qtConfig(webengine-winversion) { - qtwebengine_skipBuild("QtWebEngine needs Visual Studio 2017 or higher.") + qtwebengine_skipBuild("$${module} requires Visual Studio 2017 or higher.") return(false) } return(true) } -defineTest(qtwebengine_makeCheckError) { +defineTest(qtwebengine_makeCheckWebEngineCoreError) { + include($$QTWEBENGINE_OUT_ROOT/src/buildtools/qtbuildtools-config.pri) + QT_FOR_CONFIG += buildtools-private gui-private + return($$qtwebengine_checkWebEngineCoreError()) +} + +defineTest(qtwebengine_makeCheckPdfError) { include($$QTWEBENGINE_OUT_ROOT/src/buildtools/qtbuildtools-config.pri) QT_FOR_CONFIG += buildtools-private gui-private - return($$qtwebengine_checkError()) + return($$qtwebengine_checkPdfError()) } diff --git a/src/buildtools/config/windows.pri b/src/buildtools/config/windows.pri index a910e3e31..c36534d19 100644 --- a/src/buildtools/config/windows.pri +++ b/src/buildtools/config/windows.pri @@ -78,7 +78,7 @@ msvc { } else: equals(MSVC_VER, 16.0) { MSVS_VERSION = 2019 } else { - error("Visual Studio compiler version \"$$MSVC_VER\" is not supported by Qt WebEngine") + error("Visual Studio compiler version \"$$MSVC_VER\" is not supported by gn.") } gn_args += visual_studio_version=$$MSVS_VERSION @@ -91,12 +91,5 @@ msvc { GN_TARGET_CPU = $$gnArch($$QT_ARCH) gn_args += target_cpu=\"$$GN_TARGET_CPU\" } else { - error("Qt WebEngine for Windows can only be built with a Microsoft Visual Studio C++ compatible compiler") -} - -qtConfig(build-qtwebengine-core):qtConfig(webengine-spellchecker) { - qtConfig(webengine-native-spellchecker): gn_args += use_browser_spellchecker=true - else: gn_args += use_browser_spellchecker=false -} else { - gn_args += use_browser_spellchecker=false + error("Microsoft Visual Studio C++ compatible compiler is required by gn.") } diff --git a/src/buildtools/configure.json b/src/buildtools/configure.json index f02ab8070..772159add 100644 --- a/src/buildtools/configure.json +++ b/src/buildtools/configure.json @@ -345,40 +345,58 @@ "webengine-nowhitespace" : { "label": "build path without whitespace", "type": "detectNoWhitespace" + }, + "webengine-arm-thumb" : { + "label": "thumb instruction set", + "type": "hasThumbFlag" + }, + "webengine-sanitizer": { + "label" : "sanitizer support", + "type": "isSanitizerSupported" } }, "features": { "webengine-core-support": { "label": "Support Qt WebEngine Core", - "condition": "module.gui - && features.webengine-python2 - && features.webengine-gperf - && features.webengine-bison - && features.webengine-flex + "condition": "(config.linux || config.win32 || config.macos) + && !config.static + && module.gui && features.webengine-submodule && features.webengine-nowhitespace - && features.webengine-arch-support && !features.webengine-no-platform-support - && !config.static + && features.webengine-arch-support + && features.webengine-gperf + && features.webengine-bison + && features.webengine-flex + && features.webengine-python2 + && (!config.sanitizer || features.webengine-sanitizer) && (!config.linux || features.pkg-config) - && (!features.xcb || features.webengine-ozone-x11) - && (!config.win32 || features.webengine-winversion) - && !config.ios", + && (!config.linux || features.webengine-host-pkg-config) + && (!config.linux || features.webengine-system-glibc) + && (!config.linux || features.webengine-system-khr) + && (!config.linux || features.webengine-system-nss) + && (!config.linux || features.webengine-system-dbus) + && (!config.linux || features.webengine-system-fontconfig) + && (!config.linux || !features.pkg-config || !features.xcb || features.webengine-ozone-x11) + && (!config.win32 || features.webengine-win-compiler64) + && (!config.win32 || features.webengine-winversion)", "output": [ "privateFeature" ] }, "webengine-qtpdf-support": { "label": "Support Qt Pdf", - "condition": "module.gui - && features.webengine-python2 - && features.webengine-gperf - && features.webengine-bison - && features.webengine-flex + "condition": "(config.linux || config.win32 || config.macos) + && module.gui && features.webengine-submodule && features.webengine-nowhitespace - && features.webengine-arch-support && !features.webengine-no-platform-support - && (!config.static || config.ios) + && features.webengine-arch-support + && features.webengine-gperf + && features.webengine-bison + && features.webengine-flex + && features.webengine-python2 + && (!config.sanitizer || features.webengine-sanitizer) && (!config.linux || features.pkg-config) + && (!config.linux || features.webengine-host-pkg-config) && (!config.win32 || features.webengine-winversion)", "output": [ "privateFeature" ] }, @@ -499,7 +517,6 @@ ] }, "webengine-ozone-x11" : { - "label": "Support qpa-xcb", "condition": "config.unix && features.xcb && features.webengine-system-x11 @@ -647,14 +664,29 @@ "privateFeature", { "type": "varAssign", "name": "PLATFORM_ERROR", "value": "tests.webengine-platform-support.platformSupport" } ] + }, + "webengine-arm-thumb": { + "label": "Thumb instruction set", + "condition": "config.linux && arch.arm && tests.webengine-arm-thumb", + "output": [ "privateFeature" ] + }, + "webengine-sanitizer" : { + "label": "Sanitizer", + "autoDetect": "config.sanitizer && tests.webengine-sanitizer", + "condition": "config.sanitizer", + "output": [ "privateFeature" ] } }, "report": [ { "type": "skipBuildWarning", - "condition": "(!features.webengine-core-support && features.build-qtwebengine-core) || - (!features.webengine-qtpdf-support && features.build-qtpdf)", - "message": "qtwebengine_confCheckError" + "condition": "!features.webengine-core-support && features.build-qtwebengine-core", + "message": "qtwebengine_confCheckWebEngineCoreError" + }, + { + "type": "skipBuildWarning", + "condition": "!features.webengine-qtpdf-support && features.build-qtpdf", + "message": "qtwebengine_confCheckPdfError" }, { "type": "note", @@ -694,6 +726,11 @@ }, "webengine-developer-build", { + "type": "feature", + "args": "webengine-sanitizer", + "condition": "!config.sanitizer" + }, + { "section": "QtWebEngine required system libraries", "condition": "config.unix && !config.macos && !config.ios", "entries": [ @@ -715,7 +752,7 @@ "webengine-system-xi", "webengine-system-xtst" ] - }, + }, { "section": "Optional system libraries used", "condition": "config.unix", diff --git a/src/core/config/common.pri b/src/core/config/common.pri new file mode 100644 index 000000000..c1658ce82 --- /dev/null +++ b/src/core/config/common.pri @@ -0,0 +1,50 @@ + +qtConfig(webengine-printing-and-pdf) { + gn_args += enable_basic_printing=true enable_print_preview=true + gn_args += enable_pdf=true +} else { + gn_args += enable_basic_printing=false enable_print_preview=false + gn_args += enable_pdf=false +} + +qtConfig(webengine-pepper-plugins) { + gn_args += enable_plugins=true +} else { + gn_args += enable_plugins=false +} + +qtConfig(webengine-spellchecker) { + gn_args += enable_spellcheck=true +} else { + gn_args += enable_spellcheck=false +} + +qtConfig(webengine-webrtc) { + gn_args += enable_webrtc=true +} else { + gn_args += enable_webrtc=false audio_processing_in_audio_service_supported=false +} + +qtConfig(webengine-proprietary-codecs) { + gn_args += proprietary_codecs=true ffmpeg_branding=\"Chrome\" +} else { + gn_args += proprietary_codecs=false +} + +qtConfig(webengine-extensions) { + gn_args += enable_extensions=true +} else { + gn_args += enable_extensions=false +} + +qtConfig(webengine-kerberos) { + gn_args += use_kerberos=true +} else { + gn_args += use_kerberos=false +} + +qtConfig(webengine-nodejs) { + gn_args += have_nodejs=true +} else { + gn_args += have_nodejs=false +} diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri new file mode 100644 index 000000000..e98524002 --- /dev/null +++ b/src/core/config/linux.pri @@ -0,0 +1,47 @@ +include(common.pri) + +qtConfig(webengine-embedded-build) { + gn_args += is_desktop_linux=false +} + +!host_build{ + + + + qtConfig(webengine-pulseaudio) { + gn_args += use_pulseaudio=true + } else { + gn_args += use_pulseaudio=false + } + + qtConfig(webengine-alsa) { + gn_args += use_alsa=true + } else { + gn_args += use_alsa=false + } + + !packagesExist(libpci): gn_args += use_libpci=false + + qtConfig(webengine-ozone-x11) { + gn_args += ozone_platform_x11=true + gn_args += use_xkbcommon=true + packagesExist(xscrnsaver): gn_args += use_xscrnsaver=true + qtConfig(webengine-webrtc): gn_args += rtc_use_x11=true + } + + qtConfig(webengine-system-libevent): gn_args += use_system_libevent=true + qtConfig(webengine-system-libwebp): gn_args += use_system_libwebp=true + qtConfig(webengine-system-libxml2): gn_args += use_system_libxml=true use_system_libxslt=true + qtConfig(webengine-system-opus): gn_args += use_system_opus=true + qtConfig(webengine-system-snappy): gn_args += use_system_snappy=true + qtConfig(webengine-system-libvpx): gn_args += use_system_libvpx=true + qtConfig(webengine-system-icu): gn_args += use_system_icu=true icu_use_data_file=false + qtConfig(webengine-system-ffmpeg): gn_args += use_system_ffmpeg=true + qtConfig(webengine-system-re2): gn_args += use_system_re2=true + qtConfig(webengine-system-lcms2): gn_args += use_system_lcms2=true + + # FIXME: + #qtConfig(webengine-system-protobuf): gn_args += use_system_protobuf=true + #qtConfig(webengine-system-jsoncpp): gn_args += use_system_jsoncpp=true + #qtConfig(webengine-system-libsrtp: gn_args += use_system_libsrtp=true +} diff --git a/src/core/config/mac_osx.pri b/src/core/config/mac_osx.pri new file mode 100644 index 000000000..9543daf90 --- /dev/null +++ b/src/core/config/mac_osx.pri @@ -0,0 +1,8 @@ +include(common.pri) + +qtConfig(build-qtwebengine-core):qtConfig(webengine-spellchecker) { + qtConfig(webengine-native-spellchecker): gn_args += use_browser_spellchecker=true + else: gn_args += use_browser_spellchecker=false +} else { + gn_args += use_browser_spellchecker=false +} diff --git a/src/core/config/windows.pri b/src/core/config/windows.pri new file mode 100644 index 000000000..9543daf90 --- /dev/null +++ b/src/core/config/windows.pri @@ -0,0 +1,8 @@ +include(common.pri) + +qtConfig(build-qtwebengine-core):qtConfig(webengine-spellchecker) { + qtConfig(webengine-native-spellchecker): gn_args += use_browser_spellchecker=true + else: gn_args += use_browser_spellchecker=false +} else { + gn_args += use_browser_spellchecker=false +} diff --git a/src/core/configure.json b/src/core/configure.json index 55e68ab04..1a2162723 100644 --- a/src/core/configure.json +++ b/src/core/configure.json @@ -85,18 +85,14 @@ "label": "embedded build", "type": "detectEmbedded" }, - "webengine-sanitizer": { - "label" : "sanitizer support", - "type": "isSanitizerSupported" - }, - "webengine-arm-thumb" : { - "label": "thumb instruction set", - "type": "hasThumbFlag" - }, "webengine-noexecstack" : { "label": "linker supports -z noexecstack", "type": "linkerSupportsFlag", "flag": "-z,noexecstack" + }, + "webengine-nodejs": { + "label": "node.js", + "type": "detectNodeJS" } }, "features": { @@ -187,34 +183,17 @@ "autoDetect": "!features.webengine-embedded-build", "output": [ "privateFeature" ] }, - "webengine-ozone-x11" : { + "webengine-ozone" : { "label": "Support qpa-xcb", - "condition": "config.unix - && features.webengine-system-x11 - && features.webengine-system-libdrm - && features.webengine-system-xcomposite - && features.webengine-system-xcursor - && features.webengine-system-xi - && features.webengine-system-xtst", + "condition": "features.webengine-ozone-x11", "output": [ "privateFeature" ] }, - "webengine-sanitizer" : { - "label": "Sanitizer", - "autoDetect": "config.sanitizer && tests.webengine-sanitizer", - "condition": "config.sanitizer", - "output": [ "privateFeature" ] - }, "webengine-poppler-cpp": { "label": "poppler-cpp", "autoDetect": "config.unix", "condition": "libs.webengine-poppler-cpp", "output": [ "privateFeature" ] }, - "webengine-arm-thumb": { - "label": "Thumb instruction set", - "condition": "config.linux && features.webengine-embedded-build && arch.arm && tests.webengine-arm-thumb", - "output": [ "privateFeature" ] - }, "webengine-full-debug-info": { "label": "Full debug information", "purpose": "Enables debug information for Blink and V8.", @@ -229,17 +208,17 @@ "label": "linker supports -z noexecstack", "condition": "config.unix && tests.webengine-noexecstack", "output": [ "privateFeature" ] + }, + "webengine-nodejs": { + "label": "Node.js", + "condition": "tests.webengine-nodejs", + "output": [ "privateFeature" ] } }, "report": [ { "type": "warning", - "condition": "config.sanitizer && !tests.webengine-sanitizer && !features.webengine-sanitizer", - "message": "Qt WebEngine cannot be built with the chosen sanitizer configuration. Check config.log for details or use -feature-webengine-sanitizer to force the build." - }, - { - "type": "warning", "condition": "config.unix && !features.webengine-host-pkg-config", "message": "host pkg-config not found" }, @@ -252,6 +231,11 @@ "type": "warning", "condition": "config.unix && config.cross_compile && !features.webengine-v8-snapshot-support", "message": "V8 snapshot cannot be built. Most likely, the 32-bit host compiler does not work. Please make sure you have 32-bit devel environment installed." + }, + { + "type": "warning", + "condition": "!features.webengine-nodejs", + "message": "Building without node.js will disable some features of QtWebEngine DevTools." } ], @@ -272,9 +256,10 @@ "webengine-webchannel", "webengine-kerberos", "webengine-extensions", + "webengine-nodejs", { "type": "feature", - "args": "webengine-ozone-x11", + "args": "webengine-ozone", "condition": "config.unix" }, { @@ -293,11 +278,6 @@ "condition": "config.unix" }, { - "type": "feature", - "args": "webengine-sanitizer", - "condition": "config.sanitizer" - }, - { "message": "macOS version", "type": "macosToolchainVersion", "args": "macosVersion", diff --git a/src/core/core.pro b/src/core/core.pro index 9709e62c3..f2d3fd307 100644 --- a/src/core/core.pro +++ b/src/core/core.pro @@ -1,3 +1,5 @@ +include($$QTWEBENGINE_OUT_ROOT/src/buildtools/qtbuildtools-config.pri) +QT_FOR_CONFIG += buildtools-private TEMPLATE = subdirs # core_headers is a dummy module to syncqt the headers so we can @@ -9,8 +11,6 @@ core_api.file = api/core_api.pro core_module.file = core_module.pro core_module.depends = core_api -# core_generator.pro is a dummy .pro file that is used by qmake -# to generate our main .gyp/BUILD.gn file core_generator.file = core_generator.pro core_generator.depends = core_headers @@ -26,11 +26,23 @@ core_api.depends = gn_run core_project.file = core_project.pro core_project.depends = gn_run -SUBDIRS += \ - core_headers \ - core_generator \ - gn_run \ - core_api \ - core_module - -false: SUBDIRS += core_project +!qtConfig(webengine-core-support):qtConfig(build-qtwebengine-core):!build_pass { + !qtwebengine_makeCheckWebEngineCoreError() { + errorbuild.commands = @echo $$shell_quote("QtWebEngineCore module will not be built. $${skipBuildReason}") + } else { + errorbuild.commands = @echo $$shell_quote("QtWebEngineCore module will not be built for unknown reason, please open a bug report at https://bugreports.qt.io") + } + errorbuild.CONFIG = phony + QMAKE_EXTRA_TARGETS += errorbuild + first.depends += errorbuild + QMAKE_EXTRA_TARGETS += first +} else { + SUBDIRS += \ + core_headers \ + core_generator \ + gn_run \ + core_api \ + core_module + + false: SUBDIRS += core_project +} diff --git a/src/core/devtools_frontend_qt.cpp b/src/core/devtools_frontend_qt.cpp index 8d325eca6..52d7dc669 100644 --- a/src/core/devtools_frontend_qt.cpp +++ b/src/core/devtools_frontend_qt.cpp @@ -65,14 +65,17 @@ #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" +#include "content/public/browser/file_url_loader.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_handle.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_view_host.h" +#include "content/public/browser/shared_cors_origin_access_list.h" #include "content/public/browser/storage_partition.h" #include "content/public/browser/web_contents.h" #include "content/public/common/content_client.h" #include "content/public/common/url_constants.h" +#include "content/public/common/url_utils.h" #include "ipc/ipc_channel.h" #include "net/http/http_response_headers.h" #include "net/traffic_annotation/network_traffic_annotation.h" @@ -425,15 +428,28 @@ void DevToolsFrontendQt::HandleMessageFromDevToolsFrontend(const std::string &me resource_request->site_for_cookies = gurl; resource_request->headers.AddHeadersFromString(headers); - auto *partition = content::BrowserContext::GetStoragePartitionForSite( - web_contents()->GetBrowserContext(), gurl); - auto factory = partition->GetURLLoaderFactoryForBrowserProcess(); - + std::unique_ptr<network::mojom::URLLoaderFactory> file_url_loader_factory; + scoped_refptr<network::SharedURLLoaderFactory> network_url_loader_factory; + network::mojom::URLLoaderFactory *url_loader_factory; + if (gurl.SchemeIsFile()) { + file_url_loader_factory = content::CreateFileURLLoaderFactory(base::FilePath(), nullptr); + url_loader_factory = file_url_loader_factory.get(); + } else if (content::HasWebUIScheme(gurl)) { + base::DictionaryValue response; + response.SetInteger("statusCode", 403); + SendMessageAck(request_id, &response); + return; + } else { + auto *partition = content::BrowserContext::GetStoragePartitionForSite( + web_contents()->GetBrowserContext(), gurl); + network_url_loader_factory = partition->GetURLLoaderFactoryForBrowserProcess(); + url_loader_factory = network_url_loader_factory.get(); + } auto simple_url_loader = network::SimpleURLLoader::Create( std::move(resource_request), traffic_annotation); auto resource_loader = std::make_unique<NetworkResourceLoader>( stream_id, request_id, this, std::move(simple_url_loader), - factory.get()); + url_loader_factory); m_loaders.insert(std::move(resource_loader)); return; } else if (method == "getPreferences") { diff --git a/src/core/file_picker_controller.cpp b/src/core/file_picker_controller.cpp index 01a6d0746..65e2c6f00 100644 --- a/src/core/file_picker_controller.cpp +++ b/src/core/file_picker_controller.cpp @@ -120,7 +120,7 @@ void FilePickerController::accepted(const QStringList &files) } // Build absolute path from file URI componenets. - for (int j = 1; j < pathComponents.size(); j++) + for (size_t j = 1; j < pathComponents.size(); j++) absolutePath += toQt(pathComponents[j]) + (j != pathComponents.size()-1 ? "/" : ""); if (toFilePath(absolutePath).IsAbsolute()) { diff --git a/src/core/gn_run.pro b/src/core/gn_run.pro index f72efc8d5..4688ea59d 100644 --- a/src/core/gn_run.pro +++ b/src/core/gn_run.pro @@ -25,7 +25,7 @@ build_pass|!debug_and_release { runninja.target = run_ninja - gn_args = $$gnArgs() + gn_args = $$gnWebEngineArgs() gn_args += "qtwebengine_target=\"$$system_path($$OUT_PWD/$$getConfigDir()):QtWebEngineCore\"" diff --git a/src/core/ozone/gl_surface_egl_qt.cpp b/src/core/ozone/gl_surface_egl_qt.cpp index a6988bbf3..ac0e79b67 100644 --- a/src/core/ozone/gl_surface_egl_qt.cpp +++ b/src/core/ozone/gl_surface_egl_qt.cpp @@ -72,6 +72,9 @@ bool GLSurfaceEGLQt::InitializeOneOff() if (s_initialized) return true; + // Must be called before initializing the display. + g_driver_egl.InitializeClientExtensionBindings(); + g_display = GLContextHelper::getEGLDisplay(); if (!g_display) { LOG(ERROR) << "GLContextHelper::getEGLDisplay() failed."; @@ -107,6 +110,10 @@ bool GLSurfaceEGLQt::InitializeOneOff() context->ReleaseCurrent(surface.get()); } } + + // Must be called after initializing the display. + g_driver_egl.InitializeExtensionBindings(); + s_initialized = true; return true; } diff --git a/src/core/qtwebengine_sources.gni b/src/core/qtwebengine_sources.gni index 9c65fa690..3a39455c3 100644 --- a/src/core/qtwebengine_sources.gni +++ b/src/core/qtwebengine_sources.gni @@ -47,6 +47,7 @@ source_set("qtwebengine_sources") { deps = [ "//build:branding_buildflags", + "//chrome/browser/resources/quota_internals:quota_internals_resources", "//chrome/common:buildflags", "//components/nacl/common:buildflags", "//components/plugins/renderer/", diff --git a/src/core/renderer_host/user_resource_controller_host.cpp b/src/core/renderer_host/user_resource_controller_host.cpp index 96625c13f..6b9bb63fe 100644 --- a/src/core/renderer_host/user_resource_controller_host.cpp +++ b/src/core/renderer_host/user_resource_controller_host.cpp @@ -148,17 +148,6 @@ void UserResourceControllerHost::addUserScript(const UserScript &script, WebCont } } -bool UserResourceControllerHost::containsUserScript(const UserScript &script, WebContentsAdapter *adapter) -{ - if (script.isNull()) - return false; - // Global scripts should be dispatched to all our render processes. - const bool isProfileWideScript = !adapter; - if (isProfileWideScript) - return m_profileWideScripts.contains(script); - return m_perContentsScripts.value(adapter->webContents()).contains(script); -} - bool UserResourceControllerHost::removeUserScript(const UserScript &script, WebContentsAdapter *adapter) { if (script.isNull()) @@ -201,14 +190,6 @@ void UserResourceControllerHost::clearAllScripts(WebContentsAdapter *adapter) } } -const QList<UserScript> UserResourceControllerHost::registeredScripts(WebContentsAdapter *adapter) const -{ - const bool isProfileWideScript = !adapter; - if (isProfileWideScript) - return m_profileWideScripts; - return m_perContentsScripts.value(adapter->webContents()); -} - void UserResourceControllerHost::reserve(WebContentsAdapter *adapter, int count) { const bool isProfileWideScript = !adapter; diff --git a/src/core/renderer_host/user_resource_controller_host.h b/src/core/renderer_host/user_resource_controller_host.h index 9d828feb6..7b89cb893 100644 --- a/src/core/renderer_host/user_resource_controller_host.h +++ b/src/core/renderer_host/user_resource_controller_host.h @@ -74,11 +74,9 @@ public: ~UserResourceControllerHost(); void addUserScript(const UserScript &script, WebContentsAdapter *adapter); - bool containsUserScript(const UserScript &script, WebContentsAdapter *adapter); bool removeUserScript(const UserScript &script, WebContentsAdapter *adapter); void clearAllScripts(WebContentsAdapter *adapter); void reserve(WebContentsAdapter *adapter, int count); - const QList<UserScript> registeredScripts(WebContentsAdapter *adapter) const; void renderProcessStartedWithHost(content::RenderProcessHost *renderer); diff --git a/src/core/user_script.cpp b/src/core/user_script.cpp index bdd6524ca..7ccb6e10a 100644 --- a/src/core/user_script.cpp +++ b/src/core/user_script.cpp @@ -194,6 +194,11 @@ UserScriptData &UserScript::data() const void UserScript::parseMetadataHeader() { + // Clear previous values + scriptData->globs.clear(); + scriptData->excludeGlobs.clear(); + scriptData->urlPatterns.clear(); + // Logic taken from Chromium (extensions/browser/user_script_loader.cc) // http://wiki.greasespot.net/Metadata_block const std::string &script_text = scriptData->source; diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 53dfcb8a2..77dd4593f 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -205,12 +205,9 @@ void WebContentsDelegateQt::NavigationStateChanged(content::WebContents* source, } } - // NavigationStateChanged gets called with INVALIDATE_TYPE_TAB by AudioStateProvider::Notify, - // whenever an audio sound gets played or stopped, this is the only way to actually figure out - // if there was a recently played audio sound. // Make sure to only emit the signal when loading isn't in progress, because it causes multiple // false signals to be emitted. - if ((changed_flags & content::INVALIDATE_TYPE_TAB) && !(changed_flags & content::INVALIDATE_TYPE_LOAD)) { + if ((changed_flags & content::INVALIDATE_TYPE_AUDIO) && !(changed_flags & content::INVALIDATE_TYPE_LOAD)) { m_viewClient->recentlyAudibleChanged(source->IsCurrentlyAudible()); } } diff --git a/src/pdf/config/common.pri b/src/pdf/config/common.pri new file mode 100644 index 000000000..dd5bfa293 --- /dev/null +++ b/src/pdf/config/common.pri @@ -0,0 +1,38 @@ +include($$QTWEBENGINE_OUT_ROOT/src/pdf/qtpdf-config.pri) +QT_FOR_CONFIG += pdf-private + +qtConfig(pdf-v8) { + gn_args += pdf_enable_v8=true +} else { + gn_args += pdf_enable_v8=false +} + +qtConfig(pdf-xfa) { + gn_args += pdf_enable_xfa=true +} else { + gn_args += pdf_enable_xfa=false +} + +qtConfig(pdf-xfa-bmp) { + gn_args += pdf_enable_xfa_bmp=true +} else { + gn_args += pdf_enable_xfa_bmp=false +} + +qtConfig(pdf-xfa-gif) { + gn_args += pdf_enable_xfa_gif=true +} else { + gn_args += pdf_enable_xfa_gif=false +} + +qtConfig(pdf-xfa-png) { + gn_args += pdf_enable_xfa_png=true +} else { + gn_args += pdf_enable_xfa_png=false +} + +qtConfig(pdf-xfa-tiff) { + gn_args += pdf_enable_xfa_tiff=true +} else { + gn_args += pdf_enable_xfa_tiff=false +} diff --git a/src/buildtools/config/ios.pri b/src/pdf/config/ios.pri index 5dc7faf9d..5dc7faf9d 100644 --- a/src/buildtools/config/ios.pri +++ b/src/pdf/config/ios.pri diff --git a/src/pdf/gn_run.pro b/src/pdf/gn_run.pro index 87070fd81..70ee582a9 100644 --- a/src/pdf/gn_run.pro +++ b/src/pdf/gn_run.pro @@ -29,9 +29,7 @@ build_pass|!debug_and_release { runninja.target = run_ninja # fixme: refine args - gn_args = $$gnArgs() - - include($$QTWEBENGINE_ROOT/src/buildtools/config/pdf.pri) + gn_args = $$gnPdfArgs() # fixme: qtwebengine_target gn_args += "qtwebengine_target=\"$$system_path($$OUT_PWD/$$getConfigDir()):QtPdf\"" diff --git a/src/pdf/pdf.pro b/src/pdf/pdf.pro index c5513ce93..fcdfafab5 100644 --- a/src/pdf/pdf.pro +++ b/src/pdf/pdf.pro @@ -1,3 +1,5 @@ +include($$QTWEBENGINE_OUT_ROOT/src/buildtools/qtbuildtools-config.pri) +QT_FOR_CONFIG += buildtools-private TEMPLATE = subdirs pdfcore.file = pdfcore.pro pdfcore_generator.file = pdfcore_generator.pro @@ -7,10 +9,21 @@ gn_run.depends = pdfcore_generator pdfcore.depends = gn_run quick.depends = pdfcore -SUBDIRS += \ - pdfcore_generator \ - gn_run \ - pdfcore \ - quick - +!qtConfig(webengine-qtpdf-support):qtConfig(build-qtpdf)::!build_pass { + !qtwebengine_makeCheckPdfError() { + errorbuild.commands = @echo $$shell_quote("QtPdf will not be built. $${skipBuildReason}") + } else { + errorbuild.commands = @echo $$shell_quote("QtPdf module will not be built for unknown reason, please open a bug report at https://bugreports.qt.io") + } + errorbuild.CONFIG = phony + QMAKE_EXTRA_TARGETS += errorbuild + first.depends += errorbuild + QMAKE_EXTRA_TARGETS += first +} else { + SUBDIRS += \ + pdfcore_generator \ + gn_run \ + pdfcore \ + quick +} diff --git a/src/pdf/pdfcore_generator.pro b/src/pdf/pdfcore_generator.pro index c8eb13b81..e5c7258b7 100644 --- a/src/pdf/pdfcore_generator.pro +++ b/src/pdf/pdfcore_generator.pro @@ -3,7 +3,7 @@ qtConfig(debug_and_release): CONFIG += debug_and_release TARGET = QtPdf TEMPLATE = lib CONFIG = gn_generator $$CONFIG -ios: CONFIG -=static # note we still do static on ios when linking +CONFIG -=static # note we still do static when linking GN_SRC_DIR = $$PWD GN_FILE = $$OUT_PWD/$$getConfigDir()/BUILD.gn GN_FIND_MOCABLES_SCRIPT = $$shell_path($$QTWEBENGINE_ROOT/tools/scripts/gn_find_mocables.py) diff --git a/src/src.pro b/src/src.pro index 0247f937e..143fd00ab 100644 --- a/src/src.pro +++ b/src/src.pro @@ -7,12 +7,17 @@ include($$QTWEBENGINE_OUT_ROOT/src/webenginewidgets/qtwebenginewidgets-config.pr include($$QTWEBENGINE_OUT_ROOT/src/pdf/qtpdf-config.pri) include($$QTWEBENGINE_OUT_ROOT/src/pdfwidgets/qtpdfwidgets-config.pri) -QT_FOR_CONFIG += buildtools-private webenginecore webenginecore-private webengine-private \ - webenginewidgets-private pdf-private pdfwidgets-private +QT_FOR_CONFIG += \ + buildtools-private \ + webenginecore \ + webenginecore-private \ + webengine-private \ + webenginewidgets-private \ + pdf-private \ + pdfwidgets-private TEMPLATE = subdirs - qtConfig(build-qtwebengine-core):qtConfig(webengine-core-support) { core.depends = buildtools process.depends = core @@ -43,9 +48,9 @@ qtConfig(build-qtwebengine-core):qtConfig(webengine-core-support) { qtConfig(build-qtpdf):qtConfig(webengine-qtpdf-support) { pdf.depends = buildtools qtConfig(build-qtwebengine-core):qtConfig(webengine-core-support): pdf.depends += core - SUBDIRS += pdf !contains(SUBDIRS, buildtools): SUBDIRS += buildtools !contains(SUBDIRS, plugins): SUBDIRS += plugins + SUBDIRS += pdf plugins.depends += pdf qtConfig(pdf-widgets) { pdfwidgets.depends = pdf @@ -53,12 +58,6 @@ qtConfig(build-qtpdf):qtConfig(webengine-qtpdf-support) { } } -!qtConfig(webengine-core-support):if(qtConfig(build-qtwebengine-core)|qtConfig(build-qtpdf)) { - !qtwebengine_makeCheckError():!isEmpty(skipBuildReason):!build_pass { - errorbuild.commands = @echo $$shell_quote(Modules will not be built. $${skipBuildReason}) - errorbuild.CONFIG = phony - QMAKE_EXTRA_TARGETS += errorbuild - first.depends += errorbuild - QMAKE_EXTRA_TARGETS += first - } -} +# this needs to be last line for qmake -r +qtConfig(build-qtwebengine-core):!contains(SUBDIRS, core): SUBDIRS += core +qtConfig(build-qtpdf):!contains(SUBDIRS, pdf): SUBDIRS += pdf diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 9b71e1183..53f223642 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,14 +1,25 @@ -TEMPLATE = subdirs -qtHaveModule(webengine) { - SUBDIRS += quick -} +include($$QTWEBENGINE_OUT_ROOT/src/buildtools/qtbuildtools-config.pri) +include($$QTWEBENGINE_OUT_ROOT/src/webengine/qtwebengine-config.pri) +include($$QTWEBENGINE_OUT_ROOT/src/webenginewidgets/qtwebenginewidgets-config.pri) +include($$QTWEBENGINE_OUT_ROOT/src/pdf/qtpdf-config.pri) +include($$QTWEBENGINE_OUT_ROOT/src/pdfwidgets/qtpdfwidgets-config.pri) + +QT_FOR_CONFIG += \ + buildtools-private \ + webengine-private \ + webenginewidgets-private \ + pdf-private \ + pdfwidgets-private + +TEMPLATE = subdirs -qtHaveModule(webenginewidgets) { - SUBDIRS += core widgets +qtConfig(build-qtwebengine-core):qtConfig(webengine-core-support) { + qtConfig(webengine-qml): SUBDIRS += quick + qtConfig(webengine-widgets): SUBDIRS += core widgets } -qtHaveModule(pdf) { +qtConfig(build-qtpdf):qtConfig(webengine-qtpdf-support) { SUBDIRS += pdf } diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 7bd540cc6..16670ff30 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -229,6 +229,8 @@ private Q_SLOTS: void backgroundColor(); void audioMuted(); void closeContents(); + void isSafeRedirect_data(); + void isSafeRedirect(); private: static QPoint elementCenter(QWebEnginePage *page, const QString &id); @@ -4648,6 +4650,36 @@ void tst_QWebEnginePage::closeContents() delete dialogView; } +// Based on QTBUG-84011 +void tst_QWebEnginePage::isSafeRedirect_data() +{ + QTest::addColumn<QUrl>("requestedUrl"); + QTest::addColumn<QUrl>("expectedUrl"); + QString fileScheme = "file://"; + +#ifdef Q_OS_WIN + fileScheme += "/"; +#endif + + QString tempDir(fileScheme + QDir::tempPath()); + QTest::newRow(qPrintable(tempDir)) << QUrl(tempDir) << QUrl(tempDir + "/"); + QTest::newRow(qPrintable(tempDir + QString("/foo/bar"))) << QUrl(tempDir + "/foo/bar") << QUrl(tempDir + "/foo/bar"); + QTest::newRow("filesystem:http://foo.com/bar") << QUrl("filesystem:http://foo.com/bar") << QUrl("filesystem:http://foo.com/bar/"); +} + +void tst_QWebEnginePage::isSafeRedirect() +{ + QFETCH(QUrl, requestedUrl); + QFETCH(QUrl, expectedUrl); + + TestPage page; + QSignalSpy spy(&page, SIGNAL(loadFinished(bool))); + page.setUrl(requestedUrl); + QTRY_COMPARE_WITH_TIMEOUT(spy.count(), 1, 20000); + QCOMPARE(page.url(), expectedUrl); + spy.clear(); +} + static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")}; W_QTEST_MAIN(tst_QWebEnginePage, params) diff --git a/tests/auto/widgets/qwebenginescript/resources/title_a.html b/tests/auto/widgets/qwebenginescript/resources/title_a.html new file mode 100644 index 000000000..d1ca96eaa --- /dev/null +++ b/tests/auto/widgets/qwebenginescript/resources/title_a.html @@ -0,0 +1,9 @@ +<!DOCTYPE html> +<html> + <head> + <title>A</title> + </head> + <body> + <p>Page A</p> + </body> +</html> diff --git a/tests/auto/widgets/qwebenginescript/resources/title_b.html b/tests/auto/widgets/qwebenginescript/resources/title_b.html new file mode 100644 index 000000000..fd1fda99e --- /dev/null +++ b/tests/auto/widgets/qwebenginescript/resources/title_b.html @@ -0,0 +1,9 @@ +<!DOCTYPE html> +<html> + <head> + <title>B</title> + </head> + <body> + <p>Page B</p> + </body> +</html> diff --git a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp index 2044f0df4..32384aec2 100644 --- a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp +++ b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp @@ -593,27 +593,22 @@ void tst_QWebEngineScript::webChannelWithBadString() void tst_QWebEngineScript::matchQrcUrl() { - QWebEnginePage page; - QWebEngineView view; - view.setPage(&page); + QWebEngineProfile profile; + QWebEnginePage page(&profile); QWebEngineScript s; s.setInjectionPoint(QWebEngineScript::DocumentReady); s.setWorldId(QWebEngineScript::MainWorld); - - s.setSourceCode(QStringLiteral(R"( // ==UserScript== -// @match qrc:/*main.html +// @match qrc:/*title_b.html // ==/UserScript== document.title = 'New title'; )")); - page.scripts().insert(s); - page.load(QUrl("qrc:/resources/test_iframe_main.html")); - view.show(); - QSignalSpy spyFinished(&page, &QWebEnginePage::loadFinished); - QVERIFY(spyFinished.wait()); + loadSync(&page, QUrl("qrc:/resources/title_a.html")); + QCOMPARE(page.title(), "A"); + loadSync(&page, QUrl("qrc:/resources/title_b.html")); QCOMPARE(page.title(), "New title"); } diff --git a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.qrc b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.qrc index ada06119a..3290cb588 100644 --- a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.qrc +++ b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.qrc @@ -4,6 +4,8 @@ <file>resources/test_iframe_outer.html</file> <file>resources/test_iframe_inner.html</file> <file>resources/test_window_open.html</file> + <file>resources/title_a.html</file> + <file>resources/title_b.html</file> <file>resources/webChannelWithBadString.html</file> </qresource> </RCC> |