diff options
| author | Michal Klocek <michal.klocek@qt.io> | 2025-11-20 10:54:00 +0100 |
|---|---|---|
| committer | Michal Klocek <michal.klocek@qt.io> | 2025-11-27 09:57:13 +0100 |
| commit | 95a53e2467029e917d6d421a357c13d51aaa44db (patch) | |
| tree | 6aafb348744ab0238eb0bcfbf8fc00057a01fd86 | |
| parent | ddb86461871086d3ea5f9b6d58838a2dca427a0c (diff) | |
Pass the pointer to QWebView for private counterpart
QAbstarctWebView is going to be base class of pimpl
for QWebView.
Change-Id: I58636bc5017092e1b9360d05109a305d49899043
Reviewed-by: Kaloyan Chehlarski <kaloyan.chehlarski@qt.io>
Reviewed-by: Moss Heim <moss.heim@qt.io>
| -rw-r--r-- | src/plugins/android/qandroidwebview.cpp | 9 | ||||
| -rw-r--r-- | src/plugins/android/qandroidwebview_p.h | 2 | ||||
| -rw-r--r-- | src/plugins/android/qandroidwebviewplugin.cpp | 4 | ||||
| -rw-r--r-- | src/plugins/darwin/qdarwinwebview.mm | 5 | ||||
| -rw-r--r-- | src/plugins/darwin/qdarwinwebview_p.h | 2 | ||||
| -rw-r--r-- | src/plugins/darwin/qdarwinwebviewplugin.cpp | 4 | ||||
| -rw-r--r-- | src/plugins/wasm/qwasmwebview.cpp | 2 | ||||
| -rw-r--r-- | src/plugins/wasm/qwasmwebview_p.h | 2 | ||||
| -rw-r--r-- | src/plugins/wasm/qwasmwebviewplugin.cpp | 4 | ||||
| -rw-r--r-- | src/plugins/webengine/qwebenginewebview.cpp | 2 | ||||
| -rw-r--r-- | src/plugins/webengine/qwebenginewebview_p.h | 2 | ||||
| -rw-r--r-- | src/plugins/webengine/qwebenginewebviewplugin.cpp | 4 | ||||
| -rw-r--r-- | src/plugins/windows/qwebview2webview.cpp | 4 | ||||
| -rw-r--r-- | src/plugins/windows/qwebview2webview_p.h | 2 | ||||
| -rw-r--r-- | src/plugins/windows/qwebview2webviewplugin.cpp | 4 | ||||
| -rw-r--r-- | src/webview/qabstractwebview_p.h | 3 | ||||
| -rw-r--r-- | src/webview/qwebview.cpp | 2 | ||||
| -rw-r--r-- | src/webview/qwebviewfactory.cpp | 4 | ||||
| -rw-r--r-- | src/webview/qwebviewfactory_p.h | 2 | ||||
| -rw-r--r-- | src/webview/qwebviewplugin_p.h | 2 |
20 files changed, 34 insertions, 31 deletions
diff --git a/src/plugins/android/qandroidwebview.cpp b/src/plugins/android/qandroidwebview.cpp index 4a61e5f..56e0b2a 100644 --- a/src/plugins/android/qandroidwebview.cpp +++ b/src/plugins/android/qandroidwebview.cpp @@ -76,9 +76,12 @@ void QAndroidWebViewSettingsPrivate::setAllowFileAccess(bool enabled) typedef QSet<QAndroidWebViewPrivate *> WebViews; Q_GLOBAL_STATIC(WebViews, g_webViews) -QAndroidWebViewPrivate::QAndroidWebViewPrivate(QObject *p) - : QAbstractWebView(p) , m_callbackId(0) , m_window(nullptr) - , m_viewController(nullptr) , m_webView(nullptr) +QAndroidWebViewPrivate::QAndroidWebViewPrivate(QWebView *view) + : QAbstractWebView(view), + m_callbackId(0), + m_window(nullptr), + m_viewController(nullptr), + m_webView(nullptr) { // QtAndroidWebViewController constructor blocks a qGuiThread until // the WebView is created and configured in UI thread. diff --git a/src/plugins/android/qandroidwebview_p.h b/src/plugins/android/qandroidwebview_p.h index d3d951c..4f12268 100644 --- a/src/plugins/android/qandroidwebview_p.h +++ b/src/plugins/android/qandroidwebview_p.h @@ -56,7 +56,7 @@ class QAndroidWebViewPrivate : public QAbstractWebView { Q_OBJECT public: - explicit QAndroidWebViewPrivate(QObject *p = nullptr); + explicit QAndroidWebViewPrivate(QWebView *view); ~QAndroidWebViewPrivate() override; QString httpUserAgent() const override; diff --git a/src/plugins/android/qandroidwebviewplugin.cpp b/src/plugins/android/qandroidwebviewplugin.cpp index cebd5bf..bceb553 100644 --- a/src/plugins/android/qandroidwebviewplugin.cpp +++ b/src/plugins/android/qandroidwebviewplugin.cpp @@ -13,9 +13,9 @@ class QAndroidWebViewPlugin : public QWebViewPlugin Q_PLUGIN_METADATA(IID QWebViewPluginInterface_iid FILE "android.json") public: - QAbstractWebView *create(const QString &key) const override + QAbstractWebView *create(const QString &key, QWebView *view) const override { - return (key == QLatin1String("webview")) ? new QAndroidWebViewPrivate() : nullptr; + return (key == QLatin1String("webview")) ? new QAndroidWebViewPrivate(view) : nullptr; } }; diff --git a/src/plugins/darwin/qdarwinwebview.mm b/src/plugins/darwin/qdarwinwebview.mm index 192b52e..099dced 100644 --- a/src/plugins/darwin/qdarwinwebview.mm +++ b/src/plugins/darwin/qdarwinwebview.mm @@ -257,9 +257,8 @@ void QDarwinWebViewSettingsPrivate::setAllowFileAccess(bool enabled) m_allowFileAccess = enabled; } -QDarwinWebViewPrivate::QDarwinWebViewPrivate(QObject *p) - : QAbstractWebView(p) - , wkWebView(nil) +QDarwinWebViewPrivate::QDarwinWebViewPrivate(QWebView *view) + : QAbstractWebView(view), wkWebView(nil) { CGRect frame = CGRectMake(0.0, 0.0, 400, 400); wkWebView = [[WKWebView alloc] initWithFrame:frame]; diff --git a/src/plugins/darwin/qdarwinwebview_p.h b/src/plugins/darwin/qdarwinwebview_p.h index 02c5c75..991a31c 100644 --- a/src/plugins/darwin/qdarwinwebview_p.h +++ b/src/plugins/darwin/qdarwinwebview_p.h @@ -57,7 +57,7 @@ class QDarwinWebViewPrivate : public QAbstractWebView { Q_OBJECT public: - explicit QDarwinWebViewPrivate(QObject *p = nullptr); + explicit QDarwinWebViewPrivate(QWebView *view); ~QDarwinWebViewPrivate() override; QString httpUserAgent() const override; diff --git a/src/plugins/darwin/qdarwinwebviewplugin.cpp b/src/plugins/darwin/qdarwinwebviewplugin.cpp index 49621ed..d80e723 100644 --- a/src/plugins/darwin/qdarwinwebviewplugin.cpp +++ b/src/plugins/darwin/qdarwinwebviewplugin.cpp @@ -14,9 +14,9 @@ class QDarwinWebViewPlugin : public QWebViewPlugin Q_PLUGIN_METADATA(IID QWebViewPluginInterface_iid FILE "darwin.json") public: - QAbstractWebView *create(const QString &key) const override + QAbstractWebView *create(const QString &key, QWebView *view) const override { - return (key == QLatin1String("webview")) ? new QDarwinWebViewPrivate() : nullptr; + return (key == QLatin1String("webview")) ? new QDarwinWebViewPrivate(view) : nullptr; } void prepare() const override diff --git a/src/plugins/wasm/qwasmwebview.cpp b/src/plugins/wasm/qwasmwebview.cpp index 10f8e32..011a19d 100644 --- a/src/plugins/wasm/qwasmwebview.cpp +++ b/src/plugins/wasm/qwasmwebview.cpp @@ -72,7 +72,7 @@ void QWasmWebViewSettingsPrivate::setAllowFileAccess(bool enabled) qWarning("setAllowFileAccess() not supported on this platform"); } -QWasmWebViewPrivate::QWasmWebViewPrivate(QObject *p) : QAbstractWebView(p), m_window(0) +QWasmWebViewPrivate::QWasmWebViewPrivate(QWebView *view) : QAbstractWebView(view), m_window(0) { m_settings = new QWasmWebViewSettingsPrivate(this); } diff --git a/src/plugins/wasm/qwasmwebview_p.h b/src/plugins/wasm/qwasmwebview_p.h index 39759d1..50fcc0e 100644 --- a/src/plugins/wasm/qwasmwebview_p.h +++ b/src/plugins/wasm/qwasmwebview_p.h @@ -52,7 +52,7 @@ class QWasmWebViewPrivate final : public QAbstractWebView { Q_OBJECT public: - explicit QWasmWebViewPrivate(QObject *p = nullptr); + explicit QWasmWebViewPrivate(QWebView *view); ~QWasmWebViewPrivate() override; QString httpUserAgent() const final; diff --git a/src/plugins/wasm/qwasmwebviewplugin.cpp b/src/plugins/wasm/qwasmwebviewplugin.cpp index 83c713f..50c9ca0 100644 --- a/src/plugins/wasm/qwasmwebviewplugin.cpp +++ b/src/plugins/wasm/qwasmwebviewplugin.cpp @@ -13,9 +13,9 @@ class QWasmWebViewPlugin : public QWebViewPlugin Q_PLUGIN_METADATA(IID QWebViewPluginInterface_iid FILE "wasm.json") public: - QAbstractWebView *create(const QString &key) const override + QAbstractWebView *create(const QString &key, QWebView *view) const override { - return key == QLatin1String("webview") ? new QWasmWebViewPrivate() : nullptr; + return key == QLatin1String("webview") ? new QWasmWebViewPrivate(view) : nullptr; } }; diff --git a/src/plugins/webengine/qwebenginewebview.cpp b/src/plugins/webengine/qwebenginewebview.cpp index 244fb3c..a3a72dd 100644 --- a/src/plugins/webengine/qwebenginewebview.cpp +++ b/src/plugins/webengine/qwebenginewebview.cpp @@ -35,7 +35,7 @@ static QByteArray qmlSource() "}\n"); } -QWebEngineWebViewPrivate::QWebEngineWebViewPrivate(QObject *p) +QWebEngineWebViewPrivate::QWebEngineWebViewPrivate(QWebView *p) : QAbstractWebView(p), m_profile(nullptr) { m_settings = new QWebEngineWebViewSettingsPrivate(this); diff --git a/src/plugins/webengine/qwebenginewebview_p.h b/src/plugins/webengine/qwebenginewebview_p.h index 47fdb89..ff07192 100644 --- a/src/plugins/webengine/qwebenginewebview_p.h +++ b/src/plugins/webengine/qwebenginewebview_p.h @@ -66,7 +66,7 @@ class QWebEngineWebViewPrivate : public QAbstractWebView { Q_OBJECT public: - explicit QWebEngineWebViewPrivate(QObject *p = nullptr); + explicit QWebEngineWebViewPrivate(QWebView *p); ~QWebEngineWebViewPrivate() override; QString httpUserAgent() const override; diff --git a/src/plugins/webengine/qwebenginewebviewplugin.cpp b/src/plugins/webengine/qwebenginewebviewplugin.cpp index e192951..556a934 100644 --- a/src/plugins/webengine/qwebenginewebviewplugin.cpp +++ b/src/plugins/webengine/qwebenginewebviewplugin.cpp @@ -13,9 +13,9 @@ class QWebEngineWebViewPlugin : public QWebViewPlugin Q_PLUGIN_METADATA(IID QWebViewPluginInterface_iid FILE "webengine.json") public: - QAbstractWebView *create(const QString &key) const override + QAbstractWebView *create(const QString &key, QWebView *view) const override { - return (key == QLatin1String("webview")) ? new QWebEngineWebViewPrivate() : nullptr; + return (key == QLatin1String("webview")) ? new QWebEngineWebViewPrivate(view) : nullptr; } void prepare() const override { } diff --git a/src/plugins/windows/qwebview2webview.cpp b/src/plugins/windows/qwebview2webview.cpp index 0741261..6e71267 100644 --- a/src/plugins/windows/qwebview2webview.cpp +++ b/src/plugins/windows/qwebview2webview.cpp @@ -105,8 +105,8 @@ void QWebview2WebViewSettingsPrivate::setAllowFileAccess(bool enabled) m_allowFileAccess = enabled; } -QWebView2WebViewPrivate::QWebView2WebViewPrivate(QObject *parent) - : QAbstractWebView(parent), +QWebView2WebViewPrivate::QWebView2WebViewPrivate(QWebView *view) + : QAbstractWebView(view), m_settings(new QWebview2WebViewSettingsPrivate(this)), m_window(new QWindow), m_isLoading(false) diff --git a/src/plugins/windows/qwebview2webview_p.h b/src/plugins/windows/qwebview2webview_p.h index 44abc7f..2aa07d4 100644 --- a/src/plugins/windows/qwebview2webview_p.h +++ b/src/plugins/windows/qwebview2webview_p.h @@ -62,7 +62,7 @@ class QWebView2WebViewPrivate : public QAbstractWebView { Q_OBJECT public: - explicit QWebView2WebViewPrivate(QObject *parent = nullptr); + explicit QWebView2WebViewPrivate(QWebView *view); ~QWebView2WebViewPrivate() override; QString httpUserAgent() const override; diff --git a/src/plugins/windows/qwebview2webviewplugin.cpp b/src/plugins/windows/qwebview2webviewplugin.cpp index c674df3..e8a0432 100644 --- a/src/plugins/windows/qwebview2webviewplugin.cpp +++ b/src/plugins/windows/qwebview2webviewplugin.cpp @@ -13,9 +13,9 @@ class QWebView2WebViewPlugin : public QWebViewPlugin Q_PLUGIN_METADATA(IID QWebViewPluginInterface_iid FILE "windows.json") public: - QAbstractWebView *create(const QString &key) const override + QAbstractWebView *create(const QString &key, QWebView *view) const override { - return (key == QLatin1String("webview")) ? new QWebView2WebViewPrivate() : nullptr; + return (key == QLatin1String("webview")) ? new QWebView2WebViewPrivate(view) : nullptr; } }; diff --git a/src/webview/qabstractwebview_p.h b/src/webview/qabstractwebview_p.h index 4a188db..8731f81 100644 --- a/src/webview/qabstractwebview_p.h +++ b/src/webview/qabstractwebview_p.h @@ -89,7 +89,8 @@ Q_SIGNALS: void nativeWindowChanged(QWindow *window); protected: - explicit QAbstractWebView(QObject *p = nullptr) : QObject(p) { } + explicit QAbstractWebView(QWebView *view) : q_ptr(view) { }; + QWebView *q_ptr; }; QT_END_NAMESPACE diff --git a/src/webview/qwebview.cpp b/src/webview/qwebview.cpp index 26d2d13..a73189f 100644 --- a/src/webview/qwebview.cpp +++ b/src/webview/qwebview.cpp @@ -12,7 +12,7 @@ QT_BEGIN_NAMESPACE QWebView::QWebView(QWindow *parent) : QWindow(parent), - d(QWebViewFactory::createWebView()), + d(QWebViewFactory::createWebView(this)), m_settings(new QWebViewSettings(d->settings())), m_progress(0) { diff --git a/src/webview/qwebviewfactory.cpp b/src/webview/qwebviewfactory.cpp index f4a2b15..05ec09e 100644 --- a/src/webview/qwebviewfactory.cpp +++ b/src/webview/qwebviewfactory.cpp @@ -19,12 +19,12 @@ static QString getPluginName() return name; } -QAbstractWebView *QWebViewFactory::createWebView() +QAbstractWebView *QWebViewFactory::createWebView(QWebView *view) { QAbstractWebView *wv = nullptr; QWebViewPlugin *plugin = getPlugin(); if (plugin) - wv = plugin->create(QStringLiteral("webview")); + wv = plugin->create(QStringLiteral("webview"), view); if (!wv || !plugin) { qFatal("No WebView plug-in found!"); diff --git a/src/webview/qwebviewfactory_p.h b/src/webview/qwebviewfactory_p.h index 48d9545..01f2610 100644 --- a/src/webview/qwebviewfactory_p.h +++ b/src/webview/qwebviewfactory_p.h @@ -25,7 +25,7 @@ class QWebViewPlugin; namespace QWebViewFactory { QWebViewPlugin *getPlugin(); - QAbstractWebView *createWebView(); + QAbstractWebView *createWebView(QWebView *view); bool requiresExtraInitializationSteps(); Q_WEBVIEW_EXPORT bool loadedPluginHasKey(const QString key); }; diff --git a/src/webview/qwebviewplugin_p.h b/src/webview/qwebviewplugin_p.h index 2f296fa..a98f810 100644 --- a/src/webview/qwebviewplugin_p.h +++ b/src/webview/qwebviewplugin_p.h @@ -32,7 +32,7 @@ public: explicit QWebViewPlugin(QObject *parent = nullptr); virtual ~QWebViewPlugin(); - virtual QAbstractWebView *create(const QString &key) const = 0; + virtual QAbstractWebView *create(const QString &key, QWebView *view) const = 0; virtual void prepare() const; }; |
