diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-06-09 11:58:41 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-06-10 08:21:36 +0000 |
commit | be4c684be7c2fa91f7df3d7cccfb6999aecfc967 (patch) | |
tree | d847a3d11e3c4769772b1d4bbb3ed9979866a293 | |
parent | 5d1ef38f9f6815807596d0606cf7ed06b7930aac (diff) | |
download | qtwebengine-be4c684be7c2fa91f7df3d7cccfb6999aecfc967.tar.gz |
Switch from QT_NO macros to feature checks
This is safer by ensuring we are checking for a feature that is defined.
For some reason, the openssl feature is a private feature, so we need
to include the private header to access it.
Pick-to: 6.4
Change-Id: Idf7f3baba33e5188f206f5be1b8a0bfd75e79d03
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
-rw-r--r-- | src/core/api/qwebenginepage.cpp | 12 | ||||
-rw-r--r-- | src/core/api/qwebenginepage.h | 8 | ||||
-rw-r--r-- | src/core/web_contents_delegate_qt.cpp | 2 | ||||
-rw-r--r-- | src/core/web_event_factory.cpp | 2 | ||||
-rw-r--r-- | src/core/web_event_factory.h | 14 | ||||
-rw-r--r-- | src/webenginequick/api/qquickwebengineview.cpp | 4 | ||||
-rw-r--r-- | src/webenginequick/api/qquickwebengineview_p.h | 4 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginenotificationpresenter.cpp | 6 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineview.cpp | 12 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebengineview.h | 2 | ||||
-rw-r--r-- | tests/auto/widgets/qwebenginepage/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 5 | ||||
-rw-r--r-- | tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp | 6 |
13 files changed, 40 insertions, 38 deletions
diff --git a/src/core/api/qwebenginepage.cpp b/src/core/api/qwebenginepage.cpp index a893d5a80..8a49e6577 100644 --- a/src/core/api/qwebenginepage.cpp +++ b/src/core/api/qwebenginepage.cpp @@ -559,7 +559,7 @@ QObject *QWebEnginePagePrivate::accessibilityParentObject() void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const { -#ifdef QT_NO_ACTION +#if !QT_CONFIG(action) Q_UNUSED(action); #else QAction *a = actions[action]; @@ -602,7 +602,7 @@ void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const } a->setEnabled(enabled); -#endif // QT_NO_ACTION +#endif // QT_CONFIG(action) } void QWebEnginePagePrivate::updateNavigationActions() @@ -627,7 +627,7 @@ void QWebEnginePagePrivate::updateEditActions() updateAction(QWebEnginePage::Unselect); } -#ifndef QT_NO_ACTION +#if QT_CONFIG(action) void QWebEnginePagePrivate::_q_webActionTriggered(bool checked) { Q_Q(QWebEnginePage); @@ -637,7 +637,7 @@ void QWebEnginePagePrivate::_q_webActionTriggered(bool checked) QWebEnginePage::WebAction action = static_cast<QWebEnginePage::WebAction>(a->data().toInt()); q->triggerAction(action, checked); } -#endif // QT_NO_ACTION +#endif // QT_CONFIG(action) void QWebEnginePagePrivate::recreateFromSerializedHistory(QDataStream &input) { @@ -1057,7 +1057,7 @@ QString QWebEnginePage::selectedText() const return d->adapter->selectedText(); } -#ifndef QT_NO_ACTION +#if QT_CONFIG(action) QAction *QWebEnginePage::action(WebAction action) const { Q_D(const QWebEnginePage); @@ -1219,7 +1219,7 @@ QAction *QWebEnginePage::action(WebAction action) const d->updateAction(action); return a; } -#endif // QT_NO_ACTION +#endif // QT_CONFIG(action) void QWebEnginePage::triggerAction(WebAction action, bool) { diff --git a/src/core/api/qwebenginepage.h b/src/core/api/qwebenginepage.h index 68fee0f84..3a9d2a611 100644 --- a/src/core/api/qwebenginepage.h +++ b/src/core/api/qwebenginepage.h @@ -251,7 +251,7 @@ public: QWebEngineProfile *profile() const; -#ifndef QT_NO_ACTION +#if QT_CONFIG(action) QAction *action(WebAction action) const; #endif virtual void triggerAction(WebAction action, bool checked = false); @@ -398,16 +398,16 @@ private: Q_DISABLE_COPY(QWebEnginePage) Q_DECLARE_PRIVATE(QWebEnginePage) QScopedPointer<QWebEnginePagePrivate> d_ptr; -#ifndef QT_NO_ACTION +#if QT_CONFIG(action) Q_PRIVATE_SLOT(d_func(), void _q_webActionTriggered(bool checked)) #endif friend class QContextMenuBuilder; friend class QWebEngineView; friend class QWebEngineViewPrivate; -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) friend class QWebEngineViewAccessible; -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) }; Q_DECLARE_OPERATORS_FOR_FLAGS(QWebEnginePage::FindFlags) diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index bbd15a35d..f1002652c 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -726,7 +726,7 @@ void WebContentsDelegateQt::launchExternalURL(const QUrl &url, ui::PageTransitio if (navigationAllowedByPolicy) { m_viewClient->navigationRequested(pageTransitionToNavigationType(page_transition), url, navigationRequestAccepted, is_main_frame); -#ifndef QT_NO_DESKTOPSERVICES +#if QT_CONFIG(desktopservices) if (navigationRequestAccepted) QDesktopServices::openUrl(url); #endif diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp index d7dceb30c..ee8be5f61 100644 --- a/src/core/web_event_factory.cpp +++ b/src/core/web_event_factory.cpp @@ -1516,7 +1516,7 @@ WebMouseEvent WebEventFactory::toWebMouseEvent(QEvent *ev) return webKitEvent; } -#ifndef QT_NO_GESTURES +#if QT_CONFIG(gestures) WebGestureEvent WebEventFactory::toWebGestureEvent(QNativeGestureEvent *ev) { WebGestureEvent webKitEvent; diff --git a/src/core/web_event_factory.h b/src/core/web_event_factory.h index df2f26694..9e0d89b3e 100644 --- a/src/core/web_event_factory.h +++ b/src/core/web_event_factory.h @@ -40,25 +40,25 @@ #ifndef WEB_EVENT_FACTORY_H #define WEB_EVENT_FACTORY_H +#include "QtGui/qtguiglobal.h" + #include "content/public/browser/native_web_keyboard_event.h" -#ifndef QT_NO_GESTURES +#if QT_CONFIG(gestures) #include "third_party/blink/public/common/input/web_gesture_event.h" #endif #include "third_party/blink/public/common/input/web_mouse_event.h" #include "third_party/blink/public/common/input/web_mouse_wheel_event.h" -#include <QtGlobal> - QT_BEGIN_NAMESPACE class QEvent; class QHoverEvent; class QKeyEvent; class QMouseEvent; -#ifndef QT_NO_TABLETEVENT +#if QT_CONFIG(tabletevent) class QTabletEvent; #endif class QWheelEvent; -#ifndef QT_NO_GESTURES +#if QT_CONFIG(gestures) class QNativeGestureEvent; #endif QT_END_NAMESPACE @@ -72,11 +72,11 @@ class WebEventFactory { public: static blink::WebMouseEvent toWebMouseEvent(QMouseEvent *); static blink::WebMouseEvent toWebMouseEvent(QHoverEvent *); -#ifndef QT_NO_TABLETEVENT +#if QT_CONFIG(tabletevent) static blink::WebMouseEvent toWebMouseEvent(QTabletEvent *); #endif static blink::WebMouseEvent toWebMouseEvent(QEvent *); -#ifndef QT_NO_GESTURES +#if QT_CONFIG(gestures) static blink::WebGestureEvent toWebGestureEvent(QNativeGestureEvent *); #endif static blink::WebMouseWheelEvent toWebWheelEvent(QWheelEvent *); diff --git a/src/webenginequick/api/qquickwebengineview.cpp b/src/webenginequick/api/qquickwebengineview.cpp index 24c059d39..babd0ade7 100644 --- a/src/webenginequick/api/qquickwebengineview.cpp +++ b/src/webenginequick/api/qquickwebengineview.cpp @@ -2197,14 +2197,14 @@ void QQuickWebEngineView::componentComplete() QQuickItem::componentComplete(); Q_D(QQuickWebEngineView); d->initializeProfile(); -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) // Enable accessibility via a dynamic QQmlProperty, instead of using private API call // QQuickAccessibleAttached::qmlAttachedProperties(this). The qmlContext is required, otherwise // it is not possible to reference attached properties. QQmlContext *qmlContext = QQmlEngine::contextForObject(this); QQmlProperty role(this, QStringLiteral("Accessible.role"), qmlContext); role.write(QAccessible::Grouping); -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) QTimer::singleShot(0, this, &QQuickWebEngineView::lazyInitialize); } diff --git a/src/webenginequick/api/qquickwebengineview_p.h b/src/webenginequick/api/qquickwebengineview_p.h index 46b92b9c6..e025c896d 100644 --- a/src/webenginequick/api/qquickwebengineview_p.h +++ b/src/webenginequick/api/qquickwebengineview_p.h @@ -588,9 +588,9 @@ private: friend class QQuickContextMenuBuilder; friend class FaviconImageResponse; friend class FaviconImageResponseRunnable; -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) friend class QQuickWebEngineViewAccessible; -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) }; QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebenginenotificationpresenter.cpp b/src/webenginewidgets/api/qwebenginenotificationpresenter.cpp index 9a2ba7dee..6a4a74ea8 100644 --- a/src/webenginewidgets/api/qwebenginenotificationpresenter.cpp +++ b/src/webenginewidgets/api/qwebenginenotificationpresenter.cpp @@ -46,7 +46,7 @@ QT_BEGIN_NAMESPACE DefaultNotificationPresenter::DefaultNotificationPresenter(QObject *parent) : QObject(parent) { -#ifndef QT_NO_SYSTEMTRAYICON +#if QT_CONFIG(systemtrayicon) m_systemTrayIcon = new QSystemTrayIcon(this); connect(m_systemTrayIcon, &QSystemTrayIcon::messageClicked, this, &DefaultNotificationPresenter::messageClicked); #endif @@ -66,7 +66,7 @@ void DefaultNotificationPresenter::show(std::unique_ptr<QWebEngineNotification> m_activeNotification = std::move(notification); -#ifndef QT_NO_SYSTEMTRAYICON +#if QT_CONFIG(systemtrayicon) if (m_activeNotification && m_systemTrayIcon) { m_systemTrayIcon->setIcon(qApp->windowIcon()); m_systemTrayIcon->show(); @@ -90,7 +90,7 @@ void DefaultNotificationPresenter::messageClicked() void DefaultNotificationPresenter::closeNotification() { -#ifndef QT_NO_SYSTEMTRAYICON +#if QT_CONFIG(systemtrayicon) const QWebEngineNotification *canceled = static_cast<const QWebEngineNotification *>(QObject::sender()); if (m_systemTrayIcon && canceled->matches(m_activeNotification.get())) m_systemTrayIcon->hide(); diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp index b3bba7d9e..cf8af53e3 100644 --- a/src/webenginewidgets/api/qwebengineview.cpp +++ b/src/webenginewidgets/api/qwebengineview.cpp @@ -305,7 +305,7 @@ bool WebEngineQuickWidget::event(QEvent *event) case QEvent::ContextMenu: case QEvent::KeyPress: case QEvent::KeyRelease: -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) case QEvent::Wheel: #endif return false; @@ -629,14 +629,14 @@ bool QWebEngineViewPrivate::passOnFocus(bool reverse) return q->focusNextPrevChild(!reverse); } -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *object) { if (QWebEngineView *v = qobject_cast<QWebEngineView*>(object)) return new QWebEngineViewAccessible(v); return nullptr; } -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) QWebEngineViewPrivate::QWebEngineViewPrivate() : page(0) @@ -644,9 +644,9 @@ QWebEngineViewPrivate::QWebEngineViewPrivate() , m_ownsPage(false) , m_contextRequest(nullptr) { -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessible::installFactory(&webAccessibleFactory); -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) } QWebEngineViewPrivate::~QWebEngineViewPrivate() = default; @@ -1085,7 +1085,7 @@ QString QWebEngineView::selectedText() const return page()->selectedText(); } -#ifndef QT_NO_ACTION +#if QT_CONFIG(action) QAction* QWebEngineView::pageAction(QWebEnginePage::WebAction action) const { return page()->action(action); diff --git a/src/webenginewidgets/api/qwebengineview.h b/src/webenginewidgets/api/qwebengineview.h index 658b73da1..cc1495d24 100644 --- a/src/webenginewidgets/api/qwebengineview.h +++ b/src/webenginewidgets/api/qwebengineview.h @@ -98,7 +98,7 @@ public: bool hasSelection() const; QString selectedText() const; -#ifndef QT_NO_ACTION +#if QT_CONFIG(action) QAction *pageAction(QWebEnginePage::WebAction action) const; #endif void triggerPageAction(QWebEnginePage::WebAction action, bool checked = false); diff --git a/tests/auto/widgets/qwebenginepage/CMakeLists.txt b/tests/auto/widgets/qwebenginepage/CMakeLists.txt index bb31d9a97..599e22990 100644 --- a/tests/auto/widgets/qwebenginepage/CMakeLists.txt +++ b/tests/auto/widgets/qwebenginepage/CMakeLists.txt @@ -5,6 +5,7 @@ qt_internal_add_test(tst_qwebenginepage SOURCES tst_qwebenginepage.cpp LIBRARIES + Qt::NetworkPrivate Qt::WebEngineWidgets Test::HttpServer Test::Util diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index 63d39dd59..b8c0dd5f0 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -47,6 +47,7 @@ #include <qnetworkcookiejar.h> #include <qnetworkreply.h> #include <qnetworkrequest.h> +#include <QtNetwork/private/qtnetwork-config_p.h> #include <qwebenginedownloadrequest.h> #include <qwebenginefilesystemaccessrequest.h> #include <qwebenginefindtextresult.h> @@ -2151,7 +2152,7 @@ public: setAttribute(QNetworkRequest::RedirectionTargetAttribute, QUrl("qrc:/test2.html")); QTimer::singleShot(0, this, SLOT(continueRedirect())); } -#ifndef QT_NO_OPENSSL +#if QT_CONFIG(openssl) else if (request.url() == QUrl("qrc:/fake-ssl-error.html")) { setError(QNetworkReply::SslHandshakeFailedError, tr("Fake error!")); QTimer::singleShot(0, this, SLOT(continueError())); @@ -2208,7 +2209,7 @@ protected: { QString url = request.url().toString(); if (op == QNetworkAccessManager::GetOperation) { -#ifndef QT_NO_OPENSSL +#if QT_CONFIG(openssl) if (url == "qrc:/fake-ssl-error.html") { FakeReply* reply = new FakeReply(request, this); QList<QSslError> errors; diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index 883720490..40c99c6e0 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -152,7 +152,7 @@ private Q_SLOTS: void mouseLeave(); -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void globalMouseSelection(); #endif void noContextMenu(); @@ -927,7 +927,7 @@ public: case QEvent::ContextMenu: case QEvent::KeyPress: case QEvent::KeyRelease: -#ifndef QT_NO_WHEELEVENT +#if QT_CONFIG(wheelevent) case QEvent::Wheel: #endif ++m_eventCounter; @@ -2967,7 +2967,7 @@ void tst_QWebEngineView::imeCompositionQueryEvent() QTRY_COMPARE(anchorPosQuery.value(Qt::ImAnchorPosition).toInt(), 11); } -#ifndef QT_NO_CLIPBOARD +#if QT_CONFIG(clipboard) void tst_QWebEngineView::globalMouseSelection() { if (!QApplication::clipboard()->supportsSelection()) { |