diff --git a/configure.json b/configure.json index 7f5f46f72d5c6ec45caf9119e43cbc5e00daeea7..531a034e65d8ba2a1c959e1f1262a229df45957c 100644 --- a/configure.json +++ b/configure.json @@ -1,11 +1,15 @@ { "module": "webengine", + "depends": [ + "printsupport" + ], "testDir": "tools/qmake/config.tests", "commandline": { "options": { "alsa": "boolean", + "printing-and-pdf": "boolean", "proprietary-codecs": "boolean", "pulseaudio": "boolean", "spellchecker": "boolean" @@ -51,6 +55,13 @@ "condition": "libs.pulseaudio", "output": [ "privateFeature" ] }, + "printing-and-pdf": { + "label": "Printing and PDF", + "condition": "module.printsupport && features.printer", + "autoDetect": "!features.cross_compile", + "purpose": "Enables printing and output to PDF", + "output": [ "privateFeature" ] + }, "proprietary-codecs": { "label": "Proprietary Codecs", "autoDetect": false, @@ -78,6 +89,7 @@ { "section": "Qt WebEngine", "entries": [ + "printing-and-pdf", "proprietary-codecs", "spellchecker", "system-gn", diff --git a/src/core/config/common.pri b/src/core/config/common.pri index b5bb23684f1db0e150fb53aa2f0dbeba099824e5..b125cff93e9521b91ce4742291c6cf6275127a24 100644 --- a/src/core/config/common.pri +++ b/src/core/config/common.pri @@ -13,3 +13,15 @@ sanitize_address: GYP_CONFIG += asan=1 sanitize_thread: GYP_CONFIG += tsan=1 sanitize_memory: GYP_CONFIG += msan=1 sanitize_undefined: GYP_CONFIG += ubsan=1 + +use?(printing) { + GYP_CONFIG += enable_basic_printing=1 enable_print_preview=1 +} else { + GYP_CONFIG += enable_basic_printing=0 enable_print_preview=0 +} + +use?(pdf) { + GYP_CONFIG += enable_pdf=1 +} else { + GYP_CONFIG += enable_pdf=0 +} diff --git a/src/core/config/desktop_linux.pri b/src/core/config/desktop_linux.pri index 23044619b5d5cfbb6977636f2c893670f094d3e2..2a39f7aee3ee133993a8de99ea16d6b755226bd7 100644 --- a/src/core/config/desktop_linux.pri +++ b/src/core/config/desktop_linux.pri @@ -4,10 +4,7 @@ include(linux.pri) GYP_CONFIG += \ desktop_linux=1 \ - enable_widevine=1 \ - enable_basic_printing=1 \ - enable_print_preview=1 \ - enable_pdf=1 + enable_widevine=1 clang { GYP_CONFIG += werror= diff --git a/src/core/config/embedded_linux.pri b/src/core/config/embedded_linux.pri index 7a909f1e2a803642ab544d5939f168be8ddd06ad..e390a158fad5f3494feb7a9cb546dad7490d1d80 100644 --- a/src/core/config/embedded_linux.pri +++ b/src/core/config/embedded_linux.pri @@ -9,16 +9,13 @@ GYP_CONFIG += \ embedded=1 \ enable_autofill_dialog=0 \ enable_automation=0 \ - enable_basic_printing=0 \ enable_captive_portal_detection=0 \ enable_extensions=0 \ enable_google_now=0 \ enable_language_detection=0 \ enable_managed_users=0 \ - enable_pdf=0 \ enable_plugin_installation=0 \ enable_plugins=0 \ - enable_print_preview=0 \ enable_session_service=0 \ enable_task_manager=0 \ enable_themes=0 \ @@ -39,6 +36,6 @@ GYP_CONFIG += \ use_x11=0 \ v8_use_snapshot=false \ want_separate_host_toolset=1 \ - angle_enable_gl=0Â \ + angle_enable_gl=0 WEBENGINE_CONFIG *= reduce_binary_size diff --git a/src/core/config/embedded_qnx.pri b/src/core/config/embedded_qnx.pri index 3effdb8161ea88e657af5687ba34d3af84010d75..f248887760c259126510c362b940034fd8eec0d7 100644 --- a/src/core/config/embedded_qnx.pri +++ b/src/core/config/embedded_qnx.pri @@ -4,9 +4,6 @@ include(common.pri) GYP_CONFIG += \ disable_nacl=1 \ - enable_basic_printing=0 \ - enable_pdf=0 \ - enable_plugins=0 \ enable_webrtc=0 \ use_ash=0 \ use_aura=1 \ diff --git a/src/core/config/mac_osx.pri b/src/core/config/mac_osx.pri index 4111236eda510ba44f129e70ab7b816e558d0413..17f2004496392311ade2946b792cb50914b78063 100644 --- a/src/core/config/mac_osx.pri +++ b/src/core/config/mac_osx.pri @@ -25,10 +25,7 @@ GYP_CONFIG += \ mac_deployment_target=\"$${QMAKE_MACOSX_DEPLOYMENT_TARGET}\" \ make_clang_dir=\"$${QMAKE_CLANG_DIR}\" \ clang_use_chrome_plugins=0 \ - enable_widevine=1 \ - enable_basic_printing=1 \ - enable_print_preview=1 \ - enable_pdf=1 + enable_widevine=1 # Force touch API is used in 49-based Chromium, which is included starting with 10.10.3 SDK, so we # disable the API usage if the SDK version is lower. diff --git a/src/core/config/windows.pri b/src/core/config/windows.pri index a1c116ff84c93e0d046aa660771dfa07c488eb76..51b83ac0409687ad1f787726a9f3636222ded2e4 100644 --- a/src/core/config/windows.pri +++ b/src/core/config/windows.pri @@ -6,10 +6,7 @@ GYP_CONFIG += \ disable_nacl=1 \ remoting=0 \ use_ash=0 \ - enable_widevine=1 \ - enable_basic_printing=1 \ - enable_print_preview=1 \ - enable_pdf=1 + enable_widevine=1 # Libvpx build needs additional search path on Windows. GYP_ARGS += "-D qtwe_chromium_obj_dir=\"$$OUT_PWD/$$getConfigDir()/obj/$${getChromiumSrcDir()}\"" diff --git a/src/core/core_generator.pro b/src/core/core_generator.pro index 6071333aa1c2c0870560a79fe19072dc6c546660..15e27997a8198fb7ffaf2f410164448defb678ce 100644 --- a/src/core/core_generator.pro +++ b/src/core/core_generator.pro @@ -75,7 +75,6 @@ SOURCES = \ native_web_keyboard_event_qt.cpp \ network_delegate_qt.cpp \ ozone_platform_eglfs.cpp \ - pdfium_document_wrapper_qt.cpp \ permission_manager_qt.cpp \ process_main.cpp \ proxy_config_service_qt.cpp \ @@ -156,7 +155,6 @@ HEADERS = \ media_capture_devices_dispatcher.h \ network_delegate_qt.h \ ozone_platform_eglfs.h \ - pdfium_document_wrapper_qt.h \ permission_manager_qt.h \ process_main.h \ proxy_config_service_qt.h \ @@ -198,6 +196,26 @@ HEADERS = \ web_engine_visited_links_manager.h \ web_event_factory.h + +use?(pdf) { + SOURCES += pdfium_document_wrapper_qt.cpp + HEADERS += pdfium_document_wrapper_qt.h +} + +use?(printing) { + SOURCES += \ + printing_message_filter_qt.cpp \ + print_view_manager_base_qt.cpp \ + print_view_manager_qt.cpp \ + renderer/print_web_view_helper_delegate_qt.cpp + + HEADERS += \ + printing_message_filter_qt.h \ + print_view_manager_base_qt.h \ + print_view_manager_qt.h \ + renderer/print_web_view_helper_delegate_qt.h +} + contains(QT_CONFIG, opengl) { SOURCES += \ yuv_video_node.cpp \ diff --git a/src/core/qtwebengine.gypi b/src/core/qtwebengine.gypi index d0ab015344f274febe57c4a42d546737df4cf73e..5131ce8cc4b5ea9725894c5a2551a4639416c2bf 100644 --- a/src/core/qtwebengine.gypi +++ b/src/core/qtwebengine.gypi @@ -126,16 +126,6 @@ '<(chromium_src_dir)/components/components.gyp:printing_browser', '<(chromium_src_dir)/components/components.gyp:printing_common', '<(chromium_src_dir)/components/components.gyp:printing_renderer', - ], - 'sources': [ - 'printing_message_filter_qt.cpp', - 'print_view_manager_base_qt.cpp', - 'print_view_manager_qt.cpp', - 'printing_message_filter_qt.h', - 'print_view_manager_base_qt.h', - 'print_view_manager_qt.h', - 'renderer/print_web_view_helper_delegate_qt.cpp', - 'renderer/print_web_view_helper_delegate_qt.h', ] }], ['icu_use_data_file_flag==1', { diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 76d1ca8b591dbed6ff3036b11584a679d062a525..a19f0be530d0ae992a6ef6e9e26bb4329b470931 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -1326,7 +1326,7 @@ void QQuickWebEngineView::printToPdf(const QString& filePath, PrintedPageSizeId void QQuickWebEngineView::printToPdf(const QJSValue &callback, PrintedPageSizeId pageSizeId, PrintedPageOrientation orientation) { -#if defined (ENABLE_PDF) +#if defined(ENABLE_PDF) Q_D(QQuickWebEngineView); QPageSize layoutSize(static_cast<QPageSize::PageSizeId>(pageSizeId)); QPageLayout::Orientation layoutOrientation = static_cast<QPageLayout::Orientation>(orientation); diff --git a/src/webengine/webengine.pro b/src/webengine/webengine.pro index 2bbf8281094e57b60adff0d832bb2fde015d394e..5fa49c77e9f02825bddbc703d0ff02769601eb1b 100644 --- a/src/webengine/webengine.pro +++ b/src/webengine/webengine.pro @@ -65,7 +65,7 @@ contains(WEBENGINE_CONFIG, use_spellchecker) { DEFINES += ENABLE_SPELLCHECK } -contains(WEBENGINE_CONFIG, enable_pdf) { +use?(pdf) { DEFINES += ENABLE_PDF } diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index ae7b209e47be3dd40cdb5d5a5df9c19c5d129064..2af3db4145232f866cd4512bffb0bed04912ccc2 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -80,9 +80,11 @@ #include <QMenu> #include <QMessageBox> #include <QMimeData> +#if defined(QT_PRINTSUPPORT_LIB) #ifndef QT_NO_PRINTER #include <QPrinter> -#endif +#endif //QT_NO_PRINTER +#endif //QT_PRINTSUPPORT_LIB #include <QStandardPaths> #include <QStyle> #include <QTimer> @@ -96,8 +98,7 @@ using namespace QtWebEngineCore; static const int MaxTooltipLength = 1024; -#ifndef QT_NO_PRINTER -#if defined(ENABLE_PDF) +#if defined(ENABLE_PRINTING) && defined(ENABLE_PDF) static bool printPdfDataOnPrinter(const QByteArray& data, QPrinter& printer) { QRect printerPageRect = printer.pageRect(); @@ -174,8 +175,7 @@ static bool printPdfDataOnPrinter(const QByteArray& data, QPrinter& printer) return true; } -#endif // defined(ENABLE_PDF) -#endif // QT_NO_PRINTER +#endif // defined(ENABLE_PRINTING) && defined(ENABLE_PDF) static QWebEnginePage::WebWindowType toWindowType(WebContentsAdapterClient::WindowOpenDisposition disposition) { @@ -227,7 +227,7 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile) , fullscreenMode(false) , webChannel(nullptr) , webChannelWorldId(QWebEngineScript::MainWorld) -#ifndef QT_NO_PRINTER +#if defined(ENABLE_PRINTING) , currentPrinter(nullptr) #endif { @@ -484,7 +484,7 @@ void QWebEnginePagePrivate::didFindText(quint64 requestId, int matchCount) void QWebEnginePagePrivate::didPrintPage(quint64 requestId, const QByteArray &result) { #if defined(ENABLE_PDF) -#ifndef QT_NO_PRINTER +#if defined(ENABLE_PRINTING) // If no currentPrinter is set that means that were printing to PDF only. if (!currentPrinter) { m_callbacks.invoke(requestId, result); @@ -497,7 +497,7 @@ void QWebEnginePagePrivate::didPrintPage(quint64 requestId, const QByteArray &re currentPrinter = nullptr; #else // If print support is disabled, only PDF printing is available. m_callbacks.invoke(requestId, result); -#endif // ifndef QT_NO_PRINTER +#endif // defined(ENABLE_PRINTING) #else // defined(ENABLE_PDF) // we should never enter this branch, but just for safe-keeping... Q_UNUSED(result); @@ -1985,7 +1985,7 @@ void QWebEnginePage::printToPdf(const QString &filePath, const QPageLayout &page { #if defined(ENABLE_PDF) Q_D(const QWebEnginePage); -#ifndef QT_NO_PRINTER +#if defined(ENABLE_PRINTING) if (d->currentPrinter) { #if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) qWarning("Cannot print to PDF while at the same time printing on printer %ls", qUtf16Printable(d->currentPrinter->printerName())); @@ -1994,7 +1994,7 @@ void QWebEnginePage::printToPdf(const QString &filePath, const QPageLayout &page #endif return; } -#endif +#endif // ENABLE_PRINTING d->adapter->printToPDF(pageLayout, filePath); #else Q_UNUSED(filePath); @@ -2018,7 +2018,7 @@ void QWebEnginePage::printToPdf(const QWebEngineCallback<const QByteArray&> &res { Q_D(QWebEnginePage); #if defined(ENABLE_PDF) -#ifndef QT_NO_PRINTER +#if defined(ENABLE_PRINTING) if (d->currentPrinter) { #if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) qWarning("Cannot print to PDF while at the same time printing on printer %ls", qUtf16Printable(d->currentPrinter->printerName())); @@ -2028,7 +2028,7 @@ void QWebEnginePage::printToPdf(const QWebEngineCallback<const QByteArray&> &res d->m_callbacks.invokeEmpty(resultCallback); return; } -#endif // ifndef QT_NO_PRINTER +#endif // ENABLE_PRINTING quint64 requestId = d->adapter->printToPDFCallbackResult(pageLayout); d->m_callbacks.registerCallback(requestId, resultCallback); #else // if defined(ENABLE_PDF) @@ -2037,6 +2037,7 @@ void QWebEnginePage::printToPdf(const QWebEngineCallback<const QByteArray&> &res #endif // if defined(ENABLE_PDF) } +#if defined(QT_PRINTSUPPORT_LIB) #ifndef QT_NO_PRINTER /*! \fn void QWebEnginePage::print(QPrinter *printer, FunctorOrLambda resultCallback) @@ -2055,6 +2056,7 @@ void QWebEnginePage::print(QPrinter *printer, const QWebEngineCallback<bool> &re { Q_D(QWebEnginePage); #if defined(ENABLE_PDF) +#if defined(ENABLE_PRINTING) if (d->currentPrinter) { #if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) qWarning("Cannot print page on printer %ls: Already printing on %ls.", qUtf16Printable(printer->printerName()), qUtf16Printable(d->currentPrinter->printerName())); @@ -2065,6 +2067,7 @@ void QWebEnginePage::print(QPrinter *printer, const QWebEngineCallback<bool> &re return; } d->currentPrinter = printer; +#endif // ENABLE_PRINTING quint64 requestId = d->adapter->printToPDFCallbackResult(printer->pageLayout(), printer->colorMode() == QPrinter::Color); d->m_callbacks.registerCallback(requestId, resultCallback); #else // if defined(ENABLE_PDF) @@ -2072,7 +2075,8 @@ void QWebEnginePage::print(QPrinter *printer, const QWebEngineCallback<bool> &re d->m_callbacks.invokeDirectly(resultCallback, false); #endif // if defined(ENABLE_PDF) } -#endif // QT_NO_PRINTER +#endif // if defined(QT_NO_PRINTER) +#endif // if defined(QT_PRINTSUPPORT_LIB) /*! \since 5.7 diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h index 75621304bc1f5797ad2f8090af684e7c87245641..bc5799aac0e2d63d748e9085464ebd6ef5e1d8ea 100644 --- a/src/webenginewidgets/api/qwebenginepage.h +++ b/src/webenginewidgets/api/qwebenginepage.h @@ -55,9 +55,12 @@ QT_BEGIN_NAMESPACE class QMenu; +#if defined(QT_PRINTSUPPORT_LIB) #ifndef QT_NO_PRINTER class QPrinter; -#endif +#endif // QT_NO_PRINTER +#endif // QT_PRINTSUPPORT_LIB + class QWebChannel; class QWebEngineContextMenuData; class QWebEngineFullScreenRequest; @@ -283,6 +286,7 @@ public: void printToPdf(const QWebEngineCallback<const QByteArray&> &resultCallback, const QPageLayout &layout = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF())); #endif +#if defined(QT_PRINTSUPPORT_LIB) #ifndef QT_NO_PRINTER #ifdef Q_QDOC void print(QPrinter *printer, FunctorOrLambda resultCallback); @@ -290,6 +294,7 @@ public: void print(QPrinter *printer, const QWebEngineCallback<bool> &resultCallback); #endif // QDOC #endif // QT_NO_PRINTER +#endif // QT_PRINTSUPPORT_LIB const QWebEngineContextMenuData &contextMenuData() const; diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index 99caeac865dd8b40b6cc49db37e73544366cb037..c7b805c45405e58a15023afe02d7bb8586eb2047 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -179,9 +179,9 @@ public: mutable QtWebEngineCore::CallbackDirectory m_callbacks; mutable QAction *actions[QWebEnginePage::WebActionCount]; -#ifndef QT_NO_PRINTER +#if defined(ENABLE_PRINTING) QPrinter *currentPrinter; -#endif // QT_NO_PRINTER +#endif }; QT_END_NAMESPACE diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro index b60de6e1e2af2d08a8d9cf8fd4d212a69200688a..ad79c1ef962a6951e776a5738d74c082b1369d82 100644 --- a/src/webenginewidgets/webenginewidgets.pro +++ b/src/webenginewidgets/webenginewidgets.pro @@ -52,11 +52,13 @@ contains(WEBENGINE_CONFIG, use_spellchecker) { DEFINES += ENABLE_SPELLCHECK } -contains(WEBENGINE_CONFIG, enable_pdf) { - DEFINES += ENABLE_PDF +use?(printing) { + DEFINES += ENABLE_PRINTING + QT += printsupport } -qtHaveModule(printsupport) { - QT += printsupport +use?(pdf) { + DEFINES += ENABLE_PDF } + load(qt_module) diff --git a/tests/auto/quick/qquickwebengineview/qquickwebengineview.pro b/tests/auto/quick/qquickwebengineview/qquickwebengineview.pro index 36e74a2a8a8df36d29ed63058a7c02e73a40cee8..df9b3e1b7eed61487cba7060e7a2ee064c754d45 100644 --- a/tests/auto/quick/qquickwebengineview/qquickwebengineview.pro +++ b/tests/auto/quick/qquickwebengineview/qquickwebengineview.pro @@ -4,3 +4,8 @@ exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc QT_PRIVATE += webengine-private gui-private HEADERS += ../shared/util.h + +use?(pdf) { + DEFINES += ENABLE_PDF +} + diff --git a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp index 236358e9c7d413e3c4f849065f68444ab67be36d..7f808a4e23c19aaeedc95f4e8b72b22adbee34b6 100644 --- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp +++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp @@ -499,6 +499,9 @@ void tst_QQuickWebEngineView::setZoomFactor() void tst_QQuickWebEngineView::printToPdf() { +#if !defined(ENABLE_PDF) + QSKIP("ENABLE_PDF"); +#else QTemporaryDir tempDir(QDir::tempPath() + "/tst_qwebengineview-XXXXXX"); QVERIFY(tempDir.isValid()); QQuickWebEngineView *view = webEngineView(); @@ -523,6 +526,7 @@ void tst_QQuickWebEngineView::printToPdf() QList<QVariant> failedArguments = savePdfSpy.takeFirst(); QVERIFY2(failedArguments.at(0).toString() == path, "File path for second saved PDF does not match arguments"); QVERIFY2(failedArguments.at(1).toBool() == false, "Printing to PDF file succeeded though it should fail"); +#endif // !defined(ENABLE_PDF) } void tst_QQuickWebEngineView::stopSettingFocusWhenDisabled() diff --git a/tests/auto/widgets/qwebenginepage/qwebenginepage.pro b/tests/auto/widgets/qwebenginepage/qwebenginepage.pro index df733c473984014b00a48763e40550e5553e9134..fef92c311108bbcc32da3d187e5133a047359fd8 100644 --- a/tests/auto/widgets/qwebenginepage/qwebenginepage.pro +++ b/tests/auto/widgets/qwebenginepage/qwebenginepage.pro @@ -1,4 +1,4 @@ include(../tests.pri) QT *= core-private gui-private -contains(WEBENGINE_CONFIG, enable_pdf): DEFINES+=QWEBENGINEPAGE_PDFPRINTINGENABLED +contains(WEBENGINE_CONFIG, use_pdf): DEFINES+=QWEBENGINEPAGE_PDFPRINTINGENABLED diff --git a/tools/qmake/mkspecs/features/configure.prf b/tools/qmake/mkspecs/features/configure.prf index bea1c5fdfb5b2e5f468a7e73d43e6fa6c0a7aa31..3cdcc400bff980da574fbd0e350502e5ea7552ba 100644 --- a/tools/qmake/mkspecs/features/configure.prf +++ b/tools/qmake/mkspecs/features/configure.prf @@ -23,6 +23,7 @@ defineTest(runConfigure) { isQtMinimum(5, 8) { include($$QTWEBENGINE_OUT_ROOT/qtwebengine-config.pri) QT_FOR_CONFIG += webengine-private + qtConfig(printing-and-pdf): WEBENGINE_CONFIG += use_printing use_pdf qtConfig(proprietary-codecs): WEBENGINE_CONFIG += use_proprietary_codecs qtConfig(spellchecker): WEBENGINE_CONFIG += use_spellchecker qtConfig(appstore-compliant): WEBENGINE_CONFIG += use_appstore_compliant_code @@ -86,9 +87,6 @@ defineTest(runConfigure) { else: log("System NSS not found, BoringSSL will be used.$${EOL}") } } - !cross_compile { - WEBENGINE_CONFIG += enable_pdf - } isEmpty(skipBuildReason): { cache(CONFIG, add, $$list(webengine_successfully_configured))