summaryrefslogtreecommitdiffstats
path: root/src/webenginewidgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r--src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp2
-rw-r--r--src/webenginewidgets/api/qwebenginecertificateerror.cpp266
-rw-r--r--src/webenginewidgets/api/qwebenginecertificateerror.h104
-rw-r--r--src/webenginewidgets/api/qwebengineclientcertificateselection.cpp11
-rw-r--r--src/webenginewidgets/api/qwebengineclientcertificateselection.h19
-rw-r--r--src/webenginewidgets/api/qwebenginecontextmenudata.cpp306
-rw-r--r--src/webenginewidgets/api/qwebenginecontextmenudata.h133
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.cpp786
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.h174
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem_p.h99
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp421
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h18
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h32
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp41
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.h4
-rw-r--r--src/webenginewidgets/api/qwebengineprofile_p.h2
-rw-r--r--src/webenginewidgets/api/qwebenginesettings.cpp254
-rw-r--r--src/webenginewidgets/api/qwebenginesettings.h154
-rw-r--r--src/webenginewidgets/api/qwebengineview.cpp244
-rw-r--r--src/webenginewidgets/api/qwebengineview.h6
-rw-r--r--src/webenginewidgets/api/qwebengineview_p.h21
-rw-r--r--src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc9
-rw-r--r--src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc310
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp171
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h6
-rw-r--r--src/webenginewidgets/webenginewidgets.pro9
26 files changed, 486 insertions, 3116 deletions
diff --git a/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp b/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp
index 5949f3d6e..76f422e9d 100644
--- a/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp
+++ b/src/webenginewidgets/api/qtwebenginewidgetsglobal.cpp
@@ -41,6 +41,7 @@
#include <QCoreApplication>
#include <QOpenGLContext>
+#include <QQuickWindow>
namespace QtWebEngineCore
{
@@ -67,6 +68,7 @@ static void initialize()
}
//QCoreApplication is not yet instantiated, ensuring the call will be deferred
qAddPreRoutine(QtWebEngineCore::initialize);
+ QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi);
#endif // QT_CONFIG(opengl)
}
diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.cpp b/src/webenginewidgets/api/qwebenginecertificateerror.cpp
deleted file mode 100644
index d86019af8..000000000
--- a/src/webenginewidgets/api/qwebenginecertificateerror.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwebenginecertificateerror.h"
-
-#include "certificate_error_controller.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QWebEngineCertificateError
- \brief The QWebEngineCertificateError class provides information about a certificate error.
- \since 5.4
- \inmodule QtWebEngineWidgets
-
- Provides information about a certificate error. This class is used as a parameter of
- QWebEnginePage::certificateError().
-*/
-
-class QWebEngineCertificateErrorPrivate : public QSharedData {
-public:
- QWebEngineCertificateErrorPrivate(int error, QUrl url, bool overridable, QString errorDescription);
-
- ~QWebEngineCertificateErrorPrivate() {
- if (deferred && !answered)
- rejectCertificate();
- }
-
- void resolveError(bool accept) {
- if (answered)
- return;
- answered = true;
- if (overridable) {
- if (auto ctl = controller.lock())
- ctl->accept(accept);
- }
- }
-
- void ignoreCertificateError() { resolveError(true); }
- void rejectCertificate() { resolveError(false); }
-
- QWebEngineCertificateError::Error error;
- QUrl url;
- bool overridable;
- QString errorDescription;
- QList<QSslCertificate> certificateChain;
-
- bool answered = false, deferred = false;
- QWeakPointer<CertificateErrorController> controller;
-
- Q_DISABLE_COPY(QWebEngineCertificateErrorPrivate)
-};
-
-QWebEngineCertificateErrorPrivate::QWebEngineCertificateErrorPrivate(int error, QUrl url, bool overridable, QString errorDescription)
- : error(QWebEngineCertificateError::Error(error))
- , url(url)
- , overridable(overridable)
- , errorDescription(errorDescription)
-{ }
-
-/*! \internal
-*/
-QWebEngineCertificateError::QWebEngineCertificateError(int error, QUrl url, bool overridable, QString errorDescription)
- : d(new QWebEngineCertificateErrorPrivate(error, url, overridable, errorDescription))
-{ }
-
-/*! \internal
-*/
-QWebEngineCertificateError::QWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller)
- : d(new QWebEngineCertificateErrorPrivate(controller->error(), controller->url(),
- controller->overridable(), controller->errorString()))
-{
- d->controller = controller;
- d->certificateChain = controller->certificateChain();
-}
-
-QWebEngineCertificateError::QWebEngineCertificateError(const QWebEngineCertificateError &) = default;
-
-QWebEngineCertificateError& QWebEngineCertificateError::operator=(const QWebEngineCertificateError &) = default;
-
-/*! \internal
-*/
-QWebEngineCertificateError::~QWebEngineCertificateError()
-{
-
-}
-
-/*!
- \enum QWebEngineCertificateError::Error
-
- This enum describes the type of certificate error encountered.
-
- The values of this enum type match the SSL errors Chromium provides.
- QSslError::SslError values are not used directly, because the Qt error
- categories cannot be mapped to the Chromium error categories.
-
- \value SslPinnedKeyNotInCertificateChain The certificate did not match the built-in public keys
- pinned for the host name.
- \value CertificateCommonNameInvalid The certificate's common name did not match the host name.
- \value CertificateDateInvalid The certificate is not valid at the current date and time.
- \value CertificateAuthorityInvalid The certificate is not signed by a trusted authority.
- \value CertificateContainsErrors The certificate contains errors.
- \value CertificateNoRevocationMechanism The certificate has no mechanism for determining if it has been revoked.
- \value CertificateUnableToCheckRevocation Revocation information for the certificate is not available.
- \value CertificateRevoked The certificate has been revoked.
- \value CertificateInvalid The certificate is invalid.
- \value CertificateWeakSignatureAlgorithm The certificate is signed using a weak signature algorithm.
- \value CertificateNonUniqueName The host name specified in the certificate is not unique.
- \value CertificateWeakKey The certificate contains a weak key.
- \value CertificateNameConstraintViolation The certificate claimed DNS names that are in violation of name constraints.
- \value CertificateValidityTooLong The certificate has a validity period that is too long. (Added in Qt 5.7)
- \value CertificateTransparencyRequired Certificate Transparency was required for this connection, but the server
- did not provide CT information that complied with the policy. (Added in Qt 5.8)
- \value CertificateKnownInterceptionBlocked The certificate is known to be
- used for interception by an entity other the device owner. (Added in
- 5.15)
-*/
-
-/*!
- Returns whether this error can be overridden and accepted.
-
- \sa error(), errorDescription()
-*/
-bool QWebEngineCertificateError::isOverridable() const
-{
- return d->overridable;
-}
-
-/*!
- Returns the URL that triggered the error.
-
- \sa error(), errorDescription()
-*/
-QUrl QWebEngineCertificateError::url() const
-{
- return d->url;
-}
-
-/*!
- Returns the type of the error.
-
- \sa errorDescription(), isOverridable()
-*/
-QWebEngineCertificateError::Error QWebEngineCertificateError::error() const
-{
- return d->error;
-}
-
-/*!
- Returns a short localized human-readable description of the error.
-
- \sa error(), url(), isOverridable()
-*/
-QString QWebEngineCertificateError::errorDescription() const
-{
- return d->errorDescription;
-}
-
-/*!
- \since 5.14
-
- Marks the certificate error for delayed handling.
-
- This function should be called when there is a need to postpone the decision whether to ignore a
- certificate error, for example, while waiting for user input. When called, the function pauses the
- URL request until ignoreCertificateError() or rejectCertificate() is called.
-
- \note It is only possible to defer overridable certificate errors.
-
- \sa isOverridable(), deferred()
-*/
-void QWebEngineCertificateError::defer()
-{
- if (isOverridable())
- d->deferred = true;
-}
-
-/*!
- \since 5.14
-
- Returns whether the decision for error handling was delayed and the URL load was halted.
-*/
-bool QWebEngineCertificateError::deferred() const
-{
- return d->deferred;
-}
-
-/*!
- \since 5.14
-
- Ignores the certificate error and continues the loading of the requested URL.
-*/
-void QWebEngineCertificateError::ignoreCertificateError()
-{
- d->ignoreCertificateError();
-}
-
-/*!
- \since 5.14
-
- Rejects the certificate and aborts the loading of the requested URL.
-*/
-void QWebEngineCertificateError::rejectCertificate()
-{
- d->rejectCertificate();
-}
-
-/*!
- \since 5.14
-
- Returns \c true if the error was explicitly rejected or ignored.
-*/
-bool QWebEngineCertificateError::answered() const
-{
- return d->answered;
-}
-
-/*!
- \since 5.14
-
- Returns the peer's chain of digital certificates.
-
- Chain starts with the peer's immediate certificate and ending with the CA's certificate.
-*/
-QList<QSslCertificate> QWebEngineCertificateError::certificateChain() const
-{
- return d->certificateChain;
-}
-
-QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.h b/src/webenginewidgets/api/qwebenginecertificateerror.h
deleted file mode 100644
index a32f7ab8e..000000000
--- a/src/webenginewidgets/api/qwebenginecertificateerror.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWEBENGINECERTIFICATEERROR_H
-#define QWEBENGINECERTIFICATEERROR_H
-
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-
-#include <QtCore/qsharedpointer.h>
-#include <QtCore/qurl.h>
-#include <QtNetwork/QSslCertificate>
-
-QT_BEGIN_NAMESPACE
-
-class CertificateErrorController;
-class QWebEngineCertificateErrorPrivate;
-
-class QWEBENGINEWIDGETS_EXPORT QWebEngineCertificateError {
-public:
- QWebEngineCertificateError(int error, QUrl url, bool overridable, QString errorDescription);
- ~QWebEngineCertificateError();
-
- // Keep this identical to CertificateErrorController::CertificateError, or add mapping layer.
- enum Error {
- SslPinnedKeyNotInCertificateChain = -150,
- CertificateCommonNameInvalid = -200,
- CertificateDateInvalid = -201,
- CertificateAuthorityInvalid = -202,
- CertificateContainsErrors = -203,
- CertificateNoRevocationMechanism = -204,
- CertificateUnableToCheckRevocation = -205,
- CertificateRevoked = -206,
- CertificateInvalid = -207,
- CertificateWeakSignatureAlgorithm = -208,
- CertificateNonUniqueName = -210,
- CertificateWeakKey = -211,
- CertificateNameConstraintViolation = -212,
- CertificateValidityTooLong = -213,
- CertificateTransparencyRequired = -214,
- CertificateKnownInterceptionBlocked = -217,
- };
-
- Error error() const;
- QUrl url() const;
- bool isOverridable() const;
- QString errorDescription() const;
-
- QWebEngineCertificateError(const QWebEngineCertificateError &other);
- QWebEngineCertificateError& operator=(const QWebEngineCertificateError &other);
-
- void defer();
- bool deferred() const;
-
- void rejectCertificate();
- void ignoreCertificateError();
- bool answered() const;
-
- QList<QSslCertificate> certificateChain() const;
-
-private:
- friend class QWebEnginePagePrivate;
- QWebEngineCertificateError(const QSharedPointer<CertificateErrorController> &controller);
- QExplicitlySharedDataPointer<QWebEngineCertificateErrorPrivate> d;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINECERTIFICATEERROR_H
diff --git a/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp b/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp
index 9eca01bbe..febfe0a21 100644
--- a/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp
+++ b/src/webenginewidgets/api/qwebengineclientcertificateselection.cpp
@@ -38,9 +38,6 @@
****************************************************************************/
#include "qwebengineclientcertificateselection.h"
-
-#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
-
#include "client_cert_select_controller.h"
QT_BEGIN_NAMESPACE
@@ -63,8 +60,9 @@ QT_BEGIN_NAMESPACE
/*! \internal
*/
-QWebEngineClientCertificateSelection::QWebEngineClientCertificateSelection(QSharedPointer<ClientCertSelectController> selectController)
- : d_ptr(selectController)
+QWebEngineClientCertificateSelection::QWebEngineClientCertificateSelection(
+ QSharedPointer<QtWebEngineCore::ClientCertSelectController> selectController)
+ : d_ptr(selectController)
{}
QWebEngineClientCertificateSelection::QWebEngineClientCertificateSelection(const QWebEngineClientCertificateSelection &other)
@@ -86,7 +84,7 @@ QWebEngineClientCertificateSelection::~QWebEngineClientCertificateSelection()
\sa select()
*/
-QVector<QSslCertificate> QWebEngineClientCertificateSelection::certificates() const
+QList<QSslCertificate> QWebEngineClientCertificateSelection::certificates() const
{
return d_ptr->certificates();
}
@@ -124,4 +122,3 @@ QUrl QWebEngineClientCertificateSelection::host() const
QT_END_NAMESPACE
-#endif // !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
diff --git a/src/webenginewidgets/api/qwebengineclientcertificateselection.h b/src/webenginewidgets/api/qwebengineclientcertificateselection.h
index d451d09ae..165194aac 100644
--- a/src/webenginewidgets/api/qwebengineclientcertificateselection.h
+++ b/src/webenginewidgets/api/qwebengineclientcertificateselection.h
@@ -42,15 +42,15 @@
#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
#include <QtNetwork/qtnetwork-config.h>
-
-#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
-
+#include <QtCore/qlist.h>
#include <QtCore/qscopedpointer.h>
-#include <QtCore/qvector.h>
#include <QtNetwork/qsslcertificate.h>
-QT_BEGIN_NAMESPACE
+namespace QtWebEngineCore {
class ClientCertSelectController;
+}
+
+QT_BEGIN_NAMESPACE
class QWEBENGINEWIDGETS_EXPORT QWebEngineClientCertificateSelection {
public:
@@ -63,18 +63,17 @@ public:
void select(const QSslCertificate &certificate);
void selectNone();
- QVector<QSslCertificate> certificates() const;
+ QList<QSslCertificate> certificates() const;
private:
friend class QWebEnginePagePrivate;
- QWebEngineClientCertificateSelection(QSharedPointer<ClientCertSelectController>);
+ QWebEngineClientCertificateSelection(
+ QSharedPointer<QtWebEngineCore::ClientCertSelectController>);
- QSharedPointer<ClientCertSelectController> d_ptr;
+ QSharedPointer<QtWebEngineCore::ClientCertSelectController> d_ptr;
};
QT_END_NAMESPACE
-#endif // !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
-
#endif // QWEBENGINECLIENTCERTSELECTION_H
diff --git a/src/webenginewidgets/api/qwebenginecontextmenudata.cpp b/src/webenginewidgets/api/qwebenginecontextmenudata.cpp
deleted file mode 100644
index 377ffe1b5..000000000
--- a/src/webenginewidgets/api/qwebenginecontextmenudata.cpp
+++ /dev/null
@@ -1,306 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwebenginecontextmenudata.h"
-
-#include "web_contents_adapter_client.h"
-
-QT_BEGIN_NAMESPACE
-
-// Match MediaType enum
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeNone, QWebEngineContextMenuData::MediaTypeNone)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeImage, QWebEngineContextMenuData::MediaTypeImage)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeAudio, QWebEngineContextMenuData::MediaTypeAudio)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeVideo, QWebEngineContextMenuData::MediaTypeVideo)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeCanvas, QWebEngineContextMenuData::MediaTypeCanvas)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypeFile, QWebEngineContextMenuData::MediaTypeFile)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaTypePlugin, QWebEngineContextMenuData::MediaTypePlugin)
-
-// Match MediaFlag enum
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaInError, QWebEngineContextMenuData::MediaInError)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaPaused, QWebEngineContextMenuData::MediaPaused)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaMuted, QWebEngineContextMenuData::MediaMuted)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaLoop, QWebEngineContextMenuData::MediaLoop)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanSave, QWebEngineContextMenuData::MediaCanSave)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaHasAudio, QWebEngineContextMenuData::MediaHasAudio)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanToggleControls, QWebEngineContextMenuData::MediaCanToggleControls)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaControls, QWebEngineContextMenuData::MediaControls)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanPrint, QWebEngineContextMenuData::MediaCanPrint)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::MediaCanRotate, QWebEngineContextMenuData::MediaCanRotate)
-
-// Match EditFlag enum
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanUndo, QWebEngineContextMenuData::CanUndo)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanRedo, QWebEngineContextMenuData::CanRedo)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanCut, QWebEngineContextMenuData::CanCut)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanCopy, QWebEngineContextMenuData::CanCopy)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanPaste, QWebEngineContextMenuData::CanPaste)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanDelete, QWebEngineContextMenuData::CanDelete)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanSelectAll, QWebEngineContextMenuData::CanSelectAll)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanTranslate, QWebEngineContextMenuData::CanTranslate)
-ASSERT_ENUMS_MATCH(QtWebEngineCore::WebEngineContextMenuData::CanEditRichly, QWebEngineContextMenuData::CanEditRichly)
-
-/*!
- \class QWebEngineContextMenuData
- \since 5.7
- \brief The QWebEngineContextMenuData class provides context data for populating or extending a context menu with actions.
-
- \inmodule QtWebEngineWidgets
-
- QWebEngineContextMenuData is returned by QWebEnginePage::contextMenuData() after a context menu event,
- and contains information about where the context menu event took place. This is also in the context
- in which any context specific QWebEnginePage::WebAction will be performed.
-*/
-
-/*!
- \enum QWebEngineContextMenuData::MediaType
-
- This enum describes the media type of the context if any.
-
- \value MediaTypeNone The context is not a media type.
- \value MediaTypeImage The context is an image element.
- \value MediaTypeVideo The context is a video element.
- \value MediaTypeAudio The context is an audio element.
- \value MediaTypeCanvas The context is a canvas element.
- \value MediaTypeFile The context is a file.
- \value MediaTypePlugin The context is a plugin element.
-*/
-
-/*!
- \enum QWebEngineContextMenuData::EditFlag
- \readonly
- \since 5.11
-
- The available edit operations in the current context.
-
- \value CanUndo Undo is available.
- \value CanRedo Redo is available.
- \value CanCut Cut is available.
- \value CanCopy Copy is available.
- \value CanPaste Paste is available.
- \value CanDelete Delete is available.
- \value CanSelectAll Select All is available.
- \value CanTranslate Translate is available.
- \value CanEditRichly Context is richly editable.
-*/
-
-/*!
- \enum QWebEngineContextMenuData::MediaFlag
- \readonly
- \since 5.11
-
- The current media element's status and its available operations.
- \c MediaNone if the selected web page content is not a media element.
-
- \value MediaInError An error occurred.
- \value MediaPaused Media is paused.
- \value MediaMuted Media is muted.
- \value MediaLoop Media can be looped.
- \value MediaCanSave Media can be saved.
- \value MediaHasAudio Media has audio.
- \value MediaCanToggleControls Media can show controls.
- \value MediaControls Media controls are shown.
- \value MediaCanPrint Media is printable.
- \value MediaCanRotate Media is rotatable.
-*/
-
-/*!
- Constructs null context menu data.
-*/
-QWebEngineContextMenuData::QWebEngineContextMenuData() : d(nullptr)
-{
-}
-
-/*!
- Constructs context menu data from \a other.
-*/
-QWebEngineContextMenuData::QWebEngineContextMenuData(const QWebEngineContextMenuData &other)
-{
- d = new QtWebEngineCore::WebEngineContextMenuData(*other.d);
-}
-
-/*!
- Assigns the \a other context menu data to this.
-*/
-QWebEngineContextMenuData &QWebEngineContextMenuData::operator=(const QWebEngineContextMenuData &other)
-{
- delete d;
- d = new QtWebEngineCore::WebEngineContextMenuData(*other.d);
- return *this;
-}
-
-/*!
- Destroys the context menu data.
-*/
-QWebEngineContextMenuData::~QWebEngineContextMenuData()
-{
- delete d;
-}
-
-/*!
- Returns \c true if the context data is valid; otherwise returns \c false.
-*/
-bool QWebEngineContextMenuData::isValid() const
-{
- return d;
-}
-
-/*!
- Resets the context data, making it invalid.
- \internal
-
- \sa isValid()
-*/
-void QWebEngineContextMenuData::reset()
-{
- delete d;
- d = nullptr;
-}
-
-/*!
- Returns the position of the context, usually the mouse position where the context menu event was triggered.
-*/
-QPoint QWebEngineContextMenuData::position() const
-{
- return d ? d->position() : QPoint();
-}
-
-/*!
- Returns the text of a link if the context is a link.
-*/
-QString QWebEngineContextMenuData::linkText() const
-{
- return d ? d->linkText() : QString();
-}
-
-/*!
- Returns the URL of a link if the context is a link.
- It is not guaranteed to be a valid URL.
-*/
-QUrl QWebEngineContextMenuData::linkUrl() const
-{
- return d ? d->unfilteredLinkUrl() : QUrl();
-}
-
-/*!
- Returns the selected text of the context.
-*/
-QString QWebEngineContextMenuData::selectedText() const
-{
- return d ? d->selectedText() : QString();
-}
-
-/*!
- If the context is a media element, returns the URL of that media.
-*/
-QUrl QWebEngineContextMenuData::mediaUrl() const
-{
- return d ? d->mediaUrl() : QUrl();
-}
-
-/*!
- Returns the type of the media element or \c MediaTypeNone if the context is not a media element.
-*/
-QWebEngineContextMenuData::MediaType QWebEngineContextMenuData::mediaType() const
-{
- return d ? static_cast<QWebEngineContextMenuData::MediaType>(d->mediaType()) : MediaTypeNone;
-}
-
-/*!
- Returns \c true if the content is editable by the user; otherwise returns \c false.
-*/
-bool QWebEngineContextMenuData::isContentEditable() const
-{
- return d ? d->isEditable() : false;
-}
-
-/*!
- If the context is a word considered misspelled by the spell-checker, returns the misspelled word.
-
- For possible replacements of the word, see spellCheckerSuggestions().
-
- \since 5.8
-*/
-QString QWebEngineContextMenuData::misspelledWord() const
-{
- if (d)
- return d->misspelledWord();
- return QString();
-}
-
-/*!
- If the context is a word considered misspelled by the spell-checker, returns a list of suggested replacements
- for misspelledWord().
-
- \since 5.8
-*/
-QStringList QWebEngineContextMenuData::spellCheckerSuggestions() const
-{
- if (d)
- return d->spellCheckerSuggestions();
- return QStringList();
-}
-
-/*!
- \internal
-*/
-QWebEngineContextMenuData &QWebEngineContextMenuData::operator=(const QWebEngineContextDataPrivate &priv)
-{
- delete d;
- d = new QtWebEngineCore::WebEngineContextMenuData(priv);
- return *this;
-}
-
-/*!
- Returns the current media element's status and its available operations.
- \c MediaNone if the selected web page content is not a media element.
-*/
-QWebEngineContextMenuData::MediaFlags QWebEngineContextMenuData::mediaFlags() const
-{
- return static_cast<QWebEngineContextMenuData::MediaFlags>(d->mediaFlags());
-}
-
-/*!
- Returns the available edit operations in the current context or \c CanDoNone if no actions are available.
-*/
-QWebEngineContextMenuData::EditFlags QWebEngineContextMenuData::editFlags() const
-{
- return static_cast<QWebEngineContextMenuData::EditFlags>(d->editFlags());
-}
-
-QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginecontextmenudata.h b/src/webenginewidgets/api/qwebenginecontextmenudata.h
deleted file mode 100644
index 5834df31a..000000000
--- a/src/webenginewidgets/api/qwebenginecontextmenudata.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWEBENGINECONTEXTDATA_H
-#define QWEBENGINECONTEXTDATA_H
-
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qurl.h>
-
-namespace QtWebEngineCore {
-class WebEngineContextMenuData;
-}
-
-QT_BEGIN_NAMESPACE
-
-class QWEBENGINEWIDGETS_EXPORT QWebEngineContextMenuData {
- Q_GADGET
-
-public:
- QWebEngineContextMenuData();
- QWebEngineContextMenuData(const QWebEngineContextMenuData &other);
- QWebEngineContextMenuData &operator=(const QWebEngineContextMenuData &other);
- ~QWebEngineContextMenuData();
-
- enum MediaType {
- MediaTypeNone,
- MediaTypeImage,
- MediaTypeVideo,
- MediaTypeAudio,
- MediaTypeCanvas,
- MediaTypeFile,
- MediaTypePlugin
- };
-
- // Must match QWebEngineCore::WebEngineContextMenuData::MediaFlags:
- enum MediaFlag {
- MediaInError = 0x1,
- MediaPaused = 0x2,
- MediaMuted = 0x4,
- MediaLoop = 0x8,
- MediaCanSave = 0x10,
- MediaHasAudio = 0x20,
- MediaCanToggleControls = 0x40,
- MediaControls = 0x80,
- MediaCanPrint = 0x100,
- MediaCanRotate = 0x200,
- };
- Q_DECLARE_FLAGS(MediaFlags, MediaFlag)
- Q_FLAG(MediaFlags)
-
- // Must match QWebEngineCore::WebEngineContextMenuData::EditFlags:
- enum EditFlag {
- CanUndo = 0x1,
- CanRedo = 0x2,
- CanCut = 0x4,
- CanCopy = 0x8,
- CanPaste = 0x10,
- CanDelete = 0x20,
- CanSelectAll = 0x40,
- CanTranslate = 0x80,
- CanEditRichly = 0x100,
- };
- Q_DECLARE_FLAGS(EditFlags, EditFlag)
- Q_FLAG(EditFlags)
-
- bool isValid() const;
-
- QPoint position() const;
- QString selectedText() const;
- QString linkText() const;
- QUrl linkUrl() const;
- QUrl mediaUrl() const;
- MediaType mediaType() const;
- bool isContentEditable() const;
- QString misspelledWord() const;
- QStringList spellCheckerSuggestions() const;
- MediaFlags mediaFlags() const;
- EditFlags editFlags() const;
-
-private:
- void reset();
- typedef QtWebEngineCore::WebEngineContextMenuData QWebEngineContextDataPrivate;
- QWebEngineContextMenuData &operator=(const QWebEngineContextDataPrivate &priv);
- const QWebEngineContextDataPrivate *d;
-
- friend class QWebEnginePagePrivate;
- friend class QWebEnginePage;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QWebEngineContextMenuData::MediaFlags)
-Q_DECLARE_OPERATORS_FOR_FLAGS(QWebEngineContextMenuData::EditFlags)
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINECONTEXTDATA_H
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp
deleted file mode 100644
index 7366dbf59..000000000
--- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp
+++ /dev/null
@@ -1,786 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwebenginedownloaditem.h"
-#include "qwebenginedownloaditem_p.h"
-
-#include "profile_adapter.h"
-#include "qwebengineprofile_p.h"
-
-#include <QDir>
-#include "QFileInfo"
-
-QT_BEGIN_NAMESPACE
-
-using QtWebEngineCore::ProfileAdapterClient;
-
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NoReason, QWebEngineDownloadItem::NoReason)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileFailed, QWebEngineDownloadItem::FileFailed)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileAccessDenied, QWebEngineDownloadItem::FileAccessDenied)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileNoSpace, QWebEngineDownloadItem::FileNoSpace)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileNameTooLong, QWebEngineDownloadItem::FileNameTooLong)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTooLarge, QWebEngineDownloadItem::FileTooLarge)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileVirusInfected, QWebEngineDownloadItem::FileVirusInfected)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTransientError, QWebEngineDownloadItem::FileTransientError)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileBlocked, QWebEngineDownloadItem::FileBlocked)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileSecurityCheckFailed, QWebEngineDownloadItem::FileSecurityCheckFailed)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileTooShort, QWebEngineDownloadItem::FileTooShort)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::FileHashMismatch, QWebEngineDownloadItem::FileHashMismatch)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkFailed, QWebEngineDownloadItem::NetworkFailed)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkTimeout, QWebEngineDownloadItem::NetworkTimeout)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkDisconnected, QWebEngineDownloadItem::NetworkDisconnected)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkServerDown, QWebEngineDownloadItem::NetworkServerDown)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::NetworkInvalidRequest, QWebEngineDownloadItem::NetworkInvalidRequest)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerFailed, QWebEngineDownloadItem::ServerFailed)
-//ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerNoRange, QWebEngineDownloadItem::ServerNoRange)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerBadContent, QWebEngineDownloadItem::ServerBadContent)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerUnauthorized, QWebEngineDownloadItem::ServerUnauthorized)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerCertProblem, QWebEngineDownloadItem::ServerCertProblem)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerForbidden, QWebEngineDownloadItem::ServerForbidden)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::ServerUnreachable, QWebEngineDownloadItem::ServerUnreachable)
-ASSERT_ENUMS_MATCH(ProfileAdapterClient::UserCanceled, QWebEngineDownloadItem::UserCanceled)
-//ASSERT_ENUMS_MATCH(ProfileAdapterClient::UserShutdown, QWebEngineDownloadItem::UserShutdown)
-//ASSERT_ENUMS_MATCH(ProfileAdapterClient::Crash, QWebEngineDownloadItem::Crash)
-
-static inline QWebEngineDownloadItem::DownloadState toDownloadState(int state)
-{
- switch (state) {
- case ProfileAdapterClient::DownloadInProgress:
- return QWebEngineDownloadItem::DownloadInProgress;
- case ProfileAdapterClient::DownloadCompleted:
- return QWebEngineDownloadItem::DownloadCompleted;
- case ProfileAdapterClient::DownloadCancelled:
- return QWebEngineDownloadItem::DownloadCancelled;
- case ProfileAdapterClient::DownloadInterrupted:
- return QWebEngineDownloadItem::DownloadInterrupted;
- default:
- Q_UNREACHABLE();
- return QWebEngineDownloadItem::DownloadCancelled;
- }
-}
-
-static inline QWebEngineDownloadItem::DownloadInterruptReason toDownloadInterruptReason(int reason)
-{
- return static_cast<QWebEngineDownloadItem::DownloadInterruptReason>(reason);
-}
-
-/*!
- \class QWebEngineDownloadItem
- \brief The QWebEngineDownloadItem class provides information about a download.
-
- \since 5.5
-
- \inmodule QtWebEngineWidgets
-
- QWebEngineDownloadItem models a download throughout its life cycle, starting
- with a pending download request and finishing with a completed download. It
- can be used, for example, to get information about new downloads, to monitor
- progress, and to pause, resume, and cancel downloads.
-
- Downloads are usually triggered by user interaction on a web page. It is the
- QWebEngineProfile's responsibility to notify the application of new download
- requests, which it does by emitting the
- \l{QWebEngineProfile::downloadRequested}{downloadRequested} signal together
- with a newly created QWebEngineDownloadItem. The application can then
- examine this item and decide whether to accept it or not. A signal handler
- must explicitly call accept() on the item for \QWE to actually start
- downloading and writing data to disk. If no signal handler calls accept(),
- then the download request will be automatically rejected and nothing will be
- written to disk.
-
- \note Some properties, such as setting the path and file name where the file
- will be saved (see \l downloadDirectory() and \l downloadFileName()), can
- only be changed before calling accept().
-
- \section2 Object Life Cycle
-
- All items are guaranteed to be valid during the emission of the
- \l{QWebEngineProfile::downloadRequested}{downloadRequested} signal. If
- accept() is \e not called by any signal handler, then the item will be
- deleted \e immediately after signal emission. This means that the
- application \b{must not} keep references to rejected download items. It also
- means the application should not use a queued connection to this signal.
-
- If accept() \e is called by a signal handler, then the QWebEngineProfile
- will take ownership of the item. However, it is safe for the application to
- delete the item at any time, except during the handling of the
- \l{QWebEngineProfile::downloadRequested}{downloadRequested} signal. The
- QWebEngineProfile being a long-lived object, it is in fact recommended that
- the application delete any items it is no longer interested in.
-
- \note Deleting an item will also automatically cancel a download since 5.12.2,
- but it is recommended to cancel manually before deleting for portability.
-
- \section2 Web Page Downloads
-
- In addition to normal file downloads, which consist simply of retrieving
- some raw bytes from the network and writing them to disk, \QWE also
- supports saving complete web pages, which involves parsing the page's HTML,
- downloading any dependent resources, and potentially packaging everything
- into a special file format (\l savePageFormat). To check if a download is
- for a file or a web page, use \l isSavePageDownload.
-
- \sa QWebEngineProfile, QWebEngineProfile::downloadRequested,
- QWebEnginePage::download, QWebEnginePage::save
-*/
-
-QWebEngineDownloadItemPrivate::QWebEngineDownloadItemPrivate(QWebEngineProfilePrivate *p, const QUrl &url)
- : profile(p)
- , downloadFinished(false)
- , downloadId(-1)
- , downloadState(QWebEngineDownloadItem::DownloadCancelled)
- , savePageFormat(QWebEngineDownloadItem::MimeHtmlSaveFormat)
- , type(QWebEngineDownloadItem::Attachment)
- , interruptReason(QWebEngineDownloadItem::NoReason)
- , downloadUrl(url)
- , downloadPaused(false)
- , isCustomFileName(false)
- , totalBytes(-1)
- , receivedBytes(0)
- , page(0)
-{
-}
-
-QWebEngineDownloadItemPrivate::~QWebEngineDownloadItemPrivate()
-{
-}
-
-void QWebEngineDownloadItemPrivate::update(const ProfileAdapterClient::DownloadItemInfo &info)
-{
- Q_Q(QWebEngineDownloadItem);
-
- Q_ASSERT(downloadState != QWebEngineDownloadItem::DownloadRequested);
-
- if (toDownloadInterruptReason(info.downloadInterruptReason) != interruptReason)
- interruptReason = toDownloadInterruptReason(info.downloadInterruptReason);
-
- if (toDownloadState(info.state) != downloadState) {
- downloadState = toDownloadState(info.state);
- Q_EMIT q->stateChanged(downloadState);
- }
-
- if (info.receivedBytes != receivedBytes || info.totalBytes != totalBytes) {
- receivedBytes = info.receivedBytes;
- totalBytes = info.totalBytes;
- Q_EMIT q->downloadProgress(receivedBytes, totalBytes);
- }
-
- if (info.done)
- setFinished();
-
- if (downloadPaused != info.paused) {
- downloadPaused = info.paused;
- Q_EMIT q->isPausedChanged(downloadPaused);
- }
-}
-
-void QWebEngineDownloadItemPrivate::setFinished()
-{
- if (downloadFinished)
- return;
-
- downloadFinished = true;
- Q_EMIT q_ptr->finished();
-}
-
-/*!
- Accepts the current download request, which will start the download.
-
- If the item is in the \l DownloadRequested state, then it will transition
- into the \l DownloadInProgress state and the downloading will begin. If the
- item is in any other state, then nothing will happen.
-
- \sa finished(), stateChanged()
-*/
-
-void QWebEngineDownloadItem::accept()
-{
- Q_D(QWebEngineDownloadItem);
-
- if (d->downloadState != QWebEngineDownloadItem::DownloadRequested)
- return;
-
- d->downloadState = QWebEngineDownloadItem::DownloadInProgress;
- Q_EMIT stateChanged(d->downloadState);
-}
-
-/*!
- Cancels the current download.
-
- If the item is in the \l DownloadInProgress state, then it will transition
- into the \l DownloadCancelled state, the downloading will stop, and partially
- downloaded files will be deleted from disk.
-
- If the item is in the \l DownloadCompleted state, then nothing will happen.
- If the item is in any other state, then it will transition into the \l
- DownloadCancelled state without further effect.
-
- \sa finished(), stateChanged()
-*/
-
-void QWebEngineDownloadItem::cancel()
-{
- Q_D(QWebEngineDownloadItem);
-
- QWebEngineDownloadItem::DownloadState state = d->downloadState;
-
- if (state == QWebEngineDownloadItem::DownloadCompleted
- || state == QWebEngineDownloadItem::DownloadCancelled)
- return;
-
- // We directly cancel the download request if the user cancels
- // before it even started, so no need to notify the profile here.
- if (state == QWebEngineDownloadItem::DownloadInProgress) {
- if (auto profileAdapter = d->profile->profileAdapter())
- profileAdapter->cancelDownload(d->downloadId);
- } else {
- d->downloadState = QWebEngineDownloadItem::DownloadCancelled;
- Q_EMIT stateChanged(d->downloadState);
- d->setFinished();
- }
-}
-
-/*!
- \since 5.10
- Pauses the download.
-
- Has no effect if the state is not \l DownloadInProgress. Does not change the
- state.
-
- \sa resume(), isPaused()
-*/
-
-void QWebEngineDownloadItem::pause()
-{
- Q_D(QWebEngineDownloadItem);
-
- QWebEngineDownloadItem::DownloadState state = d->downloadState;
-
- if (state != QWebEngineDownloadItem::DownloadInProgress)
- return;
-
- d->profile->profileAdapter()->pauseDownload(d->downloadId);
-}
-
-/*!
- \since 5.10
- Resumes the current download if it was paused or interrupted.
-
- Has no effect if the state is not \l DownloadInProgress or \l
- DownloadInterrupted. Does not change the state.
-
- \sa pause(), isPaused(), state()
-*/
-void QWebEngineDownloadItem::resume()
-{
- Q_D(QWebEngineDownloadItem);
-
- QWebEngineDownloadItem::DownloadState state = d->downloadState;
-
- if (d->downloadFinished || (state != QWebEngineDownloadItem::DownloadInProgress && state != QWebEngineDownloadItem::DownloadInterrupted))
- return;
- d->profile->profileAdapter()->resumeDownload(d->downloadId);
-}
-
-/*!
- Returns the download item's ID.
-*/
-
-quint32 QWebEngineDownloadItem::id() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->downloadId;
-}
-
-/*!
- \fn void QWebEngineDownloadItem::finished()
-
- This signal is emitted when the download finishes.
-
- \sa state(), isFinished()
-*/
-
-/*!
- \fn void QWebEngineDownloadItem::isPausedChanged(bool isPaused)
- \since 5.10
-
- This signal is emitted whenever \a isPaused changes.
-
- \sa pause(), isPaused()
-*/
-
-/*!
- \fn void QWebEngineDownloadItem::stateChanged(DownloadState state)
-
- This signal is emitted whenever the download's \a state changes.
-
- \sa state(), DownloadState
-*/
-
-/*!
- \fn void QWebEngineDownloadItem::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
-
- This signal is emitted to indicate the progress of the download request.
-
- The \a bytesReceived parameter indicates the number of bytes received, while
- \a bytesTotal indicates the total number of bytes expected to be downloaded.
- If the size of the file to be downloaded is not known, \c bytesTotal will be
- 0.
-
- \sa totalBytes(), receivedBytes()
-*/
-
-/*!
- \enum QWebEngineDownloadItem::DownloadState
-
- This enum describes the state of the download:
-
- \value DownloadRequested Download has been requested, but has not been accepted yet.
- \value DownloadInProgress Download is in progress.
- \value DownloadCompleted Download completed successfully.
- \value DownloadCancelled Download has been cancelled.
- \value DownloadInterrupted Download has been interrupted (by the server or because of lost
- connectivity).
-*/
-
-/*!
- \enum QWebEngineDownloadItem::SavePageFormat
- \since 5.7
-
- This enum describes the format that is used to save a web page.
-
- \value UnknownSaveFormat This is not a request for downloading a complete web page.
- \value SingleHtmlSaveFormat The page is saved as a single HTML page. Resources such as images
- are not saved.
- \value CompleteHtmlSaveFormat The page is saved as a complete HTML page, for example a directory
- containing the single HTML page and the resources.
- \value MimeHtmlSaveFormat The page is saved as a complete web page in the MIME HTML format.
-*/
-
-/*!
- \enum QWebEngineDownloadItem::DownloadType
- \since 5.8
- \obsolete
-
- Describes the requested download's type.
-
- \value Attachment The web server's response includes a
- \c Content-Disposition header with the \c attachment directive. If \c Content-Disposition
- is present in the reply, the web server is indicating that the client should prompt the
- user to save the content regardless of the content type.
- See \l {RFC 2616 section 19.5.1} for details.
- \value DownloadAttribute The user clicked a link with the \c download
- attribute.
- \value UserRequested The user initiated the download, for example by
- selecting a web action.
- \value SavePage Saving of the current page was requested (for example by
- the \l{QWebEnginePage::WebAction}{QWebEnginePage::SavePage} web action).
-*/
-
-/*!
- \enum QWebEngineDownloadItem::DownloadInterruptReason
- \since 5.9
-
- Describes the reason why a download was interrupted:
-
- \value NoReason Unknown reason or not interrupted.
- \value FileFailed General file operation failure.
- \value FileAccessDenied The file cannot be written locally, due to access restrictions.
- \value FileNoSpace Insufficient space on the target drive.
- \value FileNameTooLong The directory or file name is too long.
- \value FileTooLarge The file size exceeds the file system limitation.
- \value FileVirusInfected The file is infected with a virus.
- \value FileTransientError Temporary problem (for example the file is in use,
- out of memory, or too many files are opened at once).
- \value FileBlocked The file was blocked due to local policy.
- \value FileSecurityCheckFailed An attempt to check the safety of the download
- failed due to unexpected reasons.
- \value FileTooShort An attempt was made to seek past the end of a file when
- opening a file (as part of resuming a previously interrupted download).
- \value FileHashMismatch The partial file did not match the expected hash.
-
- \value NetworkFailed General network failure.
- \value NetworkTimeout The network operation has timed out.
- \value NetworkDisconnected The network connection has been terminated.
- \value NetworkServerDown The server has gone down.
- \value NetworkInvalidRequest The network request was invalid (for example, the
- original or redirected URL is invalid, has an unsupported scheme, or is disallowed by policy).
-
- \value ServerFailed General server failure.
- \value ServerBadContent The server does not have the requested data.
- \value ServerUnauthorized The server did not authorize access to the resource.
- \value ServerCertProblem A problem with the server certificate occurred.
- \value ServerForbidden Access forbidden by the server.
- \value ServerUnreachable Unexpected server response (might indicate that
- the responding server may not be the intended server).
- \value UserCanceled The user canceled the download.
-*/
-
-/*!
- Returns the download item's current state.
-
- \sa DownloadState
-*/
-
-QWebEngineDownloadItem::DownloadState QWebEngineDownloadItem::state() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->downloadState;
-}
-
-/*!
- Returns the the total amount of data to download in bytes.
-
- \c -1 means the size is unknown.
-*/
-
-qint64 QWebEngineDownloadItem::totalBytes() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->totalBytes;
-}
-
-/*!
- Returns the amount of data in bytes that has been downloaded so far.
-
- \c -1 means the size is unknown.
-*/
-
-qint64 QWebEngineDownloadItem::receivedBytes() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->receivedBytes;
-}
-
-/*!
- Returns the download's origin URL.
-*/
-
-QUrl QWebEngineDownloadItem::url() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->downloadUrl;
-}
-
-/*!
- \since 5.6
-
- Returns the MIME type of the download.
-*/
-
-QString QWebEngineDownloadItem::mimeType() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->mimeType;
-}
-
-/*!
- \obsolete
-
- Use \l suggestedFileName(), \l downloadDirectory(), and
- \l downloadFileName() instead.
-
- Returns the full target path where data is being downloaded to.
-
- The path includes the file name. The default suggested path is the standard download location
- and file name is deduced not to overwrite already existing files.
-*/
-
-QString QWebEngineDownloadItem::path() const
-{
- Q_D(const QWebEngineDownloadItem);
- return QDir::cleanPath(QDir(d->downloadDirectory).filePath(d->downloadFileName));
-}
-
-/*!
- \obsolete
-
- Use \l setDownloadDirectory() and \l setDownloadFileName() instead.
-
- Sets the full target path to download the file to.
-
- The \a path should also include the file name. The download path can only be set in response
- to the QWebEngineProfile::downloadRequested() signal before the download is accepted.
- Past that point, this function has no effect on the download item's state.
-*/
-void QWebEngineDownloadItem::setPath(QString path)
-{
- Q_D(QWebEngineDownloadItem);
- if (d->downloadState != QWebEngineDownloadItem::DownloadRequested) {
- qWarning("Setting the download path is not allowed after the download has been accepted.");
- return;
- }
- if (QDir(d->downloadDirectory).filePath(d->downloadFileName) != path) {
- if (QFileInfo(path).fileName().isEmpty()) {
- qWarning("The download path does not include file name.");
- return;
- }
-
- if (QFileInfo(path).isDir()) {
- qWarning("The download path matches with an already existing directory path.");
- return;
- }
-
- if (QFileInfo(path).fileName() == path) {
- d->downloadDirectory = QStringLiteral("");
- d->downloadFileName = path;
- } else {
- d->downloadDirectory = QFileInfo(path).path();
- d->downloadFileName = QFileInfo(path).fileName();
- }
- }
-}
-
-/*!
- \since 5.14
-
- Returns the download directory path.
-*/
-
-QString QWebEngineDownloadItem::downloadDirectory() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->downloadDirectory;
-}
-
-/*!
- \since 5.14
-
- Sets \a directory as the directory path to download the file to.
-
- The download directory path can only be set in response to the QWebEngineProfile::downloadRequested()
- signal before the download is accepted. Past that point, this function has no effect on the
- download item's state.
-*/
-
-void QWebEngineDownloadItem::setDownloadDirectory(const QString &directory)
-{
- Q_D(QWebEngineDownloadItem);
- if (d->downloadState != QWebEngineDownloadItem::DownloadRequested) {
- qWarning("Setting the download directory is not allowed after the download has been accepted.");
- return;
- }
-
- if (!directory.isEmpty() && d->downloadDirectory != directory)
- d->downloadDirectory = directory;
-
- if (!d->isCustomFileName)
- d->downloadFileName = QFileInfo(d->profile->profileAdapter()->determineDownloadPath(d->downloadDirectory,
- d->suggestedFileName,
- d->startTime)).fileName();
-}
-
-/*!
- \since 5.14
-
- Returns the file name to download the file to.
-*/
-
-QString QWebEngineDownloadItem::downloadFileName() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->downloadFileName;
-}
-
-/*!
- \since 5.14
-
- Sets \a fileName as the file name to download the file to.
-
- The download file name can only be set in response to the QWebEngineProfile::downloadRequested()
- signal before the download is accepted. Past that point, this function has no effect on the
- download item's state.
-*/
-
-void QWebEngineDownloadItem::setDownloadFileName(const QString &fileName)
-{
- Q_D(QWebEngineDownloadItem);
- if (d->downloadState != QWebEngineDownloadItem::DownloadRequested) {
- qWarning("Setting the download file name is not allowed after the download has been accepted.");
- return;
- }
-
- if (!fileName.isEmpty()) {
- d->downloadFileName = fileName;
- d->isCustomFileName = true;
- }
-}
-
-/*!
- \since 5.14
-
- Returns the suggested file name.
-*/
-
-QString QWebEngineDownloadItem::suggestedFileName() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->suggestedFileName;
-}
-
-/*!
- Returns whether this download is finished (completed, cancelled, or non-resumable interrupted state).
-
- \sa finished(), state(),
-*/
-
-bool QWebEngineDownloadItem::isFinished() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->downloadFinished;
-}
-
-/*!
- Returns whether this download is paused.
-
- \sa pause(), resume()
-*/
-
-bool QWebEngineDownloadItem::isPaused() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->downloadPaused;
-}
-
-/*!
- Returns the format the web page will be saved in if this is a download request for a web page.
- \since 5.7
-
- \sa setSavePageFormat(), isSavePageDownload()
-*/
-QWebEngineDownloadItem::SavePageFormat QWebEngineDownloadItem::savePageFormat() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->savePageFormat;
-}
-
-/*!
- Sets the \a format the web page will be saved in if this is a download request for a web page.
- \since 5.7
-
- \sa savePageFormat(), isSavePageDownload()
-*/
-void QWebEngineDownloadItem::setSavePageFormat(QWebEngineDownloadItem::SavePageFormat format)
-{
- Q_D(QWebEngineDownloadItem);
- d->savePageFormat = format;
-}
-
-/*!
- Returns the requested download's type.
- \since 5.8
- \obsolete
-
- \note This property works unreliably, except for \c SavePage
- downloads. Use \l isSavePageDownload() instead.
- */
-
-QWebEngineDownloadItem::DownloadType QWebEngineDownloadItem::type() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->type;
-}
-
-/*!
- Returns \c true if this is a download request for saving a web page.
- \since 5.11
-
- \sa savePageFormat(), setSavePageFormat()
- */
-bool QWebEngineDownloadItem::isSavePageDownload() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->type == QWebEngineDownloadItem::SavePage;
-}
-
-/*!
- Returns the reason why the download was interrupted.
- \since 5.9
-
- \sa interruptReasonString()
-*/
-
-QWebEngineDownloadItem::DownloadInterruptReason QWebEngineDownloadItem::interruptReason() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->interruptReason;
-}
-
-/*!
- Returns a human-readable description of the reason for interrupting the download.
- \since 5.9
-
- \sa interruptReason()
-*/
-
-QString QWebEngineDownloadItem::interruptReasonString() const
-{
- return ProfileAdapterClient::downloadInterruptReasonToString(
- static_cast<ProfileAdapterClient::DownloadInterruptReason>(interruptReason()));
-}
-
-/*!
- \since 5.12
- Returns the page the download was requested on. If the download was not triggered by content in a page,
- \c nullptr is returned.
-*/
-QWebEnginePage *QWebEngineDownloadItem::page() const
-{
- Q_D(const QWebEngineDownloadItem);
- return d->page;
-}
-
-QWebEngineDownloadItem::QWebEngineDownloadItem(QWebEngineDownloadItemPrivate *p, QObject *parent)
- : QObject(parent)
- , d_ptr(p)
-{
- p->q_ptr = this;
-}
-
-/*! \internal
-*/
-QWebEngineDownloadItem::~QWebEngineDownloadItem()
-{
- // MEMO Items are owned by profile by default and will be destroyed on profile's destruction
- // It's not safe to access profile in that case, so we rely on profile to clean up items
- if (!isFinished())
- cancel();
-}
-
-QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h
deleted file mode 100644
index 094054079..000000000
--- a/src/webenginewidgets/api/qwebenginedownloaditem.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWEBENGINEDOWNLOADITEM_H
-#define QWEBENGINEDOWNLOADITEM_H
-
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_NAMESPACE
-
-class QWebEnginePage;
-class QWebEngineDownloadItemPrivate;
-class QWebEngineProfilePrivate;
-
-class QWEBENGINEWIDGETS_EXPORT QWebEngineDownloadItem : public QObject
-{
- Q_OBJECT
-public:
- ~QWebEngineDownloadItem();
-
- enum DownloadState {
- DownloadRequested,
- DownloadInProgress,
- DownloadCompleted,
- DownloadCancelled,
- DownloadInterrupted
- };
- Q_ENUM(DownloadState)
-
- enum SavePageFormat {
- UnknownSaveFormat = -1,
- SingleHtmlSaveFormat,
- CompleteHtmlSaveFormat,
- MimeHtmlSaveFormat
- };
- Q_ENUM(SavePageFormat)
-
- enum DownloadInterruptReason {
- NoReason = 0,
- FileFailed = 1,
- FileAccessDenied = 2,
- FileNoSpace = 3,
- FileNameTooLong = 5,
- FileTooLarge = 6,
- FileVirusInfected = 7,
- FileTransientError = 10,
- FileBlocked = 11,
- FileSecurityCheckFailed = 12,
- FileTooShort = 13,
- FileHashMismatch = 14,
- NetworkFailed = 20,
- NetworkTimeout = 21,
- NetworkDisconnected = 22,
- NetworkServerDown = 23,
- NetworkInvalidRequest = 24,
- ServerFailed = 30,
- //ServerNoRange = 31,
- ServerBadContent = 33,
- ServerUnauthorized = 34,
- ServerCertProblem = 35,
- ServerForbidden = 36,
- ServerUnreachable = 37,
- UserCanceled = 40,
- //UserShutdown = 41,
- //Crash = 50
- };
- Q_ENUM(DownloadInterruptReason)
-
- enum DownloadType {
- Attachment = 0,
- DownloadAttribute,
- UserRequested,
- SavePage
- };
- Q_ENUM(DownloadType)
-
- quint32 id() const;
- DownloadState state() const;
- qint64 totalBytes() const;
- qint64 receivedBytes() const;
- QUrl url() const;
- QString mimeType() const;
-#if QT_DEPRECATED_SINCE(5, 14)
-#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
- QT_DEPRECATED_VERSION_X(5, 14, "Use downloadDirectory() and downloadFileName() instead")
- QString path() const;
- QT_DEPRECATED_VERSION_X(5, 14, "Use setDownloadDirectory() and setDownloadFileName() instead")
- void setPath(QString path);
-#else
- QT_DEPRECATED_X("Use downloadDirectory() and downloadFileName() instead")
- QString path() const;
- QT_DEPRECATED_X("Use setDownloadDirectory() and setDownloadFileName() instead")
- void setPath(QString path);
-#endif
-#endif
- bool isFinished() const;
- bool isPaused() const;
- SavePageFormat savePageFormat() const;
- void setSavePageFormat(SavePageFormat format);
- DownloadType Q_DECL_DEPRECATED type() const;
- DownloadInterruptReason interruptReason() const;
- QString interruptReasonString() const;
- bool isSavePageDownload() const;
- QString suggestedFileName() const;
- QString downloadDirectory() const;
- void setDownloadDirectory(const QString &directory);
- QString downloadFileName() const;
- void setDownloadFileName(const QString &fileName);
-
- QWebEnginePage *page() const;
-
-public Q_SLOTS:
- void accept();
- void cancel();
- void pause();
- void resume();
-
-Q_SIGNALS:
- void finished();
- void stateChanged(QWebEngineDownloadItem::DownloadState state);
- void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
- void isPausedChanged(bool isPaused);
-
-private:
- Q_DISABLE_COPY(QWebEngineDownloadItem)
- Q_DECLARE_PRIVATE(QWebEngineDownloadItem)
-
- friend class QWebEngineProfilePrivate;
-
- QWebEngineDownloadItem(QWebEngineDownloadItemPrivate*, QObject *parent = Q_NULLPTR);
- QScopedPointer<QWebEngineDownloadItemPrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINEDOWNLOADITEM_H
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem_p.h b/src/webenginewidgets/api/qwebenginedownloaditem_p.h
deleted file mode 100644
index 04c6fadcc..000000000
--- a/src/webenginewidgets/api/qwebenginedownloaditem_p.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWEBENGINEDOWNLOADITEM_P_H
-#define QWEBENGINEDOWNLOADITEM_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qtwebenginewidgetsglobal.h"
-
-#include "qwebenginedownloaditem.h"
-#include "qwebengineprofile_p.h"
-#include <QString>
-
-QT_BEGIN_NAMESPACE
-
-class QWebEngineDownloadItemPrivate {
- QWebEngineDownloadItem *q_ptr;
- QWebEngineProfilePrivate* profile;
- friend class QWebEngineProfilePrivate;
-public:
- Q_DECLARE_PUBLIC(QWebEngineDownloadItem)
- QWebEngineDownloadItemPrivate(QWebEngineProfilePrivate *p, const QUrl &url);
- ~QWebEngineDownloadItemPrivate();
-
- bool downloadFinished;
- quint32 downloadId;
- qint64 startTime;
- QWebEngineDownloadItem::DownloadState downloadState;
- QWebEngineDownloadItem::SavePageFormat savePageFormat;
- QWebEngineDownloadItem::DownloadType type;
- QWebEngineDownloadItem::DownloadInterruptReason interruptReason;
- QString downloadPath;
- const QUrl downloadUrl;
- QString mimeType;
- bool downloadPaused;
- QString suggestedFileName;
- QString downloadDirectory;
- QString downloadFileName;
- bool isCustomFileName;
-
- qint64 totalBytes;
- qint64 receivedBytes;
- QWebEnginePage *page;
-
- void update(const QtWebEngineCore::ProfileAdapterClient::DownloadItemInfo &info);
-
- void setFinished();
-};
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINEDOWNLOADITEM_P_H
-
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 6fb3c5c43..f177f8d23 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -42,7 +42,6 @@
#include "authentication_dialog_controller.h"
#include "profile_adapter.h"
-#include "certificate_error_controller.h"
#include "color_chooser_controller.h"
#include "favicon_manager.h"
#include "find_text_helper.h"
@@ -278,7 +277,7 @@ void QWebEnginePagePrivate::loadStarted(const QUrl &provisionalUrl, bool isError
return;
isLoading = true;
- m_certificateErrorControllers.clear();
+
QTimer::singleShot(0, q, &QWebEnginePage::loadStarted);
}
@@ -548,7 +547,7 @@ QObject *QWebEnginePagePrivate::accessibilityParentObject()
void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const
{
#ifdef QT_NO_ACTION
- Q_UNUSED(action)
+ Q_UNUSED(action);
#else
QAction *a = actions[action];
if (!a)
@@ -1041,8 +1040,8 @@ void QWebEnginePage::setWebChannel(QWebChannel *channel, uint worldId)
d->adapter->setWebChannel(channel, worldId);
}
#else
- Q_UNUSED(channel)
- Q_UNUSED(worldId)
+ Q_UNUSED(channel);
+ Q_UNUSED(worldId);
qWarning("WebEngine compiled without webchannel support");
#endif
}
@@ -1087,11 +1086,11 @@ void QWebEnginePage::setBackgroundColor(const QColor &color)
*
* This function issues an asynchronous download request for the web page and returns immediately.
*
- * \sa QWebEngineDownloadItem::SavePageFormat
+ * \sa QWebEngineDownloadRequest::SavePageFormat
* \since 5.8
*/
void QWebEnginePage::save(const QString &filePath,
- QWebEngineDownloadItem::SavePageFormat format) const
+ QWebEngineDownloadRequest::SavePageFormat format) const
{
Q_D(const QWebEnginePage);
d->ensureInitialized();
@@ -1360,7 +1359,6 @@ void QWebEnginePage::triggerAction(WebAction action, bool)
{
Q_D(QWebEnginePage);
d->ensureInitialized();
- const QtWebEngineCore::WebEngineContextMenuData *menuData = d->contextData.d;
switch (action) {
case Back:
d->adapter->navigateBack();
@@ -1402,35 +1400,36 @@ void QWebEnginePage::triggerAction(WebAction action, bool)
d->adapter->unselect();
break;
case OpenLinkInThisWindow:
- if (menuData && menuData->linkUrl().isValid())
- setUrl(menuData->linkUrl());
+ if (d->view && d->view->lastContextMenuRequest()->filteredLinkUrl().isValid())
+ setUrl(d->view->lastContextMenuRequest()->filteredLinkUrl());
break;
case OpenLinkInNewWindow:
- if (menuData && menuData->linkUrl().isValid()) {
+ if (d->view && d->view->lastContextMenuRequest()->filteredLinkUrl().isValid()) {
QWebEnginePage *newPage = createWindow(WebBrowserWindow);
if (newPage)
- newPage->setUrl(menuData->linkUrl());
+ newPage->setUrl(d->view->lastContextMenuRequest()->filteredLinkUrl());
}
break;
case OpenLinkInNewTab:
- if (menuData && menuData->linkUrl().isValid()) {
+ if (d->view && d->view->lastContextMenuRequest()->filteredLinkUrl().isValid()) {
QWebEnginePage *newPage = createWindow(WebBrowserTab);
if (newPage)
- newPage->setUrl(menuData->linkUrl());
+ newPage->setUrl(d->view->lastContextMenuRequest()->filteredLinkUrl());
}
break;
case OpenLinkInNewBackgroundTab:
- if (menuData && menuData->linkUrl().isValid()) {
+ if (d->view && d->view->lastContextMenuRequest()->filteredLinkUrl().isValid()) {
QWebEnginePage *newPage = createWindow(WebBrowserBackgroundTab);
if (newPage)
- newPage->setUrl(menuData->linkUrl());
+ newPage->setUrl(d->view->lastContextMenuRequest()->filteredLinkUrl());
}
break;
case CopyLinkToClipboard:
- if (menuData && !menuData->unfilteredLinkUrl().isEmpty()) {
- QString urlString = menuData->unfilteredLinkUrl().toString(QUrl::FullyEncoded);
- QString linkText = menuData->linkText().toHtmlEscaped();
- QString title = menuData->titleText();
+ if (d->view && !d->view->lastContextMenuRequest()->linkUrl().isEmpty()) {
+ QString urlString = d->view->lastContextMenuRequest()->linkUrl().toString(
+ QUrl::FullyEncoded);
+ QString linkText = d->view->lastContextMenuRequest()->linkText().toHtmlEscaped();
+ QString title = d->view->lastContextMenuRequest()->titleText();
if (!title.isEmpty())
title = QStringLiteral(" title=\"%1\"").arg(title.toHtmlEscaped());
QMimeData *data = new QMimeData();
@@ -1438,102 +1437,127 @@ void QWebEnginePage::triggerAction(WebAction action, bool)
QString html = QStringLiteral("<a href=\"") + urlString + QStringLiteral("\"") + title + QStringLiteral(">")
+ linkText + QStringLiteral("</a>");
data->setHtml(html);
- data->setUrls(QList<QUrl>() << menuData->unfilteredLinkUrl());
+ data->setUrls(QList<QUrl>() << d->view->lastContextMenuRequest()->linkUrl());
qApp->clipboard()->setMimeData(data);
}
break;
case DownloadLinkToDisk:
- if (menuData && menuData->linkUrl().isValid())
- d->adapter->download(menuData->linkUrl(), menuData->suggestedFileName(),
- menuData->referrerUrl(), menuData->referrerPolicy());
+ if (d->view && d->view->lastContextMenuRequest()->filteredLinkUrl().isValid())
+ d->adapter->download(d->view->lastContextMenuRequest()->filteredLinkUrl(),
+ d->view->lastContextMenuRequest()->suggestedFileName(),
+ d->view->lastContextMenuRequest()->referrerUrl(),
+ d->view->lastContextMenuRequest()->referrerPolicy());
break;
case CopyImageToClipboard:
- if (menuData && menuData->hasImageContent() &&
- (menuData->mediaType() == WebEngineContextMenuData::MediaTypeImage ||
- menuData->mediaType() == WebEngineContextMenuData::MediaTypeCanvas))
- {
- d->adapter->copyImageAt(menuData->position());
+ if (d->view && d->view->lastContextMenuRequest()->hasImageContent()
+ && (d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeImage
+ || d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeCanvas)) {
+ d->adapter->copyImageAt(d->view->lastContextMenuRequest()->position());
}
break;
case CopyImageUrlToClipboard:
- if (menuData && menuData->mediaUrl().isValid() && menuData->mediaType() == WebEngineContextMenuData::MediaTypeImage) {
- QString urlString = menuData->mediaUrl().toString(QUrl::FullyEncoded);
- QString alt = menuData->altText();
+ if (d->view && d->view->lastContextMenuRequest()->mediaUrl().isValid()
+ && d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeImage) {
+ QString urlString =
+ d->view->lastContextMenuRequest()->mediaUrl().toString(QUrl::FullyEncoded);
+ QString alt = d->view->lastContextMenuRequest()->altText();
if (!alt.isEmpty())
alt = QStringLiteral(" alt=\"%1\"").arg(alt.toHtmlEscaped());
- QString title = menuData->titleText();
+ QString title = d->view->lastContextMenuRequest()->titleText();
if (!title.isEmpty())
title = QStringLiteral(" title=\"%1\"").arg(title.toHtmlEscaped());
QMimeData *data = new QMimeData();
data->setText(urlString);
QString html = QStringLiteral("<img src=\"") + urlString + QStringLiteral("\"") + title + alt + QStringLiteral("></img>");
data->setHtml(html);
- data->setUrls(QList<QUrl>() << menuData->mediaUrl());
+ data->setUrls(QList<QUrl>() << d->view->lastContextMenuRequest()->mediaUrl());
qApp->clipboard()->setMimeData(data);
}
break;
case DownloadImageToDisk:
case DownloadMediaToDisk:
- if (menuData && menuData->mediaUrl().isValid())
- d->adapter->download(menuData->mediaUrl(), menuData->suggestedFileName(),
- menuData->referrerUrl(), menuData->referrerPolicy());
+ if (d->view && d->view->lastContextMenuRequest()->mediaUrl().isValid())
+ d->adapter->download(d->view->lastContextMenuRequest()->mediaUrl(),
+ d->view->lastContextMenuRequest()->suggestedFileName(),
+ d->view->lastContextMenuRequest()->referrerUrl(),
+ d->view->lastContextMenuRequest()->referrerPolicy());
break;
case CopyMediaUrlToClipboard:
- if (menuData && menuData->mediaUrl().isValid() &&
- (menuData->mediaType() == WebEngineContextMenuData::MediaTypeAudio ||
- menuData->mediaType() == WebEngineContextMenuData::MediaTypeVideo))
- {
- QString urlString = menuData->mediaUrl().toString(QUrl::FullyEncoded);
- QString title = menuData->titleText();
+ if (d->view && d->view->lastContextMenuRequest()->mediaUrl().isValid()
+ && (d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeAudio
+ || d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeVideo)) {
+ QString urlString =
+ d->view->lastContextMenuRequest()->mediaUrl().toString(QUrl::FullyEncoded);
+ QString title = d->view->lastContextMenuRequest()->titleText();
if (!title.isEmpty())
title = QStringLiteral(" title=\"%1\"").arg(title.toHtmlEscaped());
QMimeData *data = new QMimeData();
data->setText(urlString);
- if (menuData->mediaType() == WebEngineContextMenuData::MediaTypeAudio)
+ if (d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeAudio)
data->setHtml(QStringLiteral("<audio src=\"") + urlString + QStringLiteral("\"") + title +
QStringLiteral("></audio>"));
else
data->setHtml(QStringLiteral("<video src=\"") + urlString + QStringLiteral("\"") + title +
QStringLiteral("></video>"));
- data->setUrls(QList<QUrl>() << menuData->mediaUrl());
+ data->setUrls(QList<QUrl>() << d->view->lastContextMenuRequest()->mediaUrl());
qApp->clipboard()->setMimeData(data);
}
break;
case ToggleMediaControls:
- if (menuData && menuData->mediaUrl().isValid() && menuData->mediaFlags() & WebEngineContextMenuData::MediaCanToggleControls) {
- bool enable = !(menuData->mediaFlags() & WebEngineContextMenuData::MediaControls);
- d->adapter->executeMediaPlayerActionAt(menuData->position(), WebContentsAdapter::MediaPlayerControls, enable);
+ if (d->view && d->view->lastContextMenuRequest()->mediaUrl().isValid()
+ && d->view->lastContextMenuRequest()->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaCanToggleControls) {
+ bool enable = !(d->view->lastContextMenuRequest()->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaControls);
+ d->adapter->executeMediaPlayerActionAt(d->view->lastContextMenuRequest()->position(),
+ WebContentsAdapter::MediaPlayerControls, enable);
}
break;
case ToggleMediaLoop:
- if (menuData && menuData->mediaUrl().isValid() &&
- (menuData->mediaType() == WebEngineContextMenuData::MediaTypeAudio ||
- menuData->mediaType() == WebEngineContextMenuData::MediaTypeVideo))
- {
- bool enable = !(menuData->mediaFlags() & WebEngineContextMenuData::MediaLoop);
- d->adapter->executeMediaPlayerActionAt(menuData->position(), WebContentsAdapter::MediaPlayerLoop, enable);
+ if (d->view && d->view->lastContextMenuRequest()->mediaUrl().isValid()
+ && (d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeAudio
+ || d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeVideo)) {
+ bool enable = !(d->view->lastContextMenuRequest()->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaLoop);
+ d->adapter->executeMediaPlayerActionAt(d->view->lastContextMenuRequest()->position(),
+ WebContentsAdapter::MediaPlayerLoop, enable);
}
break;
case ToggleMediaPlayPause:
- if (menuData && menuData->mediaUrl().isValid() &&
- (menuData->mediaType() == WebEngineContextMenuData::MediaTypeAudio ||
- menuData->mediaType() == WebEngineContextMenuData::MediaTypeVideo))
- {
- bool enable = (menuData->mediaFlags() & WebEngineContextMenuData::MediaPaused);
- d->adapter->executeMediaPlayerActionAt(menuData->position(), WebContentsAdapter::MediaPlayerPlay, enable);
+ if (d->view && d->view->lastContextMenuRequest()->mediaUrl().isValid()
+ && (d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeAudio
+ || d->view->lastContextMenuRequest()->mediaType()
+ == QWebEngineContextMenuRequest::MediaTypeVideo)) {
+ bool enable = (d->view->lastContextMenuRequest()->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaPaused);
+ d->adapter->executeMediaPlayerActionAt(d->view->lastContextMenuRequest()->position(),
+ WebContentsAdapter::MediaPlayerPlay, enable);
}
break;
case ToggleMediaMute:
- if (menuData && menuData->mediaUrl().isValid() && menuData->mediaFlags() & WebEngineContextMenuData::MediaHasAudio) {
+ if (d->view && d->view->lastContextMenuRequest()->mediaUrl().isValid()
+ && d->view->lastContextMenuRequest()->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaHasAudio) {
// Make sure to negate the value, so that toggling actually works.
- bool enable = !(menuData->mediaFlags() & WebEngineContextMenuData::MediaMuted);
- d->adapter->executeMediaPlayerActionAt(menuData->position(), WebContentsAdapter::MediaPlayerMute, enable);
+ bool enable = !(d->view->lastContextMenuRequest()->mediaFlags()
+ & QWebEngineContextMenuRequest::MediaMuted);
+ d->adapter->executeMediaPlayerActionAt(d->view->lastContextMenuRequest()->position(),
+ WebContentsAdapter::MediaPlayerMute, enable);
}
break;
case InspectElement:
- if (menuData)
- d->adapter->inspectElementAt(menuData->position());
+ if (d->view)
+ d->adapter->inspectElementAt(d->view->lastContextMenuRequest()->position());
break;
case ExitFullScreen:
// See under ViewSource, anything that can trigger a delete of the current view is dangerous to call directly here.
@@ -1604,8 +1628,8 @@ void QWebEnginePage::triggerAction(WebAction action, bool)
* \since 5.8
* Replace the current misspelled word with \a replacement.
*
- * The current misspelled word can be found in QWebEngineContextMenuData::misspelledWord(),
- * and suggested replacements in QWebEngineContextMenuData::spellCheckerSuggestions().
+ * The current misspelled word can be found in QWebEngineContextMenuRequest::misspelledWord(),
+ * and suggested replacements in QWebEngineContextMenuRequest::spellCheckerSuggestions().
*
* \sa contextMenuData(),
*/
@@ -1635,40 +1659,10 @@ bool QWebEnginePage::event(QEvent *e)
return QObject::event(e);
}
-void QWebEnginePagePrivate::contextMenuRequested(const WebEngineContextMenuData &data)
+void QWebEnginePagePrivate::contextMenuRequested(QWebEngineContextMenuRequest *data)
{
-#if QT_CONFIG(action)
- if (!view)
- return;
-
- contextData.reset();
- switch (view->contextMenuPolicy()) {
- case Qt::DefaultContextMenu:
- {
- contextData = data;
- QContextMenuEvent event(QContextMenuEvent::Mouse, data.position(), view->mapToGlobal(data.position()));
- view->contextMenuEvent(&event);
- return;
- }
- case Qt::CustomContextMenu:
- contextData = data;
- Q_EMIT view->customContextMenuRequested(data.position());
- return;
- case Qt::ActionsContextMenu:
- if (view->actions().count()) {
- QContextMenuEvent event(QContextMenuEvent::Mouse, data.position(), view->mapToGlobal(data.position()));
- QMenu::exec(view->actions(), event.globalPos(), 0, view);
- }
- return;
- case Qt::PreventContextMenu:
- case Qt::NoContextMenu:
- return;
- }
-
- Q_UNREACHABLE();
-#else
- Q_UNUSED(data);
-#endif // QT_CONFIG(action)
+ if (view)
+ view->d_ptr->contextMenuRequested(data);
}
void QWebEnginePagePrivate::navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame)
@@ -1725,32 +1719,20 @@ void QWebEnginePagePrivate::javascriptDialog(QSharedPointer<JavaScriptDialogCont
controller->reject();
}
-void QWebEnginePagePrivate::allowCertificateError(const QSharedPointer<CertificateErrorController> &controller)
+void QWebEnginePagePrivate::allowCertificateError(const QWebEngineCertificateError &error)
{
Q_Q(QWebEnginePage);
- bool accepted = false;
-
- QWebEngineCertificateError error(controller);
- accepted = q->certificateError(error);
- if (error.deferred() && !error.answered())
- m_certificateErrorControllers.append(controller);
- else if (!error.answered())
- controller->accept(error.isOverridable() && accepted);
+ q->certificateError(error);
}
void QWebEnginePagePrivate::selectClientCert(const QSharedPointer<ClientCertSelectController> &controller)
{
-#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
Q_Q(QWebEnginePage);
QWebEngineClientCertificateSelection certSelection(controller);
Q_EMIT q->selectClientCertificate(certSelection);
-#else
- Q_UNUSED(controller);
-#endif
}
-#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
/*!
\fn void QWebEnginePage::selectClientCertificate(QWebEngineClientCertificateSelection clientCertificateSelection)
\since 5.12
@@ -1766,7 +1748,6 @@ void QWebEnginePagePrivate::selectClientCert(const QSharedPointer<ClientCertSele
\sa QWebEngineClientCertificateSelection
*/
-#endif
void QWebEnginePagePrivate::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID)
{
@@ -1886,27 +1867,6 @@ void QWebEnginePage::setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *i
d->adapter->setRequestInterceptor(interceptor);
}
-#if QT_CONFIG(menu)
-QMenu *QWebEnginePage::createStandardContextMenu()
-{
- Q_D(QWebEnginePage);
- if (!d->contextData.d)
- return nullptr;
- d->ensureInitialized();
-
- QMenu *menu = new QMenu(d->view);
- const WebEngineContextMenuData &contextMenuData = *d->contextData.d;
-
- QContextMenuBuilder contextMenuBuilder(contextMenuData, this, menu);
-
- contextMenuBuilder.initMenu();
-
- menu->setAttribute(Qt::WA_DeleteOnClose, true);
-
- return menu;
-}
-#endif // QT_CONFIG(menu)
-
void QWebEnginePage::setFeaturePermission(const QUrl &securityOrigin, QWebEnginePage::Feature feature, QWebEnginePage::PermissionPolicy policy)
{
Q_D(QWebEnginePage);
@@ -2003,9 +1963,9 @@ void QWebEnginePagePrivate::runFileChooser(QSharedPointer<FilePickerController>
controller->rejected();
}
-WebEngineSettings *QWebEnginePagePrivate::webEngineSettings() const
+QWebEngineSettings *QWebEnginePagePrivate::webEngineSettings() const
{
- return settings->d_func();
+ return settings;
}
/*!
@@ -2416,10 +2376,7 @@ void QWebEnginePage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel leve
}
}
-bool QWebEnginePage::certificateError(const QWebEngineCertificateError &)
-{
- return false;
-}
+void QWebEnginePage::certificateError(QWebEngineCertificateError) { }
bool QWebEnginePage::acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame)
{
@@ -2545,19 +2502,6 @@ void QWebEnginePage::print(QPrinter *printer, const QWebEngineCallback<bool> &re
#endif
}
-/*!
- \since 5.7
-
- Returns additional data about the current context menu. It is only guaranteed to be valid during the call to the QWebEngineView::contextMenuEvent()
- handler of the associated QWebEngineView.
-
- \sa createStandardContextMenu()
-*/
-const QWebEngineContextMenuData &QWebEnginePage::contextMenuData() const
-{
- Q_D(const QWebEnginePage);
- return d->contextData;
-}
/*!
\enum QWebEnginePage::LifecycleState
@@ -2673,173 +2617,6 @@ void QWebEnginePage::setVisible(bool visible)
d->adapter->setVisible(visible);
}
-#if QT_CONFIG(action)
-QContextMenuBuilder::QContextMenuBuilder(const QtWebEngineCore::WebEngineContextMenuData &data,
- QWebEnginePage *page,
- QMenu *menu)
- : QtWebEngineCore::RenderViewContextMenuQt(data)
- , m_page(page)
- , m_menu(menu)
-{
-}
-
-bool QContextMenuBuilder::hasInspector()
-{
- return m_page->d_ptr->adapter->hasInspector();
-}
-
-bool QContextMenuBuilder::isFullScreenMode()
-{
- return m_page->d_ptr->isFullScreenMode();
-}
-
-void QContextMenuBuilder::addMenuItem(ContextMenuItem menuItem)
-{
- QPointer<QWebEnginePage> thisRef(m_page);
- QAction *action = 0;
-
- switch (menuItem) {
- case ContextMenuItem::Back:
- action = thisRef->action(QWebEnginePage::Back);
- break;
- case ContextMenuItem::Forward:
- action = thisRef->action(QWebEnginePage::Forward);
- break;
- case ContextMenuItem::Reload:
- action = thisRef->action(QWebEnginePage::Reload);
- break;
- case ContextMenuItem::Cut:
- action = thisRef->action(QWebEnginePage::Cut);
- break;
- case ContextMenuItem::Copy:
- action = thisRef->action(QWebEnginePage::Copy);
- break;
- case ContextMenuItem::Paste:
- action = thisRef->action(QWebEnginePage::Paste);
- break;
- case ContextMenuItem::Undo:
- action = thisRef->action(QWebEnginePage::Undo);
- break;
- case ContextMenuItem::Redo:
- action = thisRef->action(QWebEnginePage::Redo);
- break;
- case ContextMenuItem::SelectAll:
- action = thisRef->action(QWebEnginePage::SelectAll);
- break;
- case ContextMenuItem::PasteAndMatchStyle:
- action = thisRef->action(QWebEnginePage::PasteAndMatchStyle);
- break;
- case ContextMenuItem::OpenLinkInNewWindow:
- action = thisRef->action(QWebEnginePage::OpenLinkInNewWindow);
- break;
- case ContextMenuItem::OpenLinkInNewTab:
- action = thisRef->action(QWebEnginePage::OpenLinkInNewTab);
- break;
- case ContextMenuItem::CopyLinkToClipboard:
- action = thisRef->action(QWebEnginePage::CopyLinkToClipboard);
- break;
- case ContextMenuItem::DownloadLinkToDisk:
- action = thisRef->action(QWebEnginePage::DownloadLinkToDisk);
- break;
- case ContextMenuItem::CopyImageToClipboard:
- action = thisRef->action(QWebEnginePage::CopyImageToClipboard);
- break;
- case ContextMenuItem::CopyImageUrlToClipboard:
- action = thisRef->action(QWebEnginePage::CopyImageUrlToClipboard);
- break;
- case ContextMenuItem::DownloadImageToDisk:
- action = thisRef->action(QWebEnginePage::DownloadImageToDisk);
- break;
- case ContextMenuItem::CopyMediaUrlToClipboard:
- action = thisRef->action(QWebEnginePage::CopyMediaUrlToClipboard);
- break;
- case ContextMenuItem::ToggleMediaControls:
- action = thisRef->action(QWebEnginePage::ToggleMediaControls);
- break;
- case ContextMenuItem::ToggleMediaLoop:
- action = thisRef->action(QWebEnginePage::ToggleMediaLoop);
- break;
- case ContextMenuItem::DownloadMediaToDisk:
- action = thisRef->action(QWebEnginePage::DownloadMediaToDisk);
- break;
- case ContextMenuItem::InspectElement:
- action = thisRef->action(QWebEnginePage::InspectElement);
- break;
- case ContextMenuItem::ExitFullScreen:
- action = thisRef->action(QWebEnginePage::ExitFullScreen);
- break;
- case ContextMenuItem::SavePage:
- action = thisRef->action(QWebEnginePage::SavePage);
- break;
- case ContextMenuItem::ViewSource:
- action = thisRef->action(QWebEnginePage::ViewSource);
- break;
- case ContextMenuItem::SpellingSuggestions:
- for (int i=0; i < m_contextData.spellCheckerSuggestions().count() && i < 4; i++) {
- action = new QAction(m_menu);
- QString replacement = m_contextData.spellCheckerSuggestions().at(i);
- QObject::connect(action, &QAction::triggered, [thisRef, replacement] { if (thisRef) thisRef->replaceMisspelledWord(replacement); });
- action->setText(replacement);
- m_menu->addAction(action);
- }
- return;
- case ContextMenuItem::Separator:
- if (!m_menu->isEmpty())
- m_menu->addSeparator();
- return;
- }
- action->setEnabled(isMenuItemEnabled(menuItem));
- m_menu->addAction(action);
-}
-
-bool QContextMenuBuilder::isMenuItemEnabled(ContextMenuItem menuItem)
-{
- switch (menuItem) {
- case ContextMenuItem::Back:
- return m_page->d_ptr->adapter->canGoBack();
- case ContextMenuItem::Forward:
- return m_page->d_ptr->adapter->canGoForward();
- case ContextMenuItem::Reload:
- return true;
- case ContextMenuItem::Cut:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanCut;
- case ContextMenuItem::Copy:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanCopy;
- case ContextMenuItem::Paste:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanPaste;
- case ContextMenuItem::Undo:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanUndo;
- case ContextMenuItem::Redo:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanRedo;
- case ContextMenuItem::SelectAll:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanSelectAll;
- case ContextMenuItem::PasteAndMatchStyle:
- return m_contextData.editFlags() & QtWebEngineCore::WebEngineContextMenuData::CanPaste;
- case ContextMenuItem::OpenLinkInNewWindow:
- case ContextMenuItem::OpenLinkInNewTab:
- case ContextMenuItem::CopyLinkToClipboard:
- case ContextMenuItem::DownloadLinkToDisk:
- case ContextMenuItem::CopyImageToClipboard:
- case ContextMenuItem::CopyImageUrlToClipboard:
- case ContextMenuItem::DownloadImageToDisk:
- case ContextMenuItem::CopyMediaUrlToClipboard:
- case ContextMenuItem::ToggleMediaControls:
- case ContextMenuItem::ToggleMediaLoop:
- case ContextMenuItem::DownloadMediaToDisk:
- case ContextMenuItem::InspectElement:
- case ContextMenuItem::ExitFullScreen:
- case ContextMenuItem::SavePage:
- return true;
- case ContextMenuItem::ViewSource:
- return m_page->d_ptr->adapter->canViewSource();
- case ContextMenuItem::SpellingSuggestions:
- case ContextMenuItem::Separator:
- return true;
- }
- Q_UNREACHABLE();
-}
-#endif // QT_CONFIG(action)
-
QT_END_NAMESPACE
#include "moc_qwebenginepage.cpp"
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index 3bf79526d..5ac30863f 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -42,7 +42,7 @@
#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
#include <QtWebEngineWidgets/qwebengineclientcertificateselection.h>
-#include <QtWebEngineWidgets/qwebenginedownloaditem.h>
+#include <QtWebEngineCore/qwebenginedownloadrequest.h>
#include <QtWebEngineCore/qwebenginecallback.h>
#include <QtWebEngineCore/qwebenginehttprequest.h>
@@ -61,7 +61,6 @@ class QContextMenuBuilder;
class QWebChannel;
class QWebEngineCertificateError;
class QWebEngineClientCertificateSelection;
-class QWebEngineContextMenuData;
class QWebEngineFindTextResult;
class QWebEngineFullScreenRequest;
class QWebEngineHistory;
@@ -259,10 +258,6 @@ public:
void findText(const QString &subString, FindFlags options = FindFlags(), const QWebEngineCallback<bool> &resultCallback = QWebEngineCallback<bool>());
-#if QT_CONFIG(menu)
- QMenu *createStandardContextMenu();
-#endif
-
void setFeaturePermission(const QUrl &securityOrigin, Feature feature, PermissionPolicy policy);
void load(const QUrl &url);
@@ -300,8 +295,8 @@ public:
QColor backgroundColor() const;
void setBackgroundColor(const QColor &color);
- void save(const QString &filePath, QWebEngineDownloadItem::SavePageFormat format
- = QWebEngineDownloadItem::MimeHtmlSaveFormat) const;
+ void save(const QString &filePath, QWebEngineDownloadRequest::SavePageFormat format
+ = QWebEngineDownloadRequest::MimeHtmlSaveFormat) const;
bool isAudioMuted() const;
void setAudioMuted(bool muted);
@@ -319,8 +314,6 @@ public:
void setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor);
- const QWebEngineContextMenuData &contextMenuData() const;
-
LifecycleState lifecycleState() const;
void setLifecycleState(LifecycleState state);
@@ -344,10 +337,7 @@ Q_SIGNALS:
void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest);
void quotaRequested(QWebEngineQuotaRequest quotaRequest);
void registerProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest request);
-#if !defined(QT_NO_SSL) || QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)
void selectClientCertificate(QWebEngineClientCertificateSelection clientCertSelection);
-#endif
-
void authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator);
void proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost);
@@ -382,7 +372,7 @@ protected:
virtual bool javaScriptConfirm(const QUrl &securityOrigin, const QString& msg);
virtual bool javaScriptPrompt(const QUrl &securityOrigin, const QString& msg, const QString& defaultValue, QString* result);
virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID);
- virtual bool certificateError(const QWebEngineCertificateError &certificateError);
+ virtual void certificateError(QWebEngineCertificateError certificateError);
virtual bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame);
private:
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 3ddf4b3d6..eb021bf6d 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -54,9 +54,7 @@
#include "qwebenginepage.h"
#include "qwebenginecallback_p.h"
-#include "qwebenginecontextmenudata.h"
#include "qwebenginescriptcollection.h"
-#include "render_view_context_menu_qt.h"
#include "web_contents_adapter_client.h"
#include <QtCore/qcompilerdetection.h>
@@ -106,7 +104,7 @@ public:
QColor backgroundColor() const override;
void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) override;
void loadCommitted() override { }
- void loadVisuallyCommitted() override { }
+ void didFirstVisuallyNonEmptyPaint() override { }
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;
@@ -117,7 +115,7 @@ public:
bool isBeingAdopted() override;
void close() override;
void windowCloseRejected() override;
- void contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &data) override;
+ void contextMenuRequested(QWebEngineContextMenuRequest *request) override;
void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) override;
void requestFullScreenMode(const QUrl &origin, bool fullscreen) override;
bool isFullScreenMode() const override;
@@ -139,9 +137,10 @@ public:
void runQuotaRequest(QWebEngineQuotaRequest) override;
void runRegisterProtocolHandlerRequest(QWebEngineRegisterProtocolHandlerRequest) override;
QObject *accessibilityParentObject() override;
- QtWebEngineCore::WebEngineSettings *webEngineSettings() const override;
- void allowCertificateError(const QSharedPointer<CertificateErrorController> &controller) override;
- void selectClientCert(const QSharedPointer<ClientCertSelectController> &controller) override;
+ QWebEngineSettings *webEngineSettings() const override;
+ void allowCertificateError(const QWebEngineCertificateError &error) override;
+ void selectClientCert(
+ const QSharedPointer<QtWebEngineCore::ClientCertSelectController> &controller) override;
void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode) override;
void requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) override;
void updateScrollPosition(const QPointF &position) override;
@@ -184,7 +183,6 @@ public:
QWebEngineSettings *settings;
QWebEngineView *view;
QUrl url;
- QWebEngineContextMenuData contextData;
bool isLoading;
QWebEngineScriptCollection scriptCollection;
bool m_isBeingAdopted;
@@ -206,24 +204,6 @@ public:
#if QT_CONFIG(webengine_printing_and_pdf)
QPrinter *currentPrinter;
#endif
-
- QList<QSharedPointer<CertificateErrorController>> m_certificateErrorControllers;
-};
-
-class QContextMenuBuilder : public QtWebEngineCore::RenderViewContextMenuQt
-{
-public:
- QContextMenuBuilder(const QtWebEngineCore::WebEngineContextMenuData &data, QWebEnginePage *page, QMenu *menu);
-
-private:
- virtual bool hasInspector() override;
- virtual bool isFullScreenMode() override;
-
- virtual void addMenuItem(ContextMenuItem entry) override;
- virtual bool isMenuItemEnabled(ContextMenuItem entry) override;
-
- QWebEnginePage *m_page;
- QMenu *m_menu;
};
QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp
index 4c49be709..7aa168a6f 100644
--- a/src/webenginewidgets/api/qwebengineprofile.cpp
+++ b/src/webenginewidgets/api/qwebengineprofile.cpp
@@ -41,8 +41,8 @@
#include "qwebengineprofile_p.h"
#include "qwebenginecookiestore.h"
-#include "qwebenginedownloaditem.h"
-#include "qwebenginedownloaditem_p.h"
+#include "qwebenginedownloadrequest.h"
+#include "qwebenginedownloadrequest_p.h"
#include "qwebenginenotificationpresenter_p.h"
#include "qwebenginepage.h"
#include "qwebenginepage_p.h"
@@ -58,10 +58,10 @@
QT_BEGIN_NAMESPACE
-ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::UnknownSaveFormat, QtWebEngineCore::ProfileAdapterClient::UnknownSavePageFormat)
-ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::SingleHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::SingleHtmlSaveFormat)
-ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::CompleteHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::CompleteHtmlSaveFormat)
-ASSERT_ENUMS_MATCH(QWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::MimeHtmlSaveFormat)
+ASSERT_ENUMS_MATCH(QWebEngineDownloadRequest::UnknownSaveFormat, QtWebEngineCore::ProfileAdapterClient::UnknownSavePageFormat)
+ASSERT_ENUMS_MATCH(QWebEngineDownloadRequest::SingleHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::SingleHtmlSaveFormat)
+ASSERT_ENUMS_MATCH(QWebEngineDownloadRequest::CompleteHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::CompleteHtmlSaveFormat)
+ASSERT_ENUMS_MATCH(QWebEngineDownloadRequest::MimeHtmlSaveFormat, QtWebEngineCore::ProfileAdapterClient::MimeHtmlSaveFormat)
using QtWebEngineCore::ProfileAdapter;
@@ -151,19 +151,19 @@ void QWebEngineProfilePrivate::showNotification(QSharedPointer<QtWebEngineCore::
}
/*!
- \fn QWebEngineProfile::downloadRequested(QWebEngineDownloadItem *download)
+ \fn QWebEngineProfile::downloadRequested(QWebEngineDownloadRequest *download)
\since 5.5
This signal is emitted whenever a download has been triggered.
The \a download argument holds the state of the download.
- The download has to be explicitly accepted with QWebEngineDownloadItem::accept() or it will be
+ The download has to be explicitly accepted with QWebEngineDownloadRequest::accept() or it will be
cancelled by default.
The download item is parented by the profile. If it is not accepted, it
will be deleted immediately after the signal emission.
This signal cannot be used with a queued connection.
- \sa QWebEngineDownloadItem, QWebEnginePage::download()
+ \sa QWebEngineDownloadRequest, QWebEnginePage::download()
*/
QWebEngineProfilePrivate::QWebEngineProfilePrivate(ProfileAdapter* profileAdapter)
@@ -173,7 +173,6 @@ QWebEngineProfilePrivate::QWebEngineProfilePrivate(ProfileAdapter* profileAdapte
new QWebEngineScriptCollectionPrivate(profileAdapter->userResourceController())))
{
m_profileAdapter->addClient(this);
- m_settings->d_ptr->initDefaults();
}
QWebEngineProfilePrivate::~QWebEngineProfilePrivate()
@@ -223,37 +222,37 @@ void QWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
Q_Q(QWebEngineProfile);
Q_ASSERT(!m_ongoingDownloads.contains(info.id));
- QWebEngineDownloadItemPrivate *itemPrivate = new QWebEngineDownloadItemPrivate(this, info.url);
+ QWebEngineDownloadRequestPrivate *itemPrivate = new QWebEngineDownloadRequestPrivate(m_profileAdapter, info.url);
itemPrivate->downloadId = info.id;
- itemPrivate->downloadState = info.accepted ? QWebEngineDownloadItem::DownloadInProgress
- : QWebEngineDownloadItem::DownloadRequested;
+ itemPrivate->downloadState = info.accepted ? QWebEngineDownloadRequest::DownloadInProgress
+ : QWebEngineDownloadRequest::DownloadRequested;
itemPrivate->startTime = info.startTime;
itemPrivate->downloadDirectory = QFileInfo(info.path).path();
itemPrivate->downloadFileName = QFileInfo(info.path).fileName();
itemPrivate->suggestedFileName = info.suggestedFileName;
itemPrivate->mimeType = info.mimeType;
- itemPrivate->savePageFormat = static_cast<QWebEngineDownloadItem::SavePageFormat>(info.savePageFormat);
- itemPrivate->type = static_cast<QWebEngineDownloadItem::DownloadType>(info.downloadType);
+ itemPrivate->savePageFormat = static_cast<QWebEngineDownloadRequest::SavePageFormat>(info.savePageFormat);
+ itemPrivate->isSavePageDownload = info.isSavePageDownload;
if (info.page && info.page->clientType() == QtWebEngineCore::WebContentsAdapterClient::WidgetsClient)
itemPrivate->page = static_cast<QWebEnginePagePrivate *>(info.page)->q_ptr;
else
itemPrivate->page = nullptr;
- QWebEngineDownloadItem *download = new QWebEngineDownloadItem(itemPrivate, q);
+ QWebEngineDownloadRequest *download = new QWebEngineDownloadRequest(itemPrivate, q);
m_ongoingDownloads.insert(info.id, download);
- QObject::connect(download, &QWebEngineDownloadItem::destroyed, q, [id = info.id, this] () { downloadDestroyed(id); });
+ QObject::connect(download, &QWebEngineDownloadRequest::destroyed, q, [id = info.id, this] () { downloadDestroyed(id); });
Q_EMIT q->downloadRequested(download);
- QWebEngineDownloadItem::DownloadState state = download->state();
+ QWebEngineDownloadRequest::DownloadState state = download->state();
info.path = QDir(download->downloadDirectory()).filePath(download->downloadFileName());
info.savePageFormat = static_cast<QtWebEngineCore::ProfileAdapterClient::SavePageFormat>(
download->savePageFormat());
- info.accepted = state != QWebEngineDownloadItem::DownloadCancelled;
+ info.accepted = state != QWebEngineDownloadRequest::DownloadCancelled;
- if (state == QWebEngineDownloadItem::DownloadRequested) {
+ if (state == QWebEngineDownloadRequest::DownloadRequested) {
// Delete unaccepted downloads.
info.accepted = false;
delete download;
@@ -265,7 +264,7 @@ void QWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info)
if (!m_ongoingDownloads.contains(info.id))
return;
- QWebEngineDownloadItem* download = m_ongoingDownloads.value(info.id).data();
+ QWebEngineDownloadRequest* download = m_ongoingDownloads.value(info.id).data();
if (!download) {
downloadDestroyed(info.id);
diff --git a/src/webenginewidgets/api/qwebengineprofile.h b/src/webenginewidgets/api/qwebengineprofile.h
index 794ba6279..a8bf70856 100644
--- a/src/webenginewidgets/api/qwebengineprofile.h
+++ b/src/webenginewidgets/api/qwebengineprofile.h
@@ -55,7 +55,7 @@ class QObject;
class QUrl;
class QWebEngineClientCertificateStore;
class QWebEngineCookieStore;
-class QWebEngineDownloadItem;
+class QWebEngineDownloadRequest;
class QWebEngineNotification;
class QWebEnginePage;
class QWebEnginePagePrivate;
@@ -149,7 +149,7 @@ public:
static QWebEngineProfile *defaultProfile();
Q_SIGNALS:
- void downloadRequested(QWebEngineDownloadItem *download);
+ void downloadRequested(QWebEngineDownloadRequest *download);
private:
Q_DISABLE_COPY(QWebEngineProfile)
diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h
index 64e9500b0..60fa4632f 100644
--- a/src/webenginewidgets/api/qwebengineprofile_p.h
+++ b/src/webenginewidgets/api/qwebengineprofile_p.h
@@ -99,7 +99,7 @@ private:
QWebEngineSettings *m_settings;
QPointer<QtWebEngineCore::ProfileAdapter> m_profileAdapter;
QScopedPointer<QWebEngineScriptCollection> m_scriptCollection;
- QMap<quint32, QPointer<QWebEngineDownloadItem> > m_ongoingDownloads;
+ QMap<quint32, QPointer<QWebEngineDownloadRequest> > m_ongoingDownloads;
std::function<void(std::unique_ptr<QWebEngineNotification>)> m_notificationPresenter;
};
diff --git a/src/webenginewidgets/api/qwebenginesettings.cpp b/src/webenginewidgets/api/qwebenginesettings.cpp
deleted file mode 100644
index d9fb3b000..000000000
--- a/src/webenginewidgets/api/qwebenginesettings.cpp
+++ /dev/null
@@ -1,254 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwebenginesettings.h"
-
-#include "qwebengineprofile.h"
-#include "web_engine_settings.h"
-
-QT_BEGIN_NAMESPACE
-
-using QtWebEngineCore::WebEngineSettings;
-
-static WebEngineSettings::Attribute toWebEngineAttribute(QWebEngineSettings::WebAttribute attribute)
-{
- switch (attribute) {
- case QWebEngineSettings::AutoLoadImages:
- return WebEngineSettings::AutoLoadImages;
- case QWebEngineSettings::JavascriptEnabled:
- return WebEngineSettings::JavascriptEnabled;
- case QWebEngineSettings::JavascriptCanOpenWindows:
- return WebEngineSettings::JavascriptCanOpenWindows;
- case QWebEngineSettings::JavascriptCanAccessClipboard:
- return WebEngineSettings::JavascriptCanAccessClipboard;
- case QWebEngineSettings::LinksIncludedInFocusChain:
- return WebEngineSettings::LinksIncludedInFocusChain;
- case QWebEngineSettings::LocalStorageEnabled:
- return WebEngineSettings::LocalStorageEnabled;
- case QWebEngineSettings::LocalContentCanAccessRemoteUrls:
- return WebEngineSettings::LocalContentCanAccessRemoteUrls;
- case QWebEngineSettings::XSSAuditingEnabled:
- return WebEngineSettings::XSSAuditingEnabled;
- case QWebEngineSettings::SpatialNavigationEnabled:
- return WebEngineSettings::SpatialNavigationEnabled;
- case QWebEngineSettings::LocalContentCanAccessFileUrls:
- return WebEngineSettings::LocalContentCanAccessFileUrls;
- case QWebEngineSettings::HyperlinkAuditingEnabled:
- return WebEngineSettings::HyperlinkAuditingEnabled;
- case QWebEngineSettings::ScrollAnimatorEnabled:
- return WebEngineSettings::ScrollAnimatorEnabled;
- case QWebEngineSettings::ErrorPageEnabled:
- return WebEngineSettings::ErrorPageEnabled;
- case QWebEngineSettings::PluginsEnabled:
- return WebEngineSettings::PluginsEnabled;
- case QWebEngineSettings::FullScreenSupportEnabled:
- return WebEngineSettings::FullScreenSupportEnabled;
- case QWebEngineSettings::ScreenCaptureEnabled:
- return WebEngineSettings::ScreenCaptureEnabled;
- case QWebEngineSettings::WebGLEnabled:
- return WebEngineSettings::WebGLEnabled;
- case QWebEngineSettings::Accelerated2dCanvasEnabled:
- return WebEngineSettings::Accelerated2dCanvasEnabled;
- case QWebEngineSettings::AutoLoadIconsForPage:
- return WebEngineSettings::AutoLoadIconsForPage;
- case QWebEngineSettings::TouchIconsEnabled:
- return WebEngineSettings::TouchIconsEnabled;
- case QWebEngineSettings::FocusOnNavigationEnabled:
- return WebEngineSettings::FocusOnNavigationEnabled;
- case QWebEngineSettings::PrintElementBackgrounds:
- return WebEngineSettings::PrintElementBackgrounds;
- case QWebEngineSettings::AllowRunningInsecureContent:
- return WebEngineSettings::AllowRunningInsecureContent;
- case QWebEngineSettings::AllowGeolocationOnInsecureOrigins:
- return WebEngineSettings::AllowGeolocationOnInsecureOrigins;
- case QWebEngineSettings::AllowWindowActivationFromJavaScript:
- return WebEngineSettings::AllowWindowActivationFromJavaScript;
- case QWebEngineSettings::ShowScrollBars:
- return WebEngineSettings::ShowScrollBars;
- case QWebEngineSettings::PlaybackRequiresUserGesture:
- return WebEngineSettings::PlaybackRequiresUserGesture;
- case QWebEngineSettings::WebRTCPublicInterfacesOnly:
- return WebEngineSettings::WebRTCPublicInterfacesOnly;
- case QWebEngineSettings::JavascriptCanPaste:
- return WebEngineSettings::JavascriptCanPaste;
- case QWebEngineSettings::DnsPrefetchEnabled:
- return WebEngineSettings::DnsPrefetchEnabled;
- case QWebEngineSettings::PdfViewerEnabled:
- return WebEngineSettings::PdfViewerEnabled;
- default:
- return WebEngineSettings::UnsupportedInCoreSettings;
- }
-}
-
-QWebEngineSettings::QWebEngineSettings(QWebEngineSettings *parentSettings)
- : d_ptr(new WebEngineSettings(parentSettings ? parentSettings->d_func() : 0))
-{
- Q_D(QWebEngineSettings);
- d->scheduleApplyRecursively();
-}
-
-QWebEngineSettings::~QWebEngineSettings()
-{
-}
-
-#if QT_DEPRECATED_SINCE(5, 5)
-QWebEngineSettings *QWebEngineSettings::globalSettings()
-{
- return defaultSettings();
-}
-#endif
-
-/*!
- Returns the settings for a web engine page that belongs to the default
- profile. All web pages not specifically created with another profile belong
- to the default profile.
-*/
-QWebEngineSettings *QWebEngineSettings::defaultSettings()
-{
- return QWebEngineProfile::defaultProfile()->settings();
-}
-
-ASSERT_ENUMS_MATCH(WebEngineSettings::StandardFont, QWebEngineSettings::StandardFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::FixedFont, QWebEngineSettings::FixedFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::SerifFont, QWebEngineSettings::SerifFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::SansSerifFont, QWebEngineSettings::SansSerifFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::CursiveFont, QWebEngineSettings::CursiveFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::FantasyFont, QWebEngineSettings::FantasyFont)
-ASSERT_ENUMS_MATCH(WebEngineSettings::PictographFont, QWebEngineSettings::PictographFont)
-
-void QWebEngineSettings::setFontFamily(QWebEngineSettings::FontFamily which, const QString &family)
-{
- Q_D(QWebEngineSettings);
- d->setFontFamily(static_cast<WebEngineSettings::FontFamily>(which), family);
-}
-
-QString QWebEngineSettings::fontFamily(QWebEngineSettings::FontFamily which) const
-{
- return d_ptr->fontFamily(static_cast<WebEngineSettings::FontFamily>(which));
-}
-
-void QWebEngineSettings::resetFontFamily(QWebEngineSettings::FontFamily which)
-{
- d_ptr->resetFontFamily(static_cast<WebEngineSettings::FontFamily>(which));
-}
-
-ASSERT_ENUMS_MATCH(WebEngineSettings::DefaultFixedFontSize, QWebEngineSettings::DefaultFixedFontSize)
-ASSERT_ENUMS_MATCH(WebEngineSettings::DefaultFontSize, QWebEngineSettings::DefaultFontSize)
-ASSERT_ENUMS_MATCH(WebEngineSettings::MinimumFontSize, QWebEngineSettings::MinimumFontSize)
-ASSERT_ENUMS_MATCH(WebEngineSettings::MinimumLogicalFontSize, QWebEngineSettings::MinimumLogicalFontSize)
-
-void QWebEngineSettings::setFontSize(QWebEngineSettings::FontSize type, int size)
-{
- Q_D(QWebEngineSettings);
- d->setFontSize(static_cast<WebEngineSettings::FontSize>(type), size);
-}
-
-int QWebEngineSettings::fontSize(QWebEngineSettings::FontSize type) const
-{
- Q_D(const QWebEngineSettings);
- return d->fontSize(static_cast<WebEngineSettings::FontSize>(type));
-}
-
-void QWebEngineSettings::resetFontSize(QWebEngineSettings::FontSize type)
-{
- Q_D(QWebEngineSettings);
- d->resetFontSize(static_cast<WebEngineSettings::FontSize>(type));
-}
-
-void QWebEngineSettings::setDefaultTextEncoding(const QString &encoding)
-{
- Q_D(QWebEngineSettings);
- d->setDefaultTextEncoding(encoding);
-}
-
-QString QWebEngineSettings::defaultTextEncoding() const
-{
- Q_D(const QWebEngineSettings);
- return d->defaultTextEncoding();
-}
-
-ASSERT_ENUMS_MATCH(WebEngineSettings::DisallowUnknownUrlSchemes, QWebEngineSettings::DisallowUnknownUrlSchemes)
-ASSERT_ENUMS_MATCH(WebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction, QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction)
-ASSERT_ENUMS_MATCH(WebEngineSettings::AllowAllUnknownUrlSchemes, QWebEngineSettings::AllowAllUnknownUrlSchemes)
-
-QWebEngineSettings::UnknownUrlSchemePolicy QWebEngineSettings::unknownUrlSchemePolicy() const
-{
- Q_D(const QWebEngineSettings);
- WebEngineSettings::UnknownUrlSchemePolicy result = d->unknownUrlSchemePolicy();
- Q_ASSERT(result != WebEngineSettings::InheritedUnknownUrlSchemePolicy);
- return static_cast<QWebEngineSettings::UnknownUrlSchemePolicy>(result);
-}
-
-void QWebEngineSettings::setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy policy)
-{
- Q_D(QWebEngineSettings);
- d->setUnknownUrlSchemePolicy(static_cast<WebEngineSettings::UnknownUrlSchemePolicy>(policy));
-}
-
-void QWebEngineSettings::resetUnknownUrlSchemePolicy()
-{
- Q_D(QWebEngineSettings);
- d->setUnknownUrlSchemePolicy(WebEngineSettings::InheritedUnknownUrlSchemePolicy);
-}
-
-void QWebEngineSettings::setAttribute(QWebEngineSettings::WebAttribute attr, bool on)
-{
- Q_D(QWebEngineSettings);
- WebEngineSettings::Attribute webEngineAttribute = toWebEngineAttribute(attr);
- Q_ASSERT(webEngineAttribute != WebEngineSettings::UnsupportedInCoreSettings);
- d->setAttribute(webEngineAttribute, on);
-}
-
-bool QWebEngineSettings::testAttribute(QWebEngineSettings::WebAttribute attr) const
-{
- Q_D(const QWebEngineSettings);
- WebEngineSettings::Attribute webEngineAttribute = toWebEngineAttribute(attr);
- Q_ASSERT(webEngineAttribute != WebEngineSettings::UnsupportedInCoreSettings);
- return d->testAttribute(webEngineAttribute);
-}
-
-void QWebEngineSettings::resetAttribute(QWebEngineSettings::WebAttribute attr)
-{
- Q_D(QWebEngineSettings);
- WebEngineSettings::Attribute webEngineAttribute = toWebEngineAttribute(attr);
- Q_ASSERT(webEngineAttribute != WebEngineSettings::UnsupportedInCoreSettings);
- d->resetAttribute(webEngineAttribute);
-}
-
-QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginesettings.h b/src/webenginewidgets/api/qwebenginesettings.h
deleted file mode 100644
index d39291fed..000000000
--- a/src/webenginewidgets/api/qwebenginesettings.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://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 https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWEBENGINESETTINGS_H
-#define QWEBENGINESETTINGS_H
-
-#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-#include <QtCore/qscopedpointer.h>
-#include <QtCore/qstring.h>
-
-namespace QtWebEngineCore {
-class WebEngineSettings;
-}
-
-QT_BEGIN_NAMESPACE
-
-class QIcon;
-class QPixmap;
-class QUrl;
-
-class QWEBENGINEWIDGETS_EXPORT QWebEngineSettings {
-public:
- enum FontFamily {
- StandardFont,
- FixedFont,
- SerifFont,
- SansSerifFont,
- CursiveFont,
- FantasyFont,
- PictographFont
- };
- enum WebAttribute {
- AutoLoadImages,
- JavascriptEnabled,
- JavascriptCanOpenWindows,
- JavascriptCanAccessClipboard,
- LinksIncludedInFocusChain,
- LocalStorageEnabled,
- LocalContentCanAccessRemoteUrls,
- XSSAuditingEnabled,
- SpatialNavigationEnabled,
- LocalContentCanAccessFileUrls,
- HyperlinkAuditingEnabled,
- ScrollAnimatorEnabled,
- ErrorPageEnabled,
- PluginsEnabled,
- FullScreenSupportEnabled,
- ScreenCaptureEnabled,
- WebGLEnabled,
- Accelerated2dCanvasEnabled,
- AutoLoadIconsForPage,
- TouchIconsEnabled,
- FocusOnNavigationEnabled,
- PrintElementBackgrounds,
- AllowRunningInsecureContent,
- AllowGeolocationOnInsecureOrigins,
- AllowWindowActivationFromJavaScript,
- ShowScrollBars,
- PlaybackRequiresUserGesture,
- WebRTCPublicInterfacesOnly,
- JavascriptCanPaste,
- DnsPrefetchEnabled,
- PdfViewerEnabled,
- };
-
- enum FontSize {
- MinimumFontSize,
- MinimumLogicalFontSize,
- DefaultFontSize,
- DefaultFixedFontSize
- };
-
- enum UnknownUrlSchemePolicy {
- DisallowUnknownUrlSchemes = 1,
- AllowUnknownUrlSchemesFromUserInteraction,
- AllowAllUnknownUrlSchemes
- };
-
-#if QT_DEPRECATED_SINCE(5, 5)
- static QWebEngineSettings *globalSettings();
-#endif
- static QWebEngineSettings *defaultSettings();
-
- void setFontFamily(FontFamily which, const QString &family);
- QString fontFamily(FontFamily which) const;
- void resetFontFamily(FontFamily which);
-
- void setFontSize(FontSize type, int size);
- int fontSize(FontSize type) const;
- void resetFontSize(FontSize type);
-
- void setAttribute(WebAttribute attr, bool on);
- bool testAttribute(WebAttribute attr) const;
- void resetAttribute(WebAttribute attr);
-
- void setDefaultTextEncoding(const QString &encoding);
- QString defaultTextEncoding() const;
-
- UnknownUrlSchemePolicy unknownUrlSchemePolicy() const;
- void setUnknownUrlSchemePolicy(UnknownUrlSchemePolicy policy);
- void resetUnknownUrlSchemePolicy();
-
-private:
- Q_DISABLE_COPY(QWebEngineSettings)
- typedef ::QtWebEngineCore::WebEngineSettings QWebEngineSettingsPrivate;
- QWebEngineSettingsPrivate* d_func() { return d_ptr.data(); }
- const QWebEngineSettingsPrivate* d_func() const { return d_ptr.data(); }
- QScopedPointer<QWebEngineSettingsPrivate> d_ptr;
- friend class QWebEnginePagePrivate;
- friend class QWebEngineProfilePrivate;
-
- ~QWebEngineSettings();
- explicit QWebEngineSettings(QWebEngineSettings *parentSettings = Q_NULLPTR);
-};
-
-QT_END_NAMESPACE
-
-#endif // QWEBENGINESETTINGS_H
diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp
index b06d99478..203682c79 100644
--- a/src/webenginewidgets/api/qwebengineview.cpp
+++ b/src/webenginewidgets/api/qwebengineview.cpp
@@ -125,6 +125,38 @@ void QWebEngineViewPrivate::widgetChanged(QtWebEngineCore::RenderWidgetHostViewQ
}
}
+void QWebEngineViewPrivate::contextMenuRequested(QWebEngineContextMenuRequest *request)
+{
+#if QT_CONFIG(action)
+ m_contextRequest = request;
+ switch (q_ptr->contextMenuPolicy()) {
+ case Qt::DefaultContextMenu: {
+ QContextMenuEvent event(QContextMenuEvent::Mouse, request->position(),
+ q_ptr->mapToGlobal(request->position()));
+ q_ptr->contextMenuEvent(&event);
+ return;
+ }
+ case Qt::CustomContextMenu:
+ Q_EMIT q_ptr->customContextMenuRequested(request->position());
+ return;
+ case Qt::ActionsContextMenu:
+ if (q_ptr->actions().count()) {
+ QContextMenuEvent event(QContextMenuEvent::Mouse, request->position(),
+ q_ptr->mapToGlobal(request->position()));
+ QMenu::exec(q_ptr->actions(), event.globalPos(), 0, q_ptr);
+ }
+ return;
+ case Qt::PreventContextMenu:
+ case Qt::NoContextMenu:
+ return;
+ }
+
+ Q_UNREACHABLE();
+#else
+ Q_UNUSED(data);
+#endif // QT_CONFIG(action)
+}
+
#ifndef QT_NO_ACCESSIBILITY
static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *object)
{
@@ -135,9 +167,7 @@ static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *obje
#endif // QT_NO_ACCESSIBILITY
QWebEngineViewPrivate::QWebEngineViewPrivate()
- : page(0)
- , m_dragEntered(false)
- , m_ownsPage(false)
+ : page(0), m_dragEntered(false), m_ownsPage(false), m_contextRequest(nullptr)
{
#ifndef QT_NO_ACCESSIBILITY
QAccessible::installFactory(&webAccessibleFactory);
@@ -326,7 +356,7 @@ void QWebEngineView::reload()
QWebEngineView *QWebEngineView::createWindow(QWebEnginePage::WebWindowType type)
{
- Q_UNUSED(type)
+ Q_UNUSED(type);
return 0;
}
@@ -378,7 +408,7 @@ bool QWebEngineView::event(QEvent *ev)
#if QT_CONFIG(contextmenu)
void QWebEngineView::contextMenuEvent(QContextMenuEvent *event)
{
- QMenu *menu = page()->createStandardContextMenu();
+ QMenu *menu = createStandardContextMenu();
menu->popup(event->globalPos());
}
#endif // QT_CONFIG(contextmenu)
@@ -421,7 +451,7 @@ void QWebEngineView::dragEnterEvent(QDragEnterEvent *e)
e->accept();
if (d->m_dragEntered)
d->page->d_ptr->adapter->leaveDrag();
- d->page->d_ptr->adapter->enterDrag(e, mapToGlobal(e->pos()));
+ d->page->d_ptr->adapter->enterDrag(e, mapToGlobal(e->position().toPoint()));
d->m_dragEntered = true;
}
@@ -447,7 +477,8 @@ void QWebEngineView::dragMoveEvent(QDragMoveEvent *e)
if (!d->m_dragEntered)
return;
QtWebEngineCore::WebContentsAdapter *adapter = d->page->d_ptr->adapter.data();
- Qt::DropAction dropAction = adapter->updateDragPosition(e, mapToGlobal(e->pos()));
+ Qt::DropAction dropAction =
+ adapter->updateDragPosition(e, mapToGlobal(e->position().toPoint()));
if (Qt::IgnoreAction == dropAction) {
e->ignore();
} else {
@@ -465,11 +496,40 @@ void QWebEngineView::dropEvent(QDropEvent *e)
if (!d->m_dragEntered)
return;
e->accept();
- d->page->d_ptr->adapter->endDragging(e, mapToGlobal(e->pos()));
+ d->page->d_ptr->adapter->endDragging(e, mapToGlobal(e->position().toPoint()));
d->m_dragEntered = false;
}
#endif // QT_CONFIG(draganddrop)
+#if QT_CONFIG(menu)
+QMenu *QWebEngineView::createStandardContextMenu()
+{
+ Q_D(QWebEngineView);
+ QMenu *menu = new QMenu(this);
+ QContextMenuBuilder contextMenuBuilder(d->m_contextRequest, this, menu);
+
+ contextMenuBuilder.initMenu();
+
+ menu->setAttribute(Qt::WA_DeleteOnClose, true);
+
+ return menu;
+}
+#endif // QT_CONFIG(menu)
+
+/*!
+ \since 6.0
+
+ Returns additional data about the current context menu. It is only guaranteed to be valid during
+ the call to the contextMenuEvent()
+
+ \sa createStandardContextMenu()
+*/
+QWebEngineContextMenuRequest *QWebEngineView::lastContextMenuRequest() const
+{
+ Q_D(const QWebEngineView);
+ return d->m_contextRequest;
+}
+
#ifndef QT_NO_ACCESSIBILITY
bool QWebEngineViewAccessible::isValid() const
{
@@ -509,6 +569,174 @@ int QWebEngineViewAccessible::indexOfChild(const QAccessibleInterface *c) const
}
#endif // QT_NO_ACCESSIBILITY
+#if QT_CONFIG(action)
+QContextMenuBuilder::QContextMenuBuilder(QWebEngineContextMenuRequest *request,
+ QWebEngineView *view, QMenu *menu)
+ : QtWebEngineCore::RenderViewContextMenuQt(request), m_view(view), m_menu(menu)
+{
+ m_view->page()->d_ptr->ensureInitialized();
+}
+
+bool QContextMenuBuilder::hasInspector()
+{
+ return m_view->page()->d_ptr->adapter->hasInspector();
+}
+
+bool QContextMenuBuilder::isFullScreenMode()
+{
+ return m_view->page()->d_ptr->isFullScreenMode();
+}
+
+void QContextMenuBuilder::addMenuItem(ContextMenuItem menuItem)
+{
+ QPointer<QWebEnginePage> thisRef(m_view->page());
+ QAction *action = 0;
+
+ switch (menuItem) {
+ case ContextMenuItem::Back:
+ action = thisRef->action(QWebEnginePage::Back);
+ break;
+ case ContextMenuItem::Forward:
+ action = thisRef->action(QWebEnginePage::Forward);
+ break;
+ case ContextMenuItem::Reload:
+ action = thisRef->action(QWebEnginePage::Reload);
+ break;
+ case ContextMenuItem::Cut:
+ action = thisRef->action(QWebEnginePage::Cut);
+ break;
+ case ContextMenuItem::Copy:
+ action = thisRef->action(QWebEnginePage::Copy);
+ break;
+ case ContextMenuItem::Paste:
+ action = thisRef->action(QWebEnginePage::Paste);
+ break;
+ case ContextMenuItem::Undo:
+ action = thisRef->action(QWebEnginePage::Undo);
+ break;
+ case ContextMenuItem::Redo:
+ action = thisRef->action(QWebEnginePage::Redo);
+ break;
+ case ContextMenuItem::SelectAll:
+ action = thisRef->action(QWebEnginePage::SelectAll);
+ break;
+ case ContextMenuItem::PasteAndMatchStyle:
+ action = thisRef->action(QWebEnginePage::PasteAndMatchStyle);
+ break;
+ case ContextMenuItem::OpenLinkInNewWindow:
+ action = thisRef->action(QWebEnginePage::OpenLinkInNewWindow);
+ break;
+ case ContextMenuItem::OpenLinkInNewTab:
+ action = thisRef->action(QWebEnginePage::OpenLinkInNewTab);
+ break;
+ case ContextMenuItem::CopyLinkToClipboard:
+ action = thisRef->action(QWebEnginePage::CopyLinkToClipboard);
+ break;
+ case ContextMenuItem::DownloadLinkToDisk:
+ action = thisRef->action(QWebEnginePage::DownloadLinkToDisk);
+ break;
+ case ContextMenuItem::CopyImageToClipboard:
+ action = thisRef->action(QWebEnginePage::CopyImageToClipboard);
+ break;
+ case ContextMenuItem::CopyImageUrlToClipboard:
+ action = thisRef->action(QWebEnginePage::CopyImageUrlToClipboard);
+ break;
+ case ContextMenuItem::DownloadImageToDisk:
+ action = thisRef->action(QWebEnginePage::DownloadImageToDisk);
+ break;
+ case ContextMenuItem::CopyMediaUrlToClipboard:
+ action = thisRef->action(QWebEnginePage::CopyMediaUrlToClipboard);
+ break;
+ case ContextMenuItem::ToggleMediaControls:
+ action = thisRef->action(QWebEnginePage::ToggleMediaControls);
+ break;
+ case ContextMenuItem::ToggleMediaLoop:
+ action = thisRef->action(QWebEnginePage::ToggleMediaLoop);
+ break;
+ case ContextMenuItem::DownloadMediaToDisk:
+ action = thisRef->action(QWebEnginePage::DownloadMediaToDisk);
+ break;
+ case ContextMenuItem::InspectElement:
+ action = thisRef->action(QWebEnginePage::InspectElement);
+ break;
+ case ContextMenuItem::ExitFullScreen:
+ action = thisRef->action(QWebEnginePage::ExitFullScreen);
+ break;
+ case ContextMenuItem::SavePage:
+ action = thisRef->action(QWebEnginePage::SavePage);
+ break;
+ case ContextMenuItem::ViewSource:
+ action = thisRef->action(QWebEnginePage::ViewSource);
+ break;
+ case ContextMenuItem::SpellingSuggestions:
+ for (int i = 0; i < m_contextData->spellCheckerSuggestions().count() && i < 4; i++) {
+ action = new QAction(m_menu);
+ QString replacement = m_contextData->spellCheckerSuggestions().at(i);
+ QObject::connect(action, &QAction::triggered, [thisRef, replacement] {
+ if (thisRef)
+ thisRef->replaceMisspelledWord(replacement);
+ });
+ action->setText(replacement);
+ m_menu->addAction(action);
+ }
+ return;
+ case ContextMenuItem::Separator:
+ if (!m_menu->isEmpty())
+ m_menu->addSeparator();
+ return;
+ }
+ action->setEnabled(isMenuItemEnabled(menuItem));
+ m_menu->addAction(action);
+}
+
+bool QContextMenuBuilder::isMenuItemEnabled(ContextMenuItem menuItem)
+{
+ switch (menuItem) {
+ case ContextMenuItem::Back:
+ return m_view->page()->d_ptr->adapter->canGoBack();
+ case ContextMenuItem::Forward:
+ return m_view->page()->d_ptr->adapter->canGoForward();
+ case ContextMenuItem::Reload:
+ return true;
+ case ContextMenuItem::Cut:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanCut;
+ case ContextMenuItem::Copy:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanCopy;
+ case ContextMenuItem::Paste:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanPaste;
+ case ContextMenuItem::Undo:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanUndo;
+ case ContextMenuItem::Redo:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanRedo;
+ case ContextMenuItem::SelectAll:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanSelectAll;
+ case ContextMenuItem::PasteAndMatchStyle:
+ return m_contextData->editFlags() & QWebEngineContextMenuRequest::CanPaste;
+ case ContextMenuItem::OpenLinkInNewWindow:
+ case ContextMenuItem::OpenLinkInNewTab:
+ case ContextMenuItem::CopyLinkToClipboard:
+ case ContextMenuItem::DownloadLinkToDisk:
+ case ContextMenuItem::CopyImageToClipboard:
+ case ContextMenuItem::CopyImageUrlToClipboard:
+ case ContextMenuItem::DownloadImageToDisk:
+ case ContextMenuItem::CopyMediaUrlToClipboard:
+ case ContextMenuItem::ToggleMediaControls:
+ case ContextMenuItem::ToggleMediaLoop:
+ case ContextMenuItem::DownloadMediaToDisk:
+ case ContextMenuItem::InspectElement:
+ case ContextMenuItem::ExitFullScreen:
+ case ContextMenuItem::SavePage:
+ return true;
+ case ContextMenuItem::ViewSource:
+ return m_view->page()->d_ptr->adapter->canViewSource();
+ case ContextMenuItem::SpellingSuggestions:
+ case ContextMenuItem::Separator:
+ return true;
+ }
+ Q_UNREACHABLE();
+}
+#endif // QT_CONFIG(action)
+
QT_END_NAMESPACE
#include "moc_qwebengineview.cpp"
diff --git a/src/webenginewidgets/api/qwebengineview.h b/src/webenginewidgets/api/qwebengineview.h
index 04c8ece74..06fbc5ddf 100644
--- a/src/webenginewidgets/api/qwebengineview.h
+++ b/src/webenginewidgets/api/qwebengineview.h
@@ -47,6 +47,7 @@
#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
#include <QtWebEngineWidgets/qwebenginepage.h>
#include <QtWebEngineCore/qwebenginehttprequest.h>
+#include <QtWebEngineCore/qwebenginecontextmenurequest.h>
QT_BEGIN_NAMESPACE
class QContextMenuEvent;
@@ -101,6 +102,11 @@ public:
QSize sizeHint() const override;
QWebEngineSettings *settings() const;
+#if QT_CONFIG(menu)
+ QMenu *createStandardContextMenu();
+#endif
+ QWebEngineContextMenuRequest *lastContextMenuRequest() const;
+
public Q_SLOTS:
void stop();
void back();
diff --git a/src/webenginewidgets/api/qwebengineview_p.h b/src/webenginewidgets/api/qwebengineview_p.h
index a3c619cea..29e39d081 100644
--- a/src/webenginewidgets/api/qwebengineview_p.h
+++ b/src/webenginewidgets/api/qwebengineview_p.h
@@ -52,7 +52,8 @@
//
#include <QtWebEngineWidgets/qwebengineview.h>
-
+#include "qwebenginecontextmenurequest.h"
+#include "render_view_context_menu_qt.h"
#include <QtWidgets/qaccessiblewidget.h>
namespace QtWebEngineCore {
@@ -72,12 +73,14 @@ public:
void pageChanged(QWebEnginePage *oldPage, QWebEnginePage *newPage);
void widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *oldWidget,
QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *newWidget);
+ void contextMenuRequested(QWebEngineContextMenuRequest *request);
QWebEngineViewPrivate();
QWebEnginePage *page;
bool m_dragEntered;
mutable bool m_ownsPage;
+ QWebEngineContextMenuRequest *m_contextRequest;
};
#ifndef QT_NO_ACCESSIBILITY
@@ -98,6 +101,22 @@ private:
};
#endif // QT_NO_ACCESSIBILITY
+class QContextMenuBuilder : public QtWebEngineCore::RenderViewContextMenuQt
+{
+public:
+ QContextMenuBuilder(QWebEngineContextMenuRequest *reqeust, QWebEngineView *view, QMenu *menu);
+
+private:
+ virtual bool hasInspector() override;
+ virtual bool isFullScreenMode() override;
+
+ virtual void addMenuItem(ContextMenuItem entry) override;
+ virtual bool isMenuItemEnabled(ContextMenuItem entry) override;
+
+ QWebEngineView *m_view;
+ QMenu *m_menu;
+};
+
QT_END_NAMESPACE
#endif // QWEBENGINEVIEW_P_H
diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
index 789d9794e..5def0d65c 100644
--- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
@@ -513,16 +513,13 @@
*/
/*!
- \fn bool QWebEnginePage::certificateError(const QWebEngineCertificateError & certificateError)
+ \fn void QWebEnginePage::certificateError(const QWebEngineCertificateError & certificateError)
This function is called when an invalid certificate error is raised while loading a given request.
- The \a certificateError parameter contains information about the certificate and details of the error.
-
- Return \c true to ignore the error and complete the request. Return \c false to stop loading
+ The \a certificateError parameter contains information about the certificate and details of the error,
+ it also provides the way to ignore the error and complete the request or stop loading
the request.
- \note If the error was successfully deferred then the returned value will be ignored.
-
\sa QWebEngineCertificateError
*/
diff --git a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
deleted file mode 100644
index b83da9440..000000000
--- a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- Copyright (C) 2015 The Qt Company Ltd.
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public License
- along with this library; see the file COPYING.LIB. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-*/
-
-// The documentation in this file was imported from QtWebKit and is thus constrained
-// by its LGPL license. Documentation written from scratch for new methods should be
-// placed inline in the code as usual.
-
-#if QT_DEPRECATED_SINCE(5, 5)
-/*!
- \fn static QWebEngineSettings *QWebEngineSettings::globalSettings()
- \obsolete
-
- Use defaultSettings() instead.
-*/
-#endif
-
-/*!
- \class QWebEngineSettings
- \since 5.4
- \brief The QWebEngineSettings class provides an object to store the settings used
- by QWebEnginePage.
-
- \inmodule QtWebEngineWidgets
-
- QWebEngineSettings allows configuration of browser properties, such as font sizes and
- families, the location of a custom style sheet, and generic attributes, such as JavaScript
- support. Individual attributes are set using the setAttribute() function. The
- \l{QWebEngineSettings::WebAttribute}{WebAttribute} enum further describes each attribute.
-
- Each QWebEnginePage object has its own QWebEngineSettings object, which configures the
- settings for that page. If a setting is not configured for a web engine
- page, it is looked up in the settings of the profile the page belongs to.
-
- \sa QWebEnginePage::settings(), QWebEngineView::settings()
-*/
-
-/*!
- \enum QWebEngineSettings::FontFamily
-
- This enum describes the generic font families defined by CSS 2.
- For more information see the
- \l{http://www.w3.org/TR/REC-CSS2/fonts.html#generic-font-families}{CSS standard}.
-
- \value StandardFont
- \value FixedFont
- \value SerifFont
- \value SansSerifFont
- \value CursiveFont
- \value FantasyFont
- \value PictographFont
- (added in Qt 5.7)
-*/
-
-/*!
- \enum QWebEngineSettings::FontSize
-
- This enum describes the font sizes configurable through QWebEngineSettings:
-
- \value MinimumFontSize The hard minimum font size.
- \value MinimumLogicalFontSize The minimum logical font size that is applied
- when zooming out.
- \value DefaultFontSize The default font size for regular text.
- \value DefaultFixedFontSize The default font size for fixed-pitch text.
-*/
-
-/*!
- \enum QWebEngineSettings::WebAttribute
-
- This enum type specifies settings for web pages:
-
- \value AutoLoadImages
- Automatically dowloads images for web pages. When this setting is
- disabled, images are loaded from the cache. Enabled by default.
- \value JavascriptEnabled
- Enables the running of JavaScript programs in the
- \l{QWebEngineScript::MainWorld}{MainWorld}. Enabled by default.
- \value JavascriptCanOpenWindows
- Allows JavaScript programs to open popup windows without user
- interaction. Enabled by default.
- \value JavascriptCanAccessClipboard
- Allows JavaScript programs to read from and write to the clipboard.
- Writing to the clipboard is always allowed if it is specifically requested by the user.
- See JavascriptCanPaste to also allow pasting the content of the clipboard content from
- JavaScript.
- Disabled by default.
- \value LinksIncludedInFocusChain
- Includes hyperlinks in the keyboard focus chain. Enabled by default.
- \value LocalStorageEnabled
- Enables support for the HTML 5 local storage feature. Enabled by default.
- \value LocalContentCanAccessRemoteUrls
- Allows locally loaded documents to ignore cross-origin rules so that they can access
- remote resources that would normally be blocked, because all remote resources are
- considered cross-origin for a local file. Remote access that would not be blocked by
- cross-origin rules is still possible when this setting is disabled (default).
- Note that disabling this setting does not stop XMLHttpRequests or media elements in
- local files from accessing remote content. Basically, it only stops some HTML
- subresources, such as scripts, and therefore disabling this setting is not a safety
- mechanism.
- \value XSSAuditingEnabled
- Obsolete and has no effect.
- \value SpatialNavigationEnabled
- Enables the Spatial Navigation feature, which means the ability to navigate between
- focusable elements, such as hyperlinks and form controls, on a web page by using the
- Left, Right, Up and Down arrow keys. For example, if a user presses the
- Right key, heuristics determine whether there is an element they might be
- trying to reach towards the right and which element they probably want.
- Disabled by default.
- \value LocalContentCanAccessFileUrls
- Allows locally loaded documents to access other local URLs. Enabled by default.
- \value HyperlinkAuditingEnabled
- Enables support for the \c ping attribute for hyperlinks. Disabled by default.
- \value ScrollAnimatorEnabled
- Enables animated scrolling. Disabled by default.
- \value ErrorPageEnabled
- Enables displaying the built-in error pages of Chromium. Enabled by default.
- \value PluginsEnabled
- Enables support for Pepper plugins, such as the Flash player. Disabled by default.
- See also \l{Pepper Plugin API}. (Added in Qt 5.6)
- \value FullScreenSupportEnabled
- Enables fullscreen support in an application. Disabled by default. (Added in Qt 5.6)
- \value ScreenCaptureEnabled
- Enables screen capture in an application. Disabled by default. (Added in Qt 5.7)
- \value WebGLEnabled
- Enables support for HTML 5 WebGL. Enabled by default if available. (Added in Qt 5.7)
- \value Accelerated2dCanvasEnabled
- Specifies whether the HTML5 2D canvas should be a OpenGL framebuffer.
- This makes many painting operations faster, but slows down pixel access. Enabled by default if available. (Added in Qt 5.7)
- \value AutoLoadIconsForPage
- Automatically downloads icons for web pages. Enabled by default. (Added in Qt 5.7)
- \value TouchIconsEnabled
- Enables support for touch icons and precomposed touch icons
- Disabled by default. (Added in Qt 5.7)
- \value FocusOnNavigationEnabled
- Gives focus to the view associated with the page, whenever a navigation operation occurs
- (load, stop, reload, reload and bypass cache, forward, backward, set content, and so
- on).
- Disabled by default. (Added in Qt 5.8)
- \value PrintElementBackgrounds
- Turns on printing of CSS backgrounds when printing a web page.
- Enabled by default. (Added in Qt 5.8)
- \value AllowRunningInsecureContent
- By default, HTTPS pages cannot run JavaScript, CSS, plugins or
- web-sockets from HTTP URLs. This provides an override to get
- the old insecure behavior.
- Disabled by default. (Added in Qt 5.8)
- \value AllowGeolocationOnInsecureOrigins
- Since Qt 5.7, only secure origins such as HTTPS have been able to request
- Geolocation features. This provides an override to allow non secure
- origins to access Geolocation again.
- Disabled by default. (Added in Qt 5.9)
- \value AllowWindowActivationFromJavaScript
- Allows activating windows by using the window.focus() JavaScript
- method. Disabled by default.
- (Added in Qt 5.10)
- \value ShowScrollBars
- Shows scroll bars.
- Enabled by default. (Added in Qt 5.10)
- \value PlaybackRequiresUserGesture
- Inhibits playback of media content until the user interacts with
- the page. By default, WebEngine uses Chromium settings, as described
- in \l {Autoplay Policy Changes}. This is similar to how Chrome on
- Android behaves, while the default behavior when it is disabled is
- similar to Chrome on desktops. To overwrite the default behavior,
- disable this setting. (Added in Qt 5.11)
- \value JavascriptCanPaste
- Enables JavaScript \c{execCommand("paste")}. This also requires
- enabling JavascriptCanAccessClipboard.
- Disabled by default. (Added in Qt 5.11)
- \value WebRTCPublicInterfacesOnly
- Limits WebRTC to public IP addresses only. When disabled WebRTC may also use
- local network IP addresses, but remote hosts can also see your local network
- IP address.
- Disabled by default. (Added in Qt 5.11)
- \value DnsPrefetchEnabled Specifies whether WebEngine will try to pre-fetch DNS entries to
- speed up browsing.
- Disabled by default. (Added in Qt 5.12)
- \value PdfViewerEnabled Specifies that PDF documents will be opened in the internal PDF viewer
- instead of being downloaded.
- Enabled by default. (Added in Qt 5.13)
-*/
-
-/*!
- \enum QWebEngineSettings::UnknownUrlSchemePolicy
- \since Qt 5.11
-
- This enum describes how navigation requests to URLs with unknown schemes are handled.
-
- \value DisallowUnknownUrlSchemes
- Disallows all navigation requests to URLs with unknown schemes.
- \value AllowUnknownUrlSchemesFromUserInteraction
- Allows navigation requests to URLs with unknown schemes that are issued from
- user-interaction (like a mouse-click), whereas other navigation requests (for example
- from JavaScript) are suppressed.
- \value AllowAllUnknownUrlSchemes
- Allows all navigation requests to URLs with unknown schemes.
-
- \sa unknownUrlSchemePolicy setUnknownUrlSchemePolicy resetUnknownUrlSchemePolicy
-*/
-
-/*!
- \fn void QWebEngineSettings::setFontSize(FontSize type, int size)
- Sets the font size for \a type to \a size in pixels.
-*/
-
-/*!
- \fn int QWebEngineSettings::fontSize(FontSize type) const
- Returns the default font size for \a type in pixels.
-*/
-
-/*!
- \fn void QWebEngineSettings::resetFontSize(FontSize type)
- Resets the font size for \a type to the size specified in the profile that
- the page belongs to.
-*/
-
-/*!
- \fn void QWebEngineSettings::setDefaultTextEncoding(const QString& encoding)
- Specifies the default text encoding system.
-
- The value of \a encoding must be a string describing an encoding such as "utf-8" or
- "iso-8859-1". If left empty, a default value will be used. For a more
- extensive list of encoding names see \l{QTextCodec}.
-
- \sa defaultTextEncoding()
-*/
-
-/*!
- \fn QString QWebEngineSettings::defaultTextEncoding() const
- Returns the default text encoding.
-
- \sa setDefaultTextEncoding()
-*/
-
-/*!
- \fn void QWebEngineSettings::setFontFamily(FontFamily which, const QString& family)
- Sets the actual font family to \a family for the specified generic family,
- \a which.
-*/
-
-/*!
- \fn QString QWebEngineSettings::fontFamily(FontFamily which) const
- Returns the actual font family for the specified generic font family,
- \a which.
-*/
-
-/*!
- \fn void QWebEngineSettings::resetFontFamily(FontFamily which)
- Resets the actual font family specified by \a which to the one specified
- in the profile that the page belongs to.
-*/
-
-/*!
- \fn QWebEngineSettings::UnknownUrlSchemePolicy QWebEngineSettings::unknownUrlSchemePolicy() const
- \since Qt 5.11
- Returns the currently selected policy for handling navigation requests to URLs with
- unknown schemes. Default is \l{QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction}.
- \sa setUnknownUrlSchemePolicy resetUnknownUrlSchemePolicy
-*/
-
-/*!
- \fn void QWebEngineSettings::setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy policy)
- \since Qt 5.11
- Sets the policy for handling navigation requests to URLs with unknown schemes to \a policy.
- Default is \l{QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction}.
- \sa unknownUrlSchemePolicy resetUnknownUrlSchemePolicy
-*/
-
-/*!
- \fn void QWebEngineSettings::resetUnknownUrlSchemePolicy()
- \since Qt 5.11
- Removes the policy for handling navigation requests to URLs with unknown schemes.
- \sa unknownUrlSchemePolicy setUnknownUrlSchemePolicy
-*/
-
-/*!
- \fn void QWebEngineSettings::setAttribute(WebAttribute attribute, bool on)
-
- Enables or disables the specified \a attribute feature depending on the
- value of \a on.
-*/
-
-/*!
- \fn bool QWebEngineSettings::testAttribute(WebAttribute attribute) const
-
- Returns \c true if \a attribute is enabled; otherwise returns \c false.
-*/
-
-/*!
- \fn void QWebEngineSettings::resetAttribute(WebAttribute attribute)
-
- Resets the setting of \a attribute to the value specified in the
- profile that the page belongs to.
-*/
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 1dfcc4c5a..0fd425580 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -39,6 +39,8 @@
#include "render_widget_host_view_qt_delegate_widget.h"
+#include "render_widget_host_view_qt_delegate_client.h"
+
#include "qwebenginepage_p.h"
#include "qwebengineview.h"
#include "qwebengineview_p.h"
@@ -47,21 +49,26 @@
#include <QMouseEvent>
#include <QOpenGLContext>
#include <QResizeEvent>
-#include <QSGAbstractRenderer>
#include <QSGNode>
#include <QWindow>
+#include <QtQuick/qsgimagenode.h>
#include <QtQuick/private/qquickwindow_p.h>
namespace QtWebEngineCore {
-class RenderWidgetHostViewQuickItem : public QQuickItem {
+class RenderWidgetHostViewQuickItem : public QQuickItem, public Compositor::Observer
+{
public:
RenderWidgetHostViewQuickItem(RenderWidgetHostViewQtDelegateClient *client) : m_client(client)
{
setFlag(ItemHasContents, true);
// Mark that this item should receive focus when the parent QQuickWidget receives focus.
setFocus(true);
+
+ bind(client->compositorId());
}
+ ~RenderWidgetHostViewQuickItem() { unbind(); }
+
protected:
bool event(QEvent *event) override
{
@@ -82,17 +89,77 @@ protected:
{
m_client->forwardEvent(event);
}
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override
+ void itemChange(ItemChange change, const ItemChangeData &value) override
{
- return m_client->updatePaintNode(oldNode);
+ QQuickItem::itemChange(change, value);
+ if (change == QQuickItem::ItemSceneChange) {
+ for (const QMetaObject::Connection &c : qAsConst(m_windowConnections))
+ disconnect(c);
+ m_windowConnections.clear();
+ if (value.window) {
+ m_windowConnections.append(connect(
+ value.window, &QQuickWindow::beforeRendering, this,
+ &RenderWidgetHostViewQuickItem::onBeforeRendering, Qt::DirectConnection));
+ }
+ }
}
+ QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override
+ {
+ auto comp = compositor();
+ if (!comp)
+ return nullptr;
+
+ QQuickWindow *win = QQuickItem::window();
+
+ // Delete old node before swapFrame to decrement refcount of
+ // QImage in software mode.
+ delete oldNode;
+ QSGImageNode *node = win->createImageNode();
+ node->setOwnsTexture(true);
+
+ comp->swapFrame();
+
+ QSize texSize = comp->size();
+ QSizeF texSizeInDips = QSizeF(texSize) / comp->devicePixelRatio();
+ node->setRect(QRectF(QPointF(0, 0), texSizeInDips));
+
+ if (comp->type() == Compositor::Type::Software) {
+ QImage image = comp->image();
+ node->setTexture(win->createTextureFromImage(image));
+ } else if (comp->type() == Compositor::Type::OpenGL) {
+ QQuickWindow::CreateTextureOptions texOpts;
+ if (comp->hasAlphaChannel())
+ texOpts.setFlag(QQuickWindow::TextureHasAlphaChannel);
+ int texId = comp->textureId();
+ node->setTexture(win->createTextureFromNativeObject(QQuickWindow::NativeObjectTexture,
+ texId, 0, texSize, texOpts));
+ node->setTextureCoordinatesTransform(QSGImageNode::MirrorVertically);
+ } else {
+ Q_UNREACHABLE();
+ }
+ return node;
+ }
+ void onBeforeRendering()
+ {
+ auto comp = compositor();
+ if (!comp || comp->type() != Compositor::Type::OpenGL)
+ return;
+ comp->waitForTexture();
+ }
QVariant inputMethodQuery(Qt::InputMethodQuery query) const override
{
return m_client->inputMethodQuery(query);
}
+ void readyToSwap() override
+ {
+ // Call update() on UI thread.
+ QMetaObject::invokeMethod(this, &QQuickItem::update, Qt::QueuedConnection);
+ }
+
private:
RenderWidgetHostViewQtDelegateClient *m_client;
+ QList<QMetaObject::Connection> m_windowConnections;
};
RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, QWidget *parent)
@@ -102,62 +169,6 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende
, m_isPopup(false)
{
setFocusPolicy(Qt::StrongFocus);
-
- QSurfaceFormat format;
- format.setDepthBufferSize(24);
- format.setStencilBufferSize(8);
-
-#if QT_CONFIG(opengl)
- QOpenGLContext *globalSharedContext = QOpenGLContext::globalShareContext();
- if (globalSharedContext) {
- QSurfaceFormat sharedFormat = globalSharedContext->format();
-
-#ifdef Q_OS_OSX
- // Check that the default QSurfaceFormat OpenGL profile is compatible with the global OpenGL
- // shared context profile, otherwise this could lead to a nasty crash.
- QSurfaceFormat defaultFormat = QSurfaceFormat::defaultFormat();
-
- if (defaultFormat.profile() != sharedFormat.profile()
- && defaultFormat.profile() == QSurfaceFormat::CoreProfile
- && defaultFormat.version() >= qMakePair(3, 2)) {
- qFatal("QWebEngine: Default QSurfaceFormat OpenGL profile is not compatible with the "
- "global shared context OpenGL profile. Please make sure you set a compatible "
- "QSurfaceFormat before the QtGui application instance is created.");
- }
-#endif
- int major;
- int minor;
- QSurfaceFormat::OpenGLContextProfile profile;
-#ifdef Q_OS_MACOS
- // Due to QTBUG-63180, requesting the sharedFormat.majorVersion() on macOS will lead to
- // a failed creation of QQuickWidget shared context. Thus make sure to request the
- // major version specified in the defaultFormat instead.
- major = defaultFormat.majorVersion();
- minor = defaultFormat.minorVersion();
- profile = defaultFormat.profile();
-#else
- major = sharedFormat.majorVersion();
- minor = sharedFormat.minorVersion();
- profile = sharedFormat.profile();
-#endif
-
- // Make sure the OpenGL profile of the QQuickWidget matches the shared context profile.
- // It covers the following cases:
- // 1) Desktop OpenGL Core Profile.
- // 2) Windows ANGLE OpenGL ES profile.
- if (sharedFormat.profile() == QSurfaceFormat::CoreProfile
-#ifdef Q_OS_WIN
- || globalSharedContext->isOpenGLES()
-#endif
- ) {
- format.setMajorVersion(major);
- format.setMinorVersion(minor);
- format.setProfile(profile);
- }
- }
-
- setFormat(format);
-#endif
setMouseTracking(true);
setAttribute(Qt::WA_AcceptTouchEvents);
setAttribute(Qt::WA_OpaquePaintEvent);
@@ -291,32 +302,6 @@ QWindow* RenderWidgetHostViewQtDelegateWidget::window() const
return root ? root->windowHandle() : 0;
}
-QSGTexture *RenderWidgetHostViewQtDelegateWidget::createTextureFromImage(const QImage &image)
-{
- return quickWindow()->createTextureFromImage(image, QQuickWindow::TextureCanUseAtlas);
-}
-
-QSGLayer *RenderWidgetHostViewQtDelegateWidget::createLayer()
-{
- QSGRenderContext *renderContext = QQuickWindowPrivate::get(quickWindow())->context;
- return renderContext->sceneGraphContext()->createLayer(renderContext);
-}
-
-QSGImageNode *RenderWidgetHostViewQtDelegateWidget::createImageNode()
-{
- return quickWindow()->createImageNode();
-}
-
-QSGRectangleNode *RenderWidgetHostViewQtDelegateWidget::createRectangleNode()
-{
- return quickWindow()->createRectangleNode();
-}
-
-void RenderWidgetHostViewQtDelegateWidget::update()
-{
- m_rootItem->update();
-}
-
void RenderWidgetHostViewQtDelegateWidget::updateCursor(const QCursor &cursor)
{
QQuickWidget::setCursor(cursor);
@@ -393,15 +378,6 @@ void RenderWidgetHostViewQtDelegateWidget::hideEvent(QHideEvent *event)
m_client->notifyHidden();
}
-bool RenderWidgetHostViewQtDelegateWidget::copySurface(const QRect &rect, const QSize &size, QImage &image)
-{
- QPixmap pixmap = rect.isEmpty() ? QQuickWidget::grab(QQuickWidget::rect()) : QQuickWidget::grab(rect);
- if (pixmap.isNull())
- return false;
- image = pixmap.toImage().scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- return true;
-}
-
bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
{
bool handled = false;
@@ -465,8 +441,9 @@ bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
// QtQuick is different by sending both the Press and DblClick events for the second press
// where we can simply ignore the DblClick event.
QMouseEvent *dblClick = static_cast<QMouseEvent *>(event);
- QMouseEvent press(QEvent::MouseButtonPress, dblClick->localPos(), dblClick->windowPos(), dblClick->screenPos(),
- dblClick->button(), dblClick->buttons(), dblClick->modifiers(), dblClick->source());
+ QMouseEvent press(QEvent::MouseButtonPress, dblClick->position(), dblClick->scenePosition(),
+ dblClick->globalPosition(), dblClick->button(), dblClick->buttons(),
+ dblClick->modifiers(), dblClick->source());
press.setTimestamp(dblClick->timestamp());
handled = m_client->forwardEvent(&press);
} else
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 034fdd65c..0dd5f1cc3 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
@@ -79,18 +79,12 @@ public:
void hide() override;
bool isVisible() const override;
QWindow* window() const override;
- QSGTexture *createTextureFromImage(const QImage &) override;
- QSGLayer *createLayer() override;
- QSGImageNode *createImageNode() override;
- QSGRectangleNode *createRectangleNode() override;
- void update() override;
void updateCursor(const QCursor &) override;
void resize(int width, int height) override;
void move(const QPoint &screenPos) override;
void inputMethodStateChanged(bool editorVisible, bool passwordInput) override;
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:
diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro
index d4fb40dc7..23f51f922 100644
--- a/src/webenginewidgets/webenginewidgets.pro
+++ b/src/webenginewidgets/webenginewidgets.pro
@@ -13,10 +13,7 @@ INCLUDEPATH += $$PWD api ../core ../core/api ../webengine/api
SOURCES = \
api/qtwebenginewidgetsglobal.cpp \
- api/qwebenginecertificateerror.cpp \
api/qwebengineclientcertificateselection.cpp \
- api/qwebenginecontextmenudata.cpp \
- api/qwebenginedownloaditem.cpp \
api/qwebenginefullscreenrequest.cpp \
api/qwebenginehistory.cpp \
api/qwebenginenotificationpresenter.cpp \
@@ -24,17 +21,12 @@ SOURCES = \
api/qwebengineprofile.cpp \
api/qwebenginescript.cpp \
api/qwebenginescriptcollection.cpp \
- api/qwebenginesettings.cpp \
api/qwebengineview.cpp \
render_widget_host_view_qt_delegate_widget.cpp
HEADERS = \
api/qtwebenginewidgetsglobal.h \
- api/qwebenginecertificateerror.h \
api/qwebengineclientcertificateselection.h \
- api/qwebenginecontextmenudata.h \
- api/qwebenginedownloaditem.h \
- api/qwebenginedownloaditem_p.h \
api/qwebenginefullscreenrequest.h \
api/qwebenginehistory.h \
api/qwebenginenotificationpresenter_p.h \
@@ -44,7 +36,6 @@ HEADERS = \
api/qwebengineprofile_p.h \
api/qwebenginescriptcollection.h \
api/qwebenginescriptcollection_p.h \
- api/qwebenginesettings.h \
api/qwebengineview.h \
api/qwebengineview_p.h \
render_widget_host_view_qt_delegate_widget.h