summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@theqtcompany.com>2015-09-07 16:06:06 +0200
committerKai Koehne <kai.koehne@theqtcompany.com>2015-10-19 08:38:01 +0000
commit0e9555838c83ccf5a6a28ee99d6fd556ebf5b3b2 (patch)
tree3b1709a0e5cfb6ba76f7d532fbd2dfac85393068
parent38a426f21c0d6e47bdc05e5541b79c48cf967a0c (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>
-rw-r--r--examples/webenginewidgets/demobrowser/tabwidget.cpp19
-rw-r--r--examples/webenginewidgets/demobrowser/tabwidget.h2
m---------src/3rdparty0
-rw-r--r--src/core/web_contents_adapter.cpp6
-rw-r--r--src/core/web_contents_adapter.h1
-rw-r--r--src/core/web_contents_adapter_client.h4
-rw-r--r--src/core/web_contents_delegate_qt.cpp17
-rw-r--r--src/webengine/api/qquickwebengineview.cpp19
-rw-r--r--src/webengine/api/qquickwebengineview_p.h10
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h4
-rw-r--r--src/webenginewidgets/api/qwebenginefullscreenrequest.cpp59
-rw-r--r--src/webenginewidgets/api/qwebenginefullscreenrequest.h68
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp47
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h11
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h8
-rw-r--r--src/webenginewidgets/webenginewidgets.pro2
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp25
17 files changed, 222 insertions, 80 deletions
diff --git a/examples/webenginewidgets/demobrowser/tabwidget.cpp b/examples/webenginewidgets/demobrowser/tabwidget.cpp
index 9e08426f1..4e2073b11 100644
--- a/examples/webenginewidgets/demobrowser/tabwidget.cpp
+++ b/examples/webenginewidgets/demobrowser/tabwidget.cpp
@@ -48,10 +48,11 @@
#include "urllineedit.h"
#include "webview.h"
+#include <QWebEngineDownloadItem>
+#include <QWebEngineProfile>
+#include <QWebEngineFullScreenRequest>
#include <QtCore/QMimeData>
#include <QtGui/QClipboard>
-#include <QtWebEngineWidgets/QWebEngineDownloadItem>
-#include <QtWebEngineWidgets/QWebEngineProfile>
#include <QtWidgets/QCompleter>
#include <QtWidgets/QListView>
#include <QtWidgets/QMenu>
@@ -321,8 +322,8 @@ void TabWidget::currentChanged(int index)
this, SIGNAL(loadProgress(int)));
disconnect(oldWebView->page()->profile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)),
this, SLOT(downloadRequested(QWebEngineDownloadItem*)));
- disconnect(oldWebView->page(), SIGNAL(fullScreenRequested(bool)),
- this, SLOT(fullScreenRequested(bool)));
+ disconnect(oldWebView->page(), SIGNAL(fullScreenRequested(const QWebEngineFullScreenRequest&)),
+ this, SLOT(fullScreenRequested(const QWebEngineFullScreenRequest&)));
}
#if defined(QWEBENGINEVIEW_STATUSBARMESSAGE)
@@ -335,8 +336,8 @@ void TabWidget::currentChanged(int index)
this, SIGNAL(loadProgress(int)));
connect(webView->page()->profile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)),
this, SLOT(downloadRequested(QWebEngineDownloadItem*)));
- connect(webView->page(), SIGNAL(fullScreenRequested(bool)),
- this, SLOT(fullScreenRequested(bool)));
+ connect(webView->page(), SIGNAL(fullScreenRequested(const QWebEngineFullScreenRequest&)),
+ this, SLOT(fullScreenRequested(const QWebEngineFullScreenRequest&)));
for (int i = 0; i < m_actions.count(); ++i) {
WebActionMapper *mapper = m_actions[i];
@@ -352,13 +353,14 @@ void TabWidget::currentChanged(int index)
webView->setFocus();
}
-void TabWidget::fullScreenRequested(bool fullscreen)
+void TabWidget::fullScreenRequested(const QWebEngineFullScreenRequest &request)
{
- if (fullscreen) {
+ if (request.toggleOn()) {
if (!m_fullScreenView)
m_fullScreenView = new QWebEngineView();
WebPage *webPage = qobject_cast<WebPage*>(sender());
webPage->setView(m_fullScreenView);
+ request.accept();
m_fullScreenView->showFullScreen();
m_fullScreenView->raise();
} else {
@@ -367,6 +369,7 @@ void TabWidget::fullScreenRequested(bool fullscreen)
WebPage *webPage = qobject_cast<WebPage*>(sender());
WebView *oldWebView = this->webView(m_lineEdits->currentIndex());
webPage->setView(oldWebView);
+ request.accept();
raise();
m_fullScreenView->hide();
}
diff --git a/examples/webenginewidgets/demobrowser/tabwidget.h b/examples/webenginewidgets/demobrowser/tabwidget.h
index 0f2a20c34..3a1fe7171 100644
--- a/examples/webenginewidgets/demobrowser/tabwidget.h
+++ b/examples/webenginewidgets/demobrowser/tabwidget.h
@@ -216,7 +216,7 @@ private slots:
void lineEditReturnPressed();
void windowCloseRequested();
void moveTab(int fromIndex, int toIndex);
- void fullScreenRequested(bool);
+ void fullScreenRequested(const QWebEngineFullScreenRequest& request);
private:
QAction *m_recentlyClosedTabsAction;
diff --git a/src/3rdparty b/src/3rdparty
-Subproject 6c28e9497f45870d1d6db37f54a67fb597f9592
+Subproject b7204e81dcec1aa02e03b6bc499d811d0af6c5e
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 92c831f94..31ebb1244 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -823,6 +823,12 @@ void WebContentsAdapter::exitFullScreen()
d->webContents->ExitFullscreen();
}
+void WebContentsAdapter::changedFullScreen()
+{
+ Q_D(WebContentsAdapter);
+ d->webContents->NotifyFullscreenChanged();
+}
+
void WebContentsAdapter::wasShown()
{
Q_D(WebContentsAdapter);
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index 54bec9adf..ce033bdb4 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -129,6 +129,7 @@ public:
bool hasInspector() const;
void exitFullScreen();
void requestClose();
+ void changedFullScreen();
void wasShown();
void wasHidden();
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 6b203fc90..f2a05c575 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -211,8 +211,8 @@ public:
virtual void windowCloseRejected() = 0;
virtual bool contextMenuRequested(const WebEngineContextMenuData&) = 0;
virtual void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) = 0;
- virtual void requestFullScreen(bool) = 0;
- virtual bool isFullScreen() const = 0;
+ virtual void requestFullScreenMode(const QUrl &origin, bool fullscreen) = 0;
+ virtual bool isFullScreenMode() const = 0;
virtual void javascriptDialog(QSharedPointer<JavaScriptDialogController>) = 0;
virtual void runFileChooser(FilePickerController *controller) = 0;
virtual void didRunJavaScript(quint64 requestId, const QVariant& result) = 0;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index 497910a9c..1f789161a 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -245,24 +245,21 @@ content::JavaScriptDialogManager *WebContentsDelegateQt::GetJavaScriptDialogMana
void WebContentsDelegateQt::EnterFullscreenModeForTab(content::WebContents *web_contents, const GURL& origin)
{
- Q_UNUSED(origin); // FIXME
- if (!m_viewClient->isFullScreen()) {
- m_viewClient->requestFullScreen(true);
- web_contents->GetRenderViewHost()->WasResized();
- }
+ Q_UNUSED(web_contents);
+ if (!m_viewClient->isFullScreenMode())
+ m_viewClient->requestFullScreenMode(toQt(origin), true);
}
void WebContentsDelegateQt::ExitFullscreenModeForTab(content::WebContents *web_contents)
{
- if (m_viewClient->isFullScreen()) {
- m_viewClient->requestFullScreen(false);
- web_contents->GetRenderViewHost()->WasResized();
- }
+ if (m_viewClient->isFullScreenMode())
+ m_viewClient->requestFullScreenMode(toQt(web_contents->GetLastCommittedURL().GetOrigin()), false);
}
bool WebContentsDelegateQt::IsFullscreenForTabOrPending(const content::WebContents* web_contents) const
{
- return m_viewClient->isFullScreen();
+ Q_UNUSED(web_contents);
+ return m_viewClient->isFullScreenMode();
}
ASSERT_ENUMS_MATCH(FilePickerController::Open, content::FileChooserParams::Open)
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 3a05477a1..52245e147 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -272,7 +272,7 @@ bool QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenu
QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::InspectElement); });
ui()->addMenuItem(item, QQuickWebEngineView::tr("Inspect Element"));
}
- if (isFullScreen()) {
+ if (isFullScreenMode()) {
item = new MenuItemHandler(menu);
QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::ExitFullScreen); });
ui()->addMenuItem(item, QQuickWebEngineView::tr("Exit Full Screen Mode"));
@@ -516,14 +516,14 @@ void QQuickWebEngineViewPrivate::windowCloseRejected()
#endif
}
-void QQuickWebEngineViewPrivate::requestFullScreen(bool fullScreen)
+void QQuickWebEngineViewPrivate::requestFullScreenMode(const QUrl &origin, bool fullscreen)
{
Q_Q(QQuickWebEngineView);
- QQuickWebEngineFullScreenRequest request(this, fullScreen);
+ QQuickWebEngineFullScreenRequest request(this, origin, fullscreen);
Q_EMIT q->fullScreenRequested(request);
}
-bool QQuickWebEngineViewPrivate::isFullScreen() const
+bool QQuickWebEngineViewPrivate::isFullScreenMode() const
{
return m_isFullScreen;
}
@@ -1362,8 +1362,9 @@ QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest()
{
}
-QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, bool toggleOn)
+QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, const QUrl &origin, bool toggleOn)
: viewPrivate(viewPrivate)
+ , m_origin(origin)
, m_toggleOn(toggleOn)
{
}
@@ -1372,10 +1373,18 @@ void QQuickWebEngineFullScreenRequest::accept()
{
if (viewPrivate && viewPrivate->m_isFullScreen != m_toggleOn) {
viewPrivate->m_isFullScreen = m_toggleOn;
+ viewPrivate->adapter->changedFullScreen();
Q_EMIT viewPrivate->q_ptr->isFullScreenChanged();
}
}
+void QQuickWebEngineFullScreenRequest::reject()
+{
+ if (viewPrivate) {
+ viewPrivate->adapter->changedFullScreen();
+ }
+}
+
QQuickWebEngineViewExperimental::QQuickWebEngineViewExperimental(QQuickWebEngineViewPrivate *viewPrivate)
: q_ptr(0)
, d_ptr(viewPrivate)
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index d1d8dacbb..ddc656a58 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -71,17 +71,21 @@ class QQuickWebEngineTestSupport;
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineFullScreenRequest {
Q_GADGET
+ Q_PROPERTY(QUrl origin READ origin)
Q_PROPERTY(bool toggleOn READ toggleOn)
public:
QQuickWebEngineFullScreenRequest();
- QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, bool toggleOn);
+ QQuickWebEngineFullScreenRequest(QQuickWebEngineViewPrivate *viewPrivate, const QUrl &origin, bool toggleOn);
Q_INVOKABLE void accept();
- bool toggleOn() { return m_toggleOn; }
+ Q_INVOKABLE void reject();
+ QUrl origin() const { return m_origin; }
+ bool toggleOn() const { return m_toggleOn; }
private:
QQuickWebEngineViewPrivate *viewPrivate;
- bool m_toggleOn;
+ const QUrl m_origin;
+ const bool m_toggleOn;
};
#define LATEST_WEBENGINEVIEW_REVISION 2
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 271ab63be..c2210850f 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -144,8 +144,8 @@ public:
virtual void adoptNewWindow(QtWebEngineCore::WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &) Q_DECL_OVERRIDE;
virtual void close() Q_DECL_OVERRIDE;
virtual void windowCloseRejected() 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 bool contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &) Q_DECL_OVERRIDE;
virtual void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) Q_DECL_OVERRIDE;
virtual void javascriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>) Q_DECL_OVERRIDE;
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 \
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 9559f3cf5..150d59061 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -38,6 +38,7 @@
#include <qnetworkreply.h>
#include <qnetworkrequest.h>
#include <qpa/qplatforminputcontext.h>
+#include <qwebenginefullscreenrequest.h>
#include <qwebenginehistory.h>
#include <qwebenginepage.h>
#include <qwebengineprofile.h>
@@ -3736,28 +3737,10 @@ void tst_QWebEnginePage::runJavaScript()
QVERIFY(watcher.wait());
}
-class FullScreenPage : public QWebEnginePage {
- Q_OBJECT
-public:
- FullScreenPage(QObject* parent = 0)
- : QWebEnginePage(parent)
- , m_isFullScreen(true)
- { }
-
- void setIsFullScreen(bool b) { m_isFullScreen = b; }
-
-protected:
- bool isFullScreen() override
- {
- return m_isFullScreen;
- }
- bool m_isFullScreen;
-};
-
void tst_QWebEnginePage::fullScreenRequested()
{
JavaScriptCallbackWatcher watcher;
- FullScreenPage* page = new FullScreenPage;
+ QWebEnginePage* page = new QWebEnginePage;
QWebEngineView* view = new QWebEngineView;
view->setPage(page);
view->show();
@@ -3778,7 +3761,9 @@ void tst_QWebEnginePage::fullScreenRequested()
page->runJavaScript("document.webkitIsFullScreen", JavaScriptCallback(true));
page->runJavaScript("document.webkitExitFullscreen()", JavaScriptCallbackUndefined());
QVERIFY(watcher.wait());
- page->setIsFullScreen(false);
+ connect(page, &QWebEnginePage::fullScreenModeRequested,
+ [](const QWebEngineFullScreenRequest &request) { request.reject(); });
+
page->runJavaScript("document.webkitFullscreenEnabled", JavaScriptCallback(true));
QTest::keyPress(qApp->focusWindow(), Qt::Key_Space);
QVERIFY(watcher.wait());