diff options
author | Christian StrΓΈmme <christian.stromme@qt.io> | 2024-11-22 12:58:15 +0100 |
---|---|---|
committer | Christian StrΓΈmme <christian.stromme@qt.io> | 2024-12-05 19:49:41 +0100 |
commit | b069ab8547ef9f77ad4351bb68ecf9991282b658 (patch) | |
tree | b58108aacb7026d835498bb3e5ccddb6b7e64a2e | |
parent | ac1a751e6f60748dc2a6bdf54569610fdc432efb (diff) |
macOS: Flip the switch and make the native back-end the default
In practice this have been the case for anyone not installing
QtWebEngine and the platform issue that we had, and that required
special initialization set-up, hasn't been an issue and that code has
been removed from 6.5 and newer
(see: 5f15afaaf07586006b1731cadcb061fa23c71aef). With this change we'll
use the native back-end by default on macOS.
[ChangeLog][macOS] macOS will now use the native WebView backend by
default, meaning QtWebEngine is no longer required on macOS.
Change-Id: Iebcefddf93432c5184d495d286bdead679e423de
Reviewed-by: Tor Arne VestbΓΈ <tor.arne.vestbo@qt.io>
-rw-r--r-- | src/plugins/darwin/darwin.json | 3 | ||||
-rw-r--r-- | src/plugins/darwin/qdarwinwebview.mm | 10 | ||||
-rw-r--r-- | src/webview/qwebviewfactory.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qml/qquickwebview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/auto/webview/qwebview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/auto/webview/qwebview/tst_qwebview.cpp | 6 |
6 files changed, 18 insertions, 9 deletions
diff --git a/src/plugins/darwin/darwin.json b/src/plugins/darwin/darwin.json index daa9d6f..9f65fd4 100644 --- a/src/plugins/darwin/darwin.json +++ b/src/plugins/darwin/darwin.json @@ -1,4 +1,3 @@ { - "Keys": ["native"], - "RequiresInit": true + "Keys": ["native"] } diff --git a/src/plugins/darwin/qdarwinwebview.mm b/src/plugins/darwin/qdarwinwebview.mm index 80b9916..d8950da 100644 --- a/src/plugins/darwin/qdarwinwebview.mm +++ b/src/plugins/darwin/qdarwinwebview.mm @@ -18,6 +18,7 @@ #include <WebKit/WebKit.h> #include <QtCore/qjsondocument.h> +#include <QtCore/qfile.h> #ifdef Q_OS_IOS #import <UIKit/UIKit.h> @@ -360,6 +361,13 @@ void QDarwinWebViewPrivate::setUrl(const QUrl &url) { if (url.isValid()) { if (url.isLocalFile()) { + // NOTE: Check if the file exists before attempting to load it, we follow the same + // asynchronous pattern as expected to not break the tests (Started + Failed). + if (!QFile::exists(url.toLocalFile())) { + QMetaObject::invokeMethod(this, &QDarwinWebViewPrivate::loadingChanged, Qt::QueuedConnection, QWebViewLoadRequestPrivate(url, QWebView::LoadStartedStatus, {})); + QMetaObject::invokeMethod(this, &QDarwinWebViewPrivate::loadingChanged, Qt::QueuedConnection, QWebViewLoadRequestPrivate(url, QWebView::LoadFailedStatus, QStringLiteral("File does not exist"))); + return; + } // We need to pass local files via loadFileURL and the read access should cover // the directory that the file is in, to facilitate loading referenced images etc if (m_settings->allowFileAccess()) { @@ -371,6 +379,8 @@ void QDarwinWebViewPrivate::setUrl(const QUrl &url) } else { [wkWebView loadRequest:[NSURLRequest requestWithURL:url.toNSURL()]]; } + } else { + QMetaObject::invokeMethod(this, &QDarwinWebViewPrivate::loadingChanged, Qt::QueuedConnection, QWebViewLoadRequestPrivate(url, QWebView::LoadFailedStatus, QStringLiteral("Invalid URL"))); } } diff --git a/src/webview/qwebviewfactory.cpp b/src/webview/qwebviewfactory.cpp index 657529f..ce00ce0 100644 --- a/src/webview/qwebviewfactory.cpp +++ b/src/webview/qwebviewfactory.cpp @@ -14,11 +14,7 @@ static QString getPluginName() { static const QString name = !qEnvironmentVariableIsEmpty("QT_WEBVIEW_PLUGIN") ? QString::fromLatin1(qgetenv("QT_WEBVIEW_PLUGIN")) -#ifdef Q_OS_MACOS - : QStringLiteral("webengine"); -#else : QStringLiteral("native"); -#endif // Q_OS_MACOS return name; } diff --git a/tests/auto/qml/qquickwebview/CMakeLists.txt b/tests/auto/qml/qquickwebview/CMakeLists.txt index c773185..6b4ace5 100644 --- a/tests/auto/qml/qquickwebview/CMakeLists.txt +++ b/tests/auto/qml/qquickwebview/CMakeLists.txt @@ -46,7 +46,7 @@ qt_internal_add_resource(tst_qquickwebview "testdata1" ${testdata1_resource_files} ) -qt_internal_extend_target(tst_qquickwebview CONDITION TARGET Qt::WebEngineQuick +qt_internal_extend_target(tst_qquickwebview CONDITION TARGET Qt::WebEngineQuick AND NOT APPLE DEFINES QT_WEBVIEW_WEBENGINE_BACKEND ) diff --git a/tests/auto/webview/qwebview/CMakeLists.txt b/tests/auto/webview/qwebview/CMakeLists.txt index 8ac5b00..253cee6 100644 --- a/tests/auto/webview/qwebview/CMakeLists.txt +++ b/tests/auto/webview/qwebview/CMakeLists.txt @@ -21,7 +21,7 @@ qt_internal_extend_target(tst_qwebview CONDITION TARGET Qt::WebViewQuick Qt::Qml ) -qt_internal_extend_target(tst_qwebview CONDITION TARGET Qt::WebEngineQuick +qt_internal_extend_target(tst_qwebview CONDITION TARGET Qt::WebEngineQuick AND NOT APPLE DEFINES QT_WEBVIEW_WEBENGINE_BACKEND LIBRARIES diff --git a/tests/auto/webview/qwebview/tst_qwebview.cpp b/tests/auto/webview/qwebview/tst_qwebview.cpp index fd942ec..5b447ca 100644 --- a/tests/auto/webview/qwebview/tst_qwebview.cpp +++ b/tests/auto/webview/qwebview/tst_qwebview.cpp @@ -143,10 +143,14 @@ void tst_QWebView::loadHtml() const QWebViewLoadRequestPrivate &lr = loadChangedSingalSpy.at(1).at(0).value<QWebViewLoadRequestPrivate>(); QCOMPARE(lr.m_status, QWebView::LoadSucceededStatus); +// The following test is disabled because the content is not loaded in the same way in the webview +// on darwin and url will be just the base url (which unless specified is about:blank) +#if ! (defined(QT_PLATFORM_UIKIT) || defined(Q_OS_MACOS)) QByteArray encoded("data:text/html;charset=UTF-8,"); encoded.append(content.toPercentEncoding()); QVERIFY(view.url().isValid()); - QCOMPARE(QUrl(encoded), view.url()); + QCOMPARE(view.url(), QUrl(encoded)); +#endif } void tst_QWebView::loadRequest() |