From 94bb5644907c16b742d05a6f51cc82785b945f4a Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@qt.io>
Date: Tue, 23 Oct 2018 11:36:58 +0200
Subject: [PATCH] Remove some outdated Qt version checks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

We can't not build with older than Qt 5.9 anyway due to QSG and qmake
changes.

Change-Id: Iff0247e70d9ffc1e045e2c571f0089d68df9a589
Reviewed-by: Michael Brüning <michael.bruning@qt.io>
---
 src/core/net/proxy_config_service_qt.cpp |  7 ----
 src/core/render_widget_host_view_qt.cpp  | 50 ------------------------
 src/core/web_contents_adapter.cpp        |  4 --
 src/core/web_engine_context.cpp          |  2 -
 src/core/web_event_factory.cpp           |  4 --
 src/webengine/ui_delegates_manager.cpp   |  5 ---
 6 files changed, 72 deletions(-)

diff --git a/src/core/net/proxy_config_service_qt.cpp b/src/core/net/proxy_config_service_qt.cpp
index c5316d54e..13b969281 100644
--- a/src/core/net/proxy_config_service_qt.cpp
+++ b/src/core/net/proxy_config_service_qt.cpp
@@ -93,9 +93,7 @@ void ProxyConfigServiceQt::RemoveObserver(net::ProxyConfigService::Observer *obs
 
 net::ProxyConfigService::ConfigAvailability ProxyConfigServiceQt::GetLatestProxyConfig(net::ProxyConfigWithAnnotation *config)
 {
-#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
     m_usesSystemConfiguration = QNetworkProxyFactory::usesSystemConfiguration();
-#endif
     if (m_usesSystemConfiguration) {
         // Use Chromium's base service to retrieve system settings
         net::ProxyConfigWithAnnotation systemConfig;
@@ -149,7 +147,6 @@ void ProxyConfigServiceQt::OnLazyPoll()
 {
     DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
 
-#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)
     // We need to update if
     // - setUseSystemConfiguration() was called in between
     // - user changed application proxy
@@ -160,10 +157,6 @@ void ProxyConfigServiceQt::OnLazyPoll()
         if (m_baseService.get())
             m_baseService->OnLazyPoll();
     }
-#else
-    if (m_qtApplicationProxy != QNetworkProxy::applicationProxy())
-        Update();
-#endif
 }
 
 // Called when the base service changed
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 86d5d7118..6c5b2ac20 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -90,9 +90,7 @@
 #include <QVariant>
 #include <QWheelEvent>
 #include <QWindow>
-#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
 #include <QtGui/private/qinputcontrol_p.h>
-#endif
 #include <QtGui/qaccessible.h>
 
 namespace QtWebEngineCore {
@@ -178,55 +176,7 @@ static inline bool compareTouchPoints(const QTouchEvent::TouchPoint &lhs, const
 
 static inline bool isCommonTextEditShortcut(const QKeyEvent *ke)
 {
-#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
     return QInputControl::isCommonTextEditShortcut(ke);
-#else
-    if (ke->modifiers() == Qt::NoModifier
-        || ke->modifiers() == Qt::ShiftModifier
-        || ke->modifiers() == Qt::KeypadModifier) {
-        if (ke->key() < Qt::Key_Escape) {
-            return true;
-        } else {
-            switch (ke->key()) {
-                case Qt::Key_Return:
-                case Qt::Key_Enter:
-                case Qt::Key_Delete:
-                case Qt::Key_Home:
-                case Qt::Key_End:
-                case Qt::Key_Backspace:
-                case Qt::Key_Left:
-                case Qt::Key_Right:
-                case Qt::Key_Up:
-                case Qt::Key_Down:
-                case Qt::Key_Tab:
-                return true;
-            default:
-                break;
-            }
-        }
-    } else if (ke->matches(QKeySequence::Copy)
-               || ke->matches(QKeySequence::Paste)
-               || ke->matches(QKeySequence::Cut)
-               || ke->matches(QKeySequence::Redo)
-               || ke->matches(QKeySequence::Undo)
-               || ke->matches(QKeySequence::MoveToNextWord)
-               || ke->matches(QKeySequence::MoveToPreviousWord)
-               || ke->matches(QKeySequence::MoveToStartOfDocument)
-               || ke->matches(QKeySequence::MoveToEndOfDocument)
-               || ke->matches(QKeySequence::SelectNextWord)
-               || ke->matches(QKeySequence::SelectPreviousWord)
-               || ke->matches(QKeySequence::SelectStartOfLine)
-               || ke->matches(QKeySequence::SelectEndOfLine)
-               || ke->matches(QKeySequence::SelectStartOfBlock)
-               || ke->matches(QKeySequence::SelectEndOfBlock)
-               || ke->matches(QKeySequence::SelectStartOfDocument)
-               || ke->matches(QKeySequence::SelectEndOfDocument)
-               || ke->matches(QKeySequence::SelectAll)
-              ) {
-        return true;
-    }
-    return false;
-#endif
 }
 
 static uint32_t s_eventId = 0;
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 762d9f53a..5b9e61268 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -1431,11 +1431,7 @@ bool WebContentsAdapter::handleDropDataFileContents(const content::DropData &dro
 
     const auto maybeFilename = dropData.GetSafeFilenameForImageFileContents();
     const QString fileName = maybeFilename ? toQt(maybeFilename->AsUTF16Unsafe()) : QString();
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))
     const QString &filePath = m_dndTmpDir->filePath(fileName);
-#else
-    const QString &filePath = m_dndTmpDir->path() + QLatin1Char('/') + fileName;
-#endif
     QFile file(filePath);
     if (!file.open(QIODevice::WriteOnly)) {
         qWarning("Cannot write temporary file %s.", qUtf8Printable(filePath));
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index b7cf1344b..fefccae0e 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -142,10 +142,8 @@ 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/core/web_event_factory.cpp b/src/core/web_event_factory.cpp
index 17c1c75a0..04d4930ec 100644
--- a/src/core/web_event_factory.cpp
+++ b/src/core/web_event_factory.cpp
@@ -1413,11 +1413,7 @@ static void setBlinkWheelEventDelta(blink::WebMouseWheelEvent &webEvent)
     // a pixel delta based on ticks and scroll per line.
     static const float cDefaultQtScrollStep = 20.f;
 
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))
     static const int wheelScrollLines = QGuiApplication::styleHints()->wheelScrollLines();
-#else
-    static const int wheelScrollLines = 3;
-#endif
     webEvent.delta_x = webEvent.wheel_ticks_x * wheelScrollLines * cDefaultQtScrollStep;
     webEvent.delta_y = webEvent.wheel_ticks_y * wheelScrollLines * cDefaultQtScrollStep;
 }
diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp
index 252bdc9b6..7e49bc77d 100644
--- a/src/webengine/ui_delegates_manager.cpp
+++ b/src/webengine/ui_delegates_manager.cpp
@@ -508,12 +508,7 @@ public:
         if (pos.isNull() || !item->contains(pos))
             return;
         const QPoint oldPos = QCursor::pos();
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 7, 0))
         const QPoint globalPos = item->mapToGlobal(QPointF(pos)).toPoint();
-#else
-        const QPoint posInWindow = item->mapToItem(item->window()->contentItem(), QPointF(pos)).toPoint();
-        const QPoint globalPos = item->window()->mapToGlobal(posInWindow);
-#endif
         if (oldPos == globalPos)
             return;
         m_oldCursorPos = oldPos;
-- 
GitLab