summaryrefslogtreecommitdiffstats
path: root/src/webenginewidgets
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-05-14 10:49:00 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-05-15 17:26:19 +0200
commitbc6df3888128e3a0e0d4e2f8a69970ac36d8abe7 (patch)
tree2cb49ad5fffa0f2011b3d98faa363f105135901e /src/webenginewidgets
parent10e66c6dd0b8a8dd17252d6408c13b689fac6995 (diff)
parent585da6f74012bd09e8a873080e368cff99c97cbf (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: src/pdf/quick/qquickpdfselection_p.h Change-Id: I6eec37a01347c2d47cbfc1114326dfc6b58719ff
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r--src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp6
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp39
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h8
-rw-r--r--src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc7
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp9
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h1
6 files changed, 34 insertions, 36 deletions
diff --git a/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp b/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp
index a39c0e483..5949f3d6e 100644
--- a/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp
+++ b/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp
@@ -49,13 +49,13 @@ namespace QtWebEngineCore
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
#endif
static void initialize()
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (QCoreApplication::instance()) {
//On window/ANGLE, calling QtWebEngine::initialize from DllMain will result in a crash.
if (!qt_gl_global_share_context()) {
@@ -67,7 +67,7 @@ static void initialize()
}
//QCoreApplication is not yet instantiated, ensuring the call will be deferred
qAddPreRoutine(QtWebEngineCore::initialize);
-#endif // QT_NO_OPENGL
+#endif // QT_CONFIG(opengl)
}
Q_CONSTRUCTOR_FUNCTION(initialize)
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index b267c5dd1..dc06e48be 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -348,7 +348,10 @@ void QWebEnginePagePrivate::unhandledKeyEvent(QKeyEvent *event)
QGuiApplication::sendEvent(view->parentWidget(), event);
}
-void QWebEnginePagePrivate::adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry, const QUrl &targetUrl)
+QSharedPointer<WebContentsAdapter>
+QWebEnginePagePrivate::adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents,
+ WindowOpenDisposition disposition, bool userGesture,
+ const QRect &initialGeometry, const QUrl &targetUrl)
{
Q_Q(QWebEnginePage);
Q_UNUSED(userGesture);
@@ -356,27 +359,11 @@ void QWebEnginePagePrivate::adoptNewWindow(QSharedPointer<WebContentsAdapter> ne
QWebEnginePage *newPage = q->createWindow(toWindowType(disposition));
if (!newPage)
- return;
+ return nullptr;
- if (newPage->d_func() == this) {
- // If createWindow returns /this/ we must delay the adoption.
- Q_ASSERT(q == newPage);
- // WebContents might be null if we just opened a new page for navigation, in that case
- // avoid referencing newWebContents so that it is deleted and WebContentsDelegateQt::OpenURLFromTab
- // will fall back to navigating current page.
- if (newWebContents->webContents()) {
- QTimer::singleShot(0, q, [this, newPage, newWebContents, initialGeometry] () {
- adoptNewWindowImpl(newPage, newWebContents, initialGeometry);
- });
- }
- } else {
- adoptNewWindowImpl(newPage, newWebContents, initialGeometry);
- }
-}
+ if (!newWebContents->webContents())
+ return newPage->d_func()->adapter; // Reuse existing adapter
-void QWebEnginePagePrivate::adoptNewWindowImpl(QWebEnginePage *newPage,
- const QSharedPointer<WebContentsAdapter> &newWebContents, const QRect &initialGeometry)
-{
// Mark the new page as being in the process of being adopted, so that a second mouse move event
// sent by newWebContents->initialize() gets filtered in RenderWidgetHostViewQt::forwardEvent.
// The first mouse move event is being sent by q->createWindow(). This is necessary because
@@ -394,6 +381,8 @@ void QWebEnginePagePrivate::adoptNewWindowImpl(QWebEnginePage *newPage,
if (!initialGeometry.isEmpty())
emit newPage->geometryChangeRequested(initialGeometry);
+
+ return newWebContents;
}
bool QWebEnginePagePrivate::isBeingAdopted()
@@ -1147,9 +1136,11 @@ bool QWebEnginePage::isAudioMuted() const {
void QWebEnginePage::setAudioMuted(bool muted) {
Q_D(QWebEnginePage);
+ bool wasAudioMuted = isAudioMuted();
d->defaultAudioMuted = muted;
- if (d->adapter->isInitialized())
- d->adapter->setAudioMuted(muted);
+ d->adapter->setAudioMuted(muted);
+ if (wasAudioMuted != isAudioMuted())
+ Q_EMIT audioMutedChanged(muted);
}
/*!
@@ -1971,7 +1962,7 @@ void QWebEnginePage::setFeaturePermission(const QUrl &securityOrigin, QWebEngine
d->adapter->runFeatureRequestCallback(securityOrigin, ProfileAdapter::GeolocationPermission, true);
break;
case MouseLock:
- d->adapter->grantMouseLockPermission(true);
+ d->adapter->grantMouseLockPermission(securityOrigin, true);
break;
case Notifications:
d->adapter->runFeatureRequestCallback(securityOrigin, ProfileAdapter::NotificationPermission, true);
@@ -1990,7 +1981,7 @@ void QWebEnginePage::setFeaturePermission(const QUrl &securityOrigin, QWebEngine
d->adapter->runFeatureRequestCallback(securityOrigin, ProfileAdapter::GeolocationPermission, false);
break;
case MouseLock:
- d->adapter->grantMouseLockPermission(false);
+ d->adapter->grantMouseLockPermission(securityOrigin, false);
break;
case Notifications:
d->adapter->runFeatureRequestCallback(securityOrigin, ProfileAdapter::NotificationPermission, false);
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index f37413b8e..b4424ec4b 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -112,10 +112,10 @@ public:
void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) override;
void focusContainer() override;
void unhandledKeyEvent(QKeyEvent *event) override;
- void adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry, const QUrl &targetUrl) override;
- void adoptNewWindowImpl(QWebEnginePage *newPage,
- const QSharedPointer<QtWebEngineCore::WebContentsAdapter> &newWebContents,
- const QRect &initialGeometry);
+ QSharedPointer<QtWebEngineCore::WebContentsAdapter>
+ adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents,
+ WindowOpenDisposition disposition, bool userGesture,
+ const QRect &initialGeometry, const QUrl &targetUrl) override;
bool isBeingAdopted() override;
void close() override;
void windowCloseRejected() override;
diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
index 7701b9b3d..9d5c41713 100644
--- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
@@ -805,9 +805,10 @@
Sets the permission for the web site identified by \a securityOrigin to use \a feature to \a policy.
- \note Call this method on the featurePermissionRequested() signal, as it is
- meant to serve pending feature requests only. Setting feature permissions
- ahead of a request has no effect.
+ \note This method is primarily for calling after a featurePermissionRequested() signal has been emitted
+ to trigger the feature permission response. It can also be called before a request has been emitted,
+ but will only set a granted permission for passive checks, mainly for Notification APIs that can check
+ if permission has already been granted before explicitly requesting it.
\sa featurePermissionRequested(), featurePermissionRequestCanceled()
*/
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
index 2c7cc83d1..08c471763 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -106,7 +106,7 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QOpenGLContext *globalSharedContext = QOpenGLContext::globalShareContext();
if (globalSharedContext) {
QSurfaceFormat sharedFormat = globalSharedContext->format();
@@ -473,11 +473,16 @@ bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
if (!handled)
return QQuickWidget::event(event);
- // Most events are accepted by default, but tablet events are not:
event->accept();
return true;
}
+void RenderWidgetHostViewQtDelegateWidget::unhandledWheelEvent(QWheelEvent *ev)
+{
+ if (QWidget *p = parentWidget())
+ qApp->sendEvent(p, ev);
+}
+
void RenderWidgetHostViewQtDelegateWidget::onWindowPosChanged()
{
m_client->visualPropertiesChanged();
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
index c7783117a..034fdd65c 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
@@ -91,6 +91,7 @@ public:
void setInputMethodHints(Qt::InputMethodHints) override;
void setClearColor(const QColor &color) override;
bool copySurface(const QRect &, const QSize &, QImage &) override;
+ void unhandledWheelEvent(QWheelEvent *ev) override;
protected:
bool event(QEvent *event) override;