summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKirill Burtsev <kirill.burtsev@qt.io>2020-05-29 13:54:47 +0200
committerKirill Burtsev <kirill.burtsev@qt.io>2020-09-15 16:03:21 +0200
commitd784eb0e15fc6b4ab08db447377b79d10d123dc6 (patch)
treec01577be362718a1edc282b13170e1190758acd7 /src
parent17cab42bf68ee70f641718a144f864eb04042aa4 (diff)
Move QWebEngineFullScreenRequest to core
Task-number: QTBUG-74585 Change-Id: I953f46d01c1e4a82ab0d75b5f955e4f346f1c941 Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/core/api/core_api.pro2
-rw-r--r--src/core/api/qwebenginefullscreenrequest.cpp (renamed from src/webenginewidgets/api/qwebenginefullscreenrequest.cpp)71
-rw-r--r--src/core/api/qwebenginefullscreenrequest.h (renamed from src/webenginewidgets/api/qwebenginefullscreenrequest.h)32
-rw-r--r--src/webengine/api/qquickwebengineview.cpp28
-rw-r--r--src/webengine/api/qquickwebengineview_p.h23
-rw-r--r--src/webengine/doc/src/fullscreen_request.qdoc2
-rw-r--r--src/webengine/plugin/plugin.cpp3
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp4
-rw-r--r--src/webenginewidgets/webenginewidgets.pro2
9 files changed, 74 insertions, 93 deletions
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro
index e1a716955..29738520d 100644
--- a/src/core/api/core_api.pro
+++ b/src/core/api/core_api.pro
@@ -40,6 +40,7 @@ HEADERS = \
qwebenginecookiestore.h \
qwebenginecookiestore_p.h \
qwebenginefindtextresult.h \
+ qwebenginefullscreenrequest.h \
qwebenginehttprequest.h \
qwebenginemessagepumpscheduler_p.h \
qwebenginenotification.h \
@@ -63,6 +64,7 @@ SOURCES = \
qwebengineclientcertificatestore.cpp \
qwebenginecookiestore.cpp \
qwebenginefindtextresult.cpp \
+ qwebenginefullscreenrequest.cpp \
qwebenginehttprequest.cpp \
qwebenginemessagepumpscheduler.cpp \
qwebenginenotification.cpp \
diff --git a/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp b/src/core/api/qwebenginefullscreenrequest.cpp
index bcf2d5d22..facc8910d 100644
--- a/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp
+++ b/src/core/api/qwebenginefullscreenrequest.cpp
@@ -38,7 +38,6 @@
****************************************************************************/
#include "qwebenginefullscreenrequest.h"
-#include "qwebenginepage_p.h"
QT_BEGIN_NAMESPACE
@@ -49,7 +48,7 @@ QT_BEGIN_NAMESPACE
\since 5.6
- \inmodule QtWebEngineWidgets
+ \inmodule QtWebEngineCore
To allow elements such as videos to be shown in the fullscreen mode,
applications must set QWebEngineSettings::FullScreenSupportEnabled and
@@ -85,39 +84,37 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn QWebEngineFullScreenRequest::toggleOn() const
- Returns \c true if the web page has issued a request to enter the fullscreen
- mode, otherwise returns \c false.
-*/
-
-/*!
- \fn QWebEngineFullScreenRequest::origin() const
- Returns the URL to be opened in the fullscreen mode.
-*/
-
-/*!
Creates a request for opening the \a page from the URL specified by
\a origin in the fullscreen mode if \a fullscreen is \c true.
*/
-QWebEngineFullScreenRequest::QWebEngineFullScreenRequest(QWebEnginePage *page, const QUrl &origin, bool fullscreen)
- : m_page(page)
- , m_origin(origin)
- , m_toggleOn(fullscreen)
-{
-}
+class QWebEngineFullScreenRequestPrivate : public QSharedData {
+public:
+ QWebEngineFullScreenRequestPrivate(const QUrl &origin, bool toggleOn, const std::function<void (bool)> &setFullScreenCallback)
+ : m_origin(origin)
+ , m_toggleOn(toggleOn)
+ , m_setFullScreenCallback(setFullScreenCallback) { }
+
+ const QUrl m_origin;
+ const bool m_toggleOn;
+ const std::function<void (bool)> m_setFullScreenCallback;
+};
+
+QWebEngineFullScreenRequest::QWebEngineFullScreenRequest(const QUrl &origin, bool toggleOn, const std::function<void (bool)> &setFullScreenCallback)
+ : d_ptr(new QWebEngineFullScreenRequestPrivate(origin, toggleOn, setFullScreenCallback)) { }
+
+QWebEngineFullScreenRequest::QWebEngineFullScreenRequest(const QWebEngineFullScreenRequest &other) = default;
+QWebEngineFullScreenRequest& QWebEngineFullScreenRequest::operator=(const QWebEngineFullScreenRequest &other) = default;
+QWebEngineFullScreenRequest::QWebEngineFullScreenRequest(QWebEngineFullScreenRequest &&other) = default;
+QWebEngineFullScreenRequest& QWebEngineFullScreenRequest::operator=(QWebEngineFullScreenRequest &&other) = default;
+QWebEngineFullScreenRequest::~QWebEngineFullScreenRequest() = default;
/*!
Rejects a request to enter or exit the fullscreen mode.
*/
void QWebEngineFullScreenRequest::reject()
{
- if (!m_page) {
- qWarning("Cannot reject QWebEngineFullScreenRequest: Originating page is already deleted");
- return;
- }
-
- m_page->d_func()->setFullScreenMode(!m_toggleOn);
+ d_ptr->m_setFullScreenCallback(!d_ptr->m_toggleOn);
}
/*!
@@ -125,12 +122,26 @@ void QWebEngineFullScreenRequest::reject()
*/
void QWebEngineFullScreenRequest::accept()
{
- if (!m_page) {
- qWarning("Cannot accept QWebEngineFullScreenRequest: Originating page is already deleted");
- return;
- }
+ d_ptr->m_setFullScreenCallback(d_ptr->m_toggleOn);
+}
- m_page->d_func()->setFullScreenMode(m_toggleOn);
+/*!
+ \fn QWebEngineFullScreenRequest::toggleOn() const
+ Returns \c true if the web page has issued a request to enter the fullscreen
+ mode, otherwise returns \c false.
+*/
+bool QWebEngineFullScreenRequest::toggleOn() const
+{
+ return d_ptr->m_toggleOn;
+}
+
+/*!
+ \fn QWebEngineFullScreenRequest::origin() const
+ Returns the URL to be opened in the fullscreen mode.
+*/
+QUrl QWebEngineFullScreenRequest::origin() const
+{
+ return d_ptr->m_origin;
}
QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginefullscreenrequest.h b/src/core/api/qwebenginefullscreenrequest.h
index 08505a410..95911ed0a 100644
--- a/src/webenginewidgets/api/qwebenginefullscreenrequest.h
+++ b/src/core/api/qwebenginefullscreenrequest.h
@@ -40,29 +40,41 @@
#ifndef QWEBENGINEFULLSCREENREQUEST_H
#define QWEBENGINEFULLSCREENREQUEST_H
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
+#include <QtWebEngineCore/qtwebenginecoreglobal.h>
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qshareddata.h>
#include <QtCore/qurl.h>
-#include <QtCore/qpointer.h>
+
+#include <functional>
QT_BEGIN_NAMESPACE
-class QWebEnginePage;
-class QWEBENGINEWIDGETS_EXPORT QWebEngineFullScreenRequest {
+class QWebEngineFullScreenRequestPrivate;
+
+class Q_WEBENGINECORE_EXPORT QWebEngineFullScreenRequest
+{
Q_GADGET
Q_PROPERTY(bool toggleOn READ toggleOn CONSTANT)
Q_PROPERTY(QUrl origin READ origin CONSTANT)
+
public:
+ QWebEngineFullScreenRequest(const QWebEngineFullScreenRequest &other);
+ QWebEngineFullScreenRequest &operator=(const QWebEngineFullScreenRequest &other);
+ QWebEngineFullScreenRequest(QWebEngineFullScreenRequest &&other);
+ QWebEngineFullScreenRequest &operator=(QWebEngineFullScreenRequest &&other);
+ ~QWebEngineFullScreenRequest();
+
Q_INVOKABLE void reject();
Q_INVOKABLE void accept();
- bool toggleOn() const { return m_toggleOn; }
- const QUrl &origin() const { return m_origin; }
+ bool toggleOn() const;
+ QUrl origin() const;
private:
- QWebEngineFullScreenRequest(QWebEnginePage *page, const QUrl &origin, bool toggleOn);
- QPointer<QWebEnginePage> m_page;
- const QUrl m_origin;
- const bool m_toggleOn;
friend class QWebEnginePagePrivate;
+ friend class QQuickWebEngineViewPrivate;
+ QWebEngineFullScreenRequest(const QUrl &origin, bool toggleOn, const std::function<void (bool)> &setFullScreenCallback);
+ QExplicitlySharedDataPointer<QWebEngineFullScreenRequestPrivate> d_ptr;
};
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 72089a5c4..8086b7d1d 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -61,6 +61,7 @@
#include "qquickwebenginetouchhandleprovider_p_p.h"
#include "qwebenginecertificateerror.h"
#include "qwebenginefindtextresult.h"
+#include "qwebenginefullscreenrequest.h"
#include "qwebenginequotarequest.h"
#include "qwebengineregisterprotocolhandlerrequest.h"
@@ -617,7 +618,7 @@ void QQuickWebEngineViewPrivate::windowCloseRejected()
void QQuickWebEngineViewPrivate::requestFullScreenMode(const QUrl &origin, bool fullscreen)
{
Q_Q(QQuickWebEngineView);
- QQuickWebEngineFullScreenRequest request(this, origin, fullscreen);
+ QWebEngineFullScreenRequest request(origin, fullscreen, [q = QPointer(q)] (bool toggleOn) { if (q) q->d_ptr->setFullScreenMode(toggleOn); });
Q_EMIT q->fullScreenRequested(request);
}
@@ -2286,31 +2287,6 @@ QQuickWebEngineView::LifecycleState QQuickWebEngineView::recommendedState() cons
return static_cast<LifecycleState>(d->adapter->recommendedState());
}
-QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest()
- : m_viewPrivate(0)
- , m_toggleOn(false)
-{
-}
-
-QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, const QUrl &origin, bool toggleOn)
- : m_viewPrivate(viewPrivate)
- , m_origin(origin)
- , m_toggleOn(toggleOn)
-{
-}
-
-void QQuickWebEngineFullScreenRequest::accept()
-{
- if (m_viewPrivate)
- m_viewPrivate->setFullScreenMode(m_toggleOn);
-}
-
-void QQuickWebEngineFullScreenRequest::reject()
-{
- if (m_viewPrivate)
- m_viewPrivate->setFullScreenMode(!m_toggleOn);
-}
-
QQuickContextMenuBuilder::QQuickContextMenuBuilder(QWebEngineContextMenuRequest *request,
QQuickWebEngineView *view, QObject *menu)
: QtWebEngineCore::RenderViewContextMenuQt(request), m_view(view), m_menu(menu)
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index e169d0490..68c40616d 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -84,6 +84,7 @@ class QQuickWebEngineFormValidationMessageRequest;
class QQuickWebEngineViewPrivate;
class QWebEngineCertificateError;
class QWebEngineFindTextResult;
+class QWebEngineFullScreenRequest;
class QWebEngineQuotaRequest;
class QWebEngineRegisterProtocolHandlerRequest;
class QWebEngineContextMenuRequest;
@@ -92,25 +93,6 @@ class QWebEngineContextMenuRequest;
class QQuickWebEngineTestSupport;
#endif
-class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineFullScreenRequest {
- Q_GADGET
- Q_PROPERTY(QUrl origin READ origin CONSTANT FINAL)
- Q_PROPERTY(bool toggleOn READ toggleOn CONSTANT FINAL)
-public:
- QQuickWebEngineFullScreenRequest();
- QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, const QUrl &origin, bool toggleOn);
-
- Q_INVOKABLE void accept();
- Q_INVOKABLE void reject();
- QUrl origin() const { return m_origin; }
- bool toggleOn() const { return m_toggleOn; }
-
-private:
- QQuickWebEngineViewPrivate *m_viewPrivate;
- const QUrl m_origin;
- const bool m_toggleOn;
-};
-
#define LATEST_WEBENGINEVIEW_REVISION 10
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
@@ -553,7 +535,7 @@ Q_SIGNALS:
void navigationRequested(QQuickWebEngineNavigationRequest *request);
void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID);
Q_REVISION(1) void certificateError(const QWebEngineCertificateError &error);
- Q_REVISION(1) void fullScreenRequested(const QQuickWebEngineFullScreenRequest &request);
+ Q_REVISION(1) void fullScreenRequested(const QWebEngineFullScreenRequest &request);
Q_REVISION(1) void isFullScreenChanged();
Q_REVISION(1) void featurePermissionRequested(const QUrl &securityOrigin, Feature feature);
Q_REVISION(1) void newViewRequested(QQuickWebEngineNewViewRequest *request);
@@ -619,6 +601,5 @@ private:
QT_END_NAMESPACE
QML_DECLARE_TYPE(QQuickWebEngineView)
-Q_DECLARE_METATYPE(QQuickWebEngineFullScreenRequest)
#endif // QQUICKWEBENGINEVIEW_P_H
diff --git a/src/webengine/doc/src/fullscreen_request.qdoc b/src/webengine/doc/src/fullscreen_request.qdoc
index 230d62e50..ec7d93ba6 100644
--- a/src/webengine/doc/src/fullscreen_request.qdoc
+++ b/src/webengine/doc/src/fullscreen_request.qdoc
@@ -27,7 +27,7 @@
/*!
\qmltype FullScreenRequest
- \instantiates QQuickWebEngineFullScreenRequest
+ \instantiates QWebEngineFullScreenRequest
\inqmlmodule QtWebEngine
\since QtWebEngine 1.1
diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp
index 2dad9fefc..72ff597eb 100644
--- a/src/webengine/plugin/plugin.cpp
+++ b/src/webengine/plugin/plugin.cpp
@@ -54,6 +54,7 @@
#include <QtWebEngine/private/qquickwebengineaction_p.h>
#include <QtWebEngineCore/qwebenginecertificateerror.h>
#include <QtWebEngineCore/qwebenginefindtextresult.h>
+#include <QtWebEngineCore/qwebenginefullscreenrequest.h>
#include <QtWebEngineCore/qwebenginenotification.h>
#include <QtWebEngineCore/qwebenginequotarequest.h>
#include <QtWebEngineCore/qwebengineregisterprotocolhandlerrequest.h>
@@ -126,7 +127,7 @@ public:
qmlRegisterUncreatableType<QQuickWebEngineHistory, 1>(uri, 1, 11, "NavigationHistory", msgUncreatableType("NavigationHistory"));
qmlRegisterUncreatableType<QQuickWebEngineHistoryListModel>(uri, 1, 1, "NavigationHistoryListModel",
msgUncreatableType("NavigationHistory"));
- qmlRegisterUncreatableType<QQuickWebEngineFullScreenRequest>(uri, 1, 1, "FullScreenRequest",
+ qmlRegisterUncreatableType<QWebEngineFullScreenRequest>(uri, 1, 1, "FullScreenRequest",
msgUncreatableType("FullScreenRequest"));
qmlRegisterUncreatableType<QWebEngineContextMenuRequest, 1>(
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index f177f8d23..46f3d610f 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -1677,8 +1677,8 @@ void QWebEnginePagePrivate::navigationRequested(int navigationType, const QUrl &
void QWebEnginePagePrivate::requestFullScreenMode(const QUrl &origin, bool fullscreen)
{
Q_Q(QWebEnginePage);
- QWebEngineFullScreenRequest request(q, origin, fullscreen);
- Q_EMIT q->fullScreenRequested(request);
+ QWebEngineFullScreenRequest request(origin, fullscreen, [q = QPointer(q)] (bool toggleOn) { if (q) q->d_ptr->setFullScreenMode(toggleOn); });
+ Q_EMIT q->fullScreenRequested(std::move(request));
}
bool QWebEnginePagePrivate::isFullScreenMode() const
diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro
index 23f51f922..4112a2cb5 100644
--- a/src/webenginewidgets/webenginewidgets.pro
+++ b/src/webenginewidgets/webenginewidgets.pro
@@ -14,7 +14,6 @@ INCLUDEPATH += $$PWD api ../core ../core/api ../webengine/api
SOURCES = \
api/qtwebenginewidgetsglobal.cpp \
api/qwebengineclientcertificateselection.cpp \
- api/qwebenginefullscreenrequest.cpp \
api/qwebenginehistory.cpp \
api/qwebenginenotificationpresenter.cpp \
api/qwebenginepage.cpp \
@@ -27,7 +26,6 @@ SOURCES = \
HEADERS = \
api/qtwebenginewidgetsglobal.h \
api/qwebengineclientcertificateselection.h \
- api/qwebenginefullscreenrequest.h \
api/qwebenginehistory.h \
api/qwebenginenotificationpresenter_p.h \
api/qwebenginepage.h \