From 637beda0062ff65918823147830b52e29ae550a6 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 8 May 2017 14:44:17 +0200 Subject: Fix backwards compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QtWebEngine supports building with last stable and last LTS Qt releases. Guard some 5.7-5.9 API from being used when not available, and reinstate the default features for 5.6 LTS builds. Change-Id: Ia288a49109d011a2bee883d4a2d38d994b497d59 Reviewed-by: Michael BrĂ¼ning --- examples/webenginewidgets/spellchecker/webview.cpp | 2 +- mkspecs/features/configure.prf | 7 ++++++- src/core/delegated_frame_node.cpp | 9 +++++++++ src/core/web_contents_adapter.cpp | 2 ++ src/core/web_engine_context.cpp | 2 ++ src/webengine/ui_delegates_manager.cpp | 5 +++++ 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/examples/webenginewidgets/spellchecker/webview.cpp b/examples/webenginewidgets/spellchecker/webview.cpp index 0e52e7628..80158f7e5 100644 --- a/examples/webenginewidgets/spellchecker/webview.cpp +++ b/examples/webenginewidgets/spellchecker/webview.cpp @@ -69,7 +69,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) QMenu *menu = page()->createStandardContextMenu(); menu->addSeparator(); - QAction *spellcheckAction = new QAction(tr("Check Spelling")); + QAction *spellcheckAction = new QAction(tr("Check Spelling"), nullptr); spellcheckAction->setCheckable(true); spellcheckAction->setChecked(profile->isSpellCheckEnabled()); connect(spellcheckAction, &QAction::toggled, this, [profile](bool toogled) { diff --git a/mkspecs/features/configure.prf b/mkspecs/features/configure.prf index b293a5efa..f56f9a55e 100644 --- a/mkspecs/features/configure.prf +++ b/mkspecs/features/configure.prf @@ -39,7 +39,12 @@ defineTest(runConfigure) { qtConfig(system-icu): WEBENGINE_CONFIG += use_system_icu else: WEBENGINE_CONFIG += use_bundled_icu } else { - cross_compile: WEBENGINE_CONFIG += embedded_build reduce_binary_size + # Feature defaults when building with Qt 5.6 LTS: + cross_compile { + WEBENGINE_CONFIG += embedded_build reduce_binary_size + } else { + WEBENGINE_CONFIG += use_spellchecker use_webrtc use_pepper_plugins use_printing use_pdf + } } isQtMinimum(5, 9) { qtConfig(appstore-compliant): WEBENGINE_CONFIG += use_appstore_compliant_code diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp index a4b2a4036..e49bc553f 100644 --- a/src/core/delegated_frame_node.cpp +++ b/src/core/delegated_frame_node.cpp @@ -209,6 +209,7 @@ protected: QVector *m_sceneGraphNodes; }; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)) class DelegatedNodeTreeUpdater : public DelegatedNodeTreeHandler { public: @@ -303,6 +304,7 @@ public: private: QVector::iterator m_nodeIterator; }; +#endif class DelegatedNodeTreeCreator : public DelegatedNodeTreeHandler { @@ -872,8 +874,13 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, // We first compare if the render passes from the previous frame data are structurally // equivalent to the render passes in the current frame data. If they are, we are going // to reuse the old nodes. Otherwise, we will delete the old nodes and build a new tree. +#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)) cc::DelegatedFrameData *previousFrameData = m_chromiumCompositorData->previousFrameData.get(); const bool buildNewTree = !areRenderPassStructuresEqual(frameData, previousFrameData) || m_sceneGraphNodes.empty(); +#else + // No updates possible with old scenegraph nodes + const bool buildNewTree = true; +#endif m_chromiumCompositorData->previousFrameData = nullptr; SGObjects previousSGObjects; @@ -887,11 +894,13 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, delete oldChain; m_sceneGraphNodes.clear(); nodeHandler.reset(new DelegatedNodeTreeCreator(&m_sceneGraphNodes, apiDelegate)); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)) } else { // Save the texture strong refs so they only go out of scope when the method returns and // the new vector of texture strong refs has been filled. qSwap(m_sgObjects.textureStrongRefs, textureStrongRefs); nodeHandler.reset(new DelegatedNodeTreeUpdater(&m_sceneGraphNodes)); +#endif } // The RenderPasses list is actually a tree where a parent RenderPass is connected // to its dependencies through a RenderPassId reference in one or more RenderPassQuads. diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index d67d972c8..444429c75 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -1184,7 +1184,9 @@ void WebContentsAdapter::startDragging(QObject *dragSource, const content::DropD bool dValid = true; QMetaObject::Connection onDestroyed = QObject::connect(dragSource, &QObject::destroyed, [&dValid](){ dValid = false; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)) QDrag::cancel(); +#endif }); drag->setMimeData(mimeDataFromDropData(*d->currentDropData)); diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 7359eeea8..edd09f65d 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -158,8 +158,10 @@ bool usingQtQuick2DRenderer() } } +#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) if (device.isEmpty()) device = QQuickWindow::sceneGraphBackend(); +#endif if (device.isEmpty()) device = QString::fromLocal8Bit(qgetenv("QT_QUICK_BACKEND")); if (device.isEmpty()) diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp index 4a47a49eb..6cc496d5b 100644 --- a/src/webengine/ui_delegates_manager.cpp +++ b/src/webengine/ui_delegates_manager.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -559,7 +560,11 @@ void UIDelegatesManager::showToolTip(const QString &text) int width = QQmlProperty(m_toolTip.data(), QStringLiteral("width")).read().toInt(); QSize toolTipSize(width, height); QPoint position = m_view->cursor().pos(); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)) position = m_view->mapFromGlobal(calculateToolTipPosition(position, toolTipSize)).toPoint(); +#else + position = m_view->window()->mapFromGlobal(calculateToolTipPosition(position, toolTipSize)); +#endif QQmlProperty(m_toolTip.data(), QStringLiteral("x")).write(position.x()); QQmlProperty(m_toolTip.data(), QStringLiteral("y")).write(position.y()); -- cgit v1.2.3