diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-09-07 16:06:06 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@theqtcompany.com> | 2015-10-19 08:38:01 +0000 |
commit | 0e9555838c83ccf5a6a28ee99d6fd556ebf5b3b2 (patch) | |
tree | 3b1709a0e5cfb6ba76f7d532fbd2dfac85393068 /src/webenginewidgets | |
parent | 38a426f21c0d6e47bdc05e5541b79c48cf967a0c (diff) |
Fix ABI breakage due to fullscreen feature
We can not add a new virtual method without breaking ABI on some
platforms, instead we need to use a setter.
The API now uses a request object, and a separate signal for canceling,
since canceling can not be rejected.
Change-Id: If8069c343e86926293c30e8de179bf4e3cbd5886
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r-- | src/webenginewidgets/api/qwebenginefullscreenrequest.cpp | 59 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginefullscreenrequest.h | 68 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.cpp | 47 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.h | 11 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage_p.h | 8 | ||||
-rw-r--r-- | src/webenginewidgets/webenginewidgets.pro | 2 |
6 files changed, 166 insertions, 29 deletions
diff --git a/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp b/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp new file mode 100644 index 000000000..6223c070d --- /dev/null +++ b/src/webenginewidgets/api/qwebenginefullscreenrequest.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwebenginefullscreenrequest.h" +#include "qwebenginepage_p.h" + +QT_BEGIN_NAMESPACE + +QWebEngineFullScreenRequest::QWebEngineFullScreenRequest(QWebEnginePagePrivate *pagePrivate, const QUrl &origin, bool fullscreen) + : m_pagePrivate(pagePrivate) + , m_origin(origin) + , m_toggleOn(fullscreen) +{ +} + +void QWebEngineFullScreenRequest::reject() const +{ + m_pagePrivate->setFullScreenMode(!m_toggleOn); +} + +void QWebEngineFullScreenRequest::accept() const +{ + m_pagePrivate->setFullScreenMode(m_toggleOn); +} + +QT_END_NAMESPACE diff --git a/src/webenginewidgets/api/qwebenginefullscreenrequest.h b/src/webenginewidgets/api/qwebenginefullscreenrequest.h new file mode 100644 index 000000000..c6768f4d6 --- /dev/null +++ b/src/webenginewidgets/api/qwebenginefullscreenrequest.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWEBENGINEFULLSCREENREQUEST_H +#define QWEBENGINEFULLSCREENREQUEST_H + +#include <qtwebenginewidgetsglobal.h> +#include <qwebenginepage.h> +#include <QtCore/qurl.h> + +QT_BEGIN_NAMESPACE +class QWebEnginePagePrivate; + +class QWEBENGINEWIDGETS_EXPORT QWebEngineFullScreenRequest { + Q_GADGET + Q_PROPERTY(bool toggleOn READ toggleOn) + Q_PROPERTY(QUrl origin READ origin) +public: + Q_INVOKABLE void reject() const; + Q_INVOKABLE void accept() const; + bool toggleOn() const { return m_toggleOn; } + const QUrl &origin() const { return m_origin; } + +private: + Q_DISABLE_COPY(QWebEngineFullScreenRequest) + QWebEngineFullScreenRequest(QWebEnginePagePrivate *pagePrivate, const QUrl &origin, bool toggleOn); + QWebEnginePagePrivate *m_pagePrivate; + const QUrl m_origin; + const bool m_toggleOn; + friend class QWebEnginePagePrivate; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index bb0917918..93e229db8 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -28,6 +28,7 @@ #include "certificate_error_controller.h" #include "file_picker_controller.h" #include "javascript_dialog_controller.h" +#include "qwebenginefullscreenrequest.h" #include "qwebenginehistory.h" #include "qwebenginehistory_p.h" #include "qwebengineprofile.h" @@ -89,7 +90,7 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile) , isLoading(false) , scriptCollection(new QWebEngineScriptCollectionPrivate(browserContextAdapter()->userScriptController(), adapter.data())) , m_backgroundColor(Qt::white) - , m_fullscreenRequested(false) + , fullscreenMode(false) { memset(actions, 0, sizeof(actions)); } @@ -372,6 +373,14 @@ void QWebEnginePagePrivate::recreateFromSerializedHistory(QDataStream &input) } } +void QWebEnginePagePrivate::setFullScreenMode(bool fullscreen) +{ + if (fullscreenMode != fullscreen) { + fullscreenMode = fullscreen; + adapter->changedFullScreen(); + } +} + BrowserContextAdapter *QWebEnginePagePrivate::browserContextAdapter() { return profile->d_ptr->browserContext(); @@ -410,13 +419,18 @@ QWebEnginePage::QWebEnginePage(QObject* parent) */ /*! - \fn QWebEnginePage::fullScreenRequested(bool fullScreen) + \fn QWebEnginePage::fullScreenRequested(const QWebEngineFullScreenRequest &request) + + This signal is emitted when the web page issues the request to enter fullscreen mode for + a web-element, usually a video element. + + The request object \a request can be used to accept or reject the request. - This signal is emitted when the web page issues the request to enter or exit fullscreen mode. - If \a fullScreen is \c true, the page wants to enter the mode and if it is \c false, the page - wants to exit the mode. + If the request is accepted the element requesting fullscreen will fill the viewport, + but it is up to the application to make the view fullscreen or move the page to a view + that is fullscreen. - \sa isFullScreen(), QWebEngineSettings::FullScreenSupportEnabled + \sa QWebEngineSettings::FullScreenSupportEnabled */ /*! @@ -885,16 +899,16 @@ void QWebEnginePagePrivate::navigationRequested(int navigationType, const QUrl & navigationRequestAction = accepted ? WebContentsAdapterClient::AcceptRequest : WebContentsAdapterClient::IgnoreRequest; } -void QWebEnginePagePrivate::requestFullScreen(bool fullScreen) +void QWebEnginePagePrivate::requestFullScreenMode(const QUrl &origin, bool fullscreen) { Q_Q(QWebEnginePage); - m_fullscreenRequested = fullScreen; - Q_EMIT q->fullScreenRequested(fullScreen); + QWebEngineFullScreenRequest request(this, origin, fullscreen); + Q_EMIT q->fullScreenRequested(request); } -bool QWebEnginePagePrivate::isFullScreen() const +bool QWebEnginePagePrivate::isFullScreenMode() const { - return m_fullscreenRequested && q_ptr->isFullScreen(); + return fullscreenMode; } void QWebEnginePagePrivate::javascriptDialog(QSharedPointer<JavaScriptDialogController> controller) @@ -1041,7 +1055,7 @@ QMenu *QWebEnginePage::createStandardContextMenu() if (d->adapter->hasInspector()) menu->addAction(QWebEnginePage::action(InspectElement)); - if (d->isFullScreen()) + if (d->isFullScreenMode()) menu->addAction(QWebEnginePage::action(ExitFullScreen)); return menu; @@ -1295,15 +1309,6 @@ bool QWebEnginePage::acceptNavigationRequest(const QUrl &url, NavigationType typ return true; } -/*! - Returns \c true if the web view is in fullscreen mode, \c false otherwise. -*/ -bool QWebEnginePage::isFullScreen() -{ - Q_D(const QWebEnginePage); - return d->view ? d->view->isFullScreen() : false; -} - QT_END_NAMESPACE #include "moc_qwebenginepage.cpp" diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h index 4b5e6456d..07b27deee 100644 --- a/src/webenginewidgets/api/qwebenginepage.h +++ b/src/webenginewidgets/api/qwebenginepage.h @@ -37,9 +37,9 @@ #ifndef QWEBENGINEPAGE_H #define QWEBENGINEPAGE_H -#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h> -#include <QtWebEngineWidgets/qwebenginecertificateerror.h> -#include <QtWebEngineCore/qwebenginecallback.h> +#include <qtwebenginewidgetsglobal.h> +#include <qwebenginecertificateerror.h> +#include <qwebenginecallback.h> #include <QtCore/qobject.h> #include <QtCore/qurl.h> @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE class QMenu; class QWebChannel; +class QWebEngineFullScreenRequest; class QWebEngineHistory; class QWebEnginePage; class QWebEnginePagePrivate; @@ -246,12 +247,12 @@ Q_SIGNALS: void linkHovered(const QString &url); void selectionChanged(); - void fullScreenRequested(bool fullScreen); void geometryChangeRequested(const QRect& geom); void windowCloseRequested(); void featurePermissionRequested(const QUrl &securityOrigin, QWebEnginePage::Feature feature); void featurePermissionRequestCanceled(const QUrl &securityOrigin, QWebEnginePage::Feature feature); + void fullScreenRequested(const QWebEngineFullScreenRequest &fullScreenRequest); void authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator); void proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost); @@ -273,7 +274,7 @@ protected: virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID); virtual bool certificateError(const QWebEngineCertificateError &certificateError); virtual bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame); - virtual bool isFullScreen(); + private: Q_DISABLE_COPY(QWebEnginePage) Q_DECLARE_PRIVATE(QWebEnginePage) diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index f5c01ce1b..8009336ec 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -98,8 +98,8 @@ public: virtual void windowCloseRejected() Q_DECL_OVERRIDE; virtual bool contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &data) Q_DECL_OVERRIDE; virtual void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) Q_DECL_OVERRIDE; - virtual void requestFullScreen(bool) Q_DECL_OVERRIDE; - virtual bool isFullScreen() const Q_DECL_OVERRIDE; + virtual void requestFullScreenMode(const QUrl &origin, bool fullscreen) Q_DECL_OVERRIDE; + virtual bool isFullScreenMode() const Q_DECL_OVERRIDE; virtual void javascriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>) Q_DECL_OVERRIDE; virtual void runFileChooser(QtWebEngineCore::FilePickerController *controller) Q_DECL_OVERRIDE; virtual void didRunJavaScript(quint64 requestId, const QVariant& result) Q_DECL_OVERRIDE; @@ -132,6 +132,8 @@ public: QtWebEngineCore::WebContentsAdapter *webContents() { return adapter.data(); } void recreateFromSerializedHistory(QDataStream &input); + void setFullScreenMode(bool); + QExplicitlySharedDataPointer<QtWebEngineCore::WebContentsAdapter> adapter; QWebEngineHistory *history; QWebEngineProfile *profile; @@ -142,7 +144,7 @@ public: bool isLoading; QWebEngineScriptCollection scriptCollection; QColor m_backgroundColor; - bool m_fullscreenRequested; + bool fullscreenMode; mutable QtWebEngineCore::CallbackDirectory m_callbacks; mutable QAction *actions[QWebEnginePage::WebActionCount]; diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro index 17a0a3dbb..4622d0028 100644 --- a/src/webenginewidgets/webenginewidgets.pro +++ b/src/webenginewidgets/webenginewidgets.pro @@ -12,6 +12,7 @@ SOURCES = \ api/qtwebenginewidgetsglobal.cpp \ api/qwebenginecertificateerror.cpp \ api/qwebenginedownloaditem.cpp \ + api/qwebenginefullscreenrequest.cpp \ api/qwebenginehistory.cpp \ api/qwebenginepage.cpp \ api/qwebengineprofile.cpp \ @@ -26,6 +27,7 @@ HEADERS = \ api/qwebenginedownloaditem.h \ api/qwebenginedownloaditem_p.h \ api/qwebenginecertificateerror.h \ + api/qwebenginefullscreenrequest.h \ api/qwebenginehistory.h \ api/qwebenginepage.h \ api/qwebenginepage_p.h \ |