summaryrefslogtreecommitdiffstats
path: root/src/webengine
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine')
-rw-r--r--src/webengine/api/qquickwebenginedialogrequests.cpp110
-rw-r--r--src/webengine/api/qquickwebenginedialogrequests_p.h33
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem.cpp140
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p.h19
-rw-r--r--src/webengine/api/qquickwebenginedownloaditem_p_p.h6
-rw-r--r--src/webengine/api/qquickwebenginenavigationrequest.cpp2
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp10
-rw-r--r--src/webengine/api/qquickwebengineview.cpp74
-rw-r--r--src/webengine/api/qquickwebengineview_p.h26
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h5
-rw-r--r--src/webengine/doc/src/webengineview_lgpl.qdoc65
-rw-r--r--src/webengine/plugin/plugin.cpp28
-rw-r--r--src/webengine/plugin/plugin.pro2
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quick.cpp6
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quick.h1
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp5
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quickwindow.h1
-rw-r--r--src/webengine/ui_delegates_manager.cpp6
18 files changed, 484 insertions, 55 deletions
diff --git a/src/webengine/api/qquickwebenginedialogrequests.cpp b/src/webengine/api/qquickwebenginedialogrequests.cpp
index d6bba9a98..da1aecaf6 100644
--- a/src/webengine/api/qquickwebenginedialogrequests.cpp
+++ b/src/webengine/api/qquickwebenginedialogrequests.cpp
@@ -44,6 +44,9 @@
#include "file_picker_controller.h"
#include "web_contents_adapter_client.h"
+#include <QCursor>
+#include <QQuickItem>
+
QT_BEGIN_NAMESPACE
using namespace QtWebEngineCore;
@@ -823,4 +826,111 @@ void QQuickWebEngineFormValidationMessageRequest::setAccepted(bool accepted)
m_accepted = accepted;
}
+///////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \qmltype TooltipRequest
+ \instantiates QQuickWebEngineTooltipRequest
+ \inqmlmodule QtWebEngine
+ \since QtWebEngine 1.10
+
+ \brief A request for showing a tooltip to the user.
+*/
+
+QQuickWebEngineTooltipRequest::QQuickWebEngineTooltipRequest(
+ const QString &text, QObject *parent):
+ QObject(parent)
+ , m_text(text)
+ , m_type(text.isEmpty() ? RequestType::Hide : RequestType::Show)
+ , m_accepted(false)
+{
+ Q_ASSERT(parent);
+ if (QQuickItem *view = qobject_cast<QQuickItem *>(parent))
+ m_position = view->mapFromGlobal(view->cursor().pos()).toPoint();
+}
+
+QQuickWebEngineTooltipRequest::~QQuickWebEngineTooltipRequest()
+{
+
+}
+
+/*!
+ \qmlproperty int TooltipRequest::x
+ \readonly
+
+ The x coordinate of the top-left corner of the requested tooltip.
+*/
+
+int QQuickWebEngineTooltipRequest::x() const
+{
+ return m_position.x();
+}
+
+/*!
+ \qmlproperty int TooltipRequest::y
+ \readonly
+
+ The y coordinate of the top-left corner of the requested tooltip.
+*/
+
+int QQuickWebEngineTooltipRequest::y() const
+{
+ return m_position.y();
+}
+
+/*!
+ \qmlproperty bool TooltipRequest::text
+ \readonly
+
+ The text of the tooltip. It contains an empty string when the
+ tooltip should be hidden.
+*/
+
+
+QString QQuickWebEngineTooltipRequest::text() const
+{
+ return m_text;
+}
+
+/*!
+ \qmlproperty enumeration TooltipRequest::type
+ \readonly
+
+ The type of the tooltip request.
+
+ \value TooltipRequest.Show
+ The tooltip should be shown.
+ \value TooltipRequest.Hide
+ The tooltip should be hidden.
+*/
+
+QQuickWebEngineTooltipRequest::RequestType QQuickWebEngineTooltipRequest::type() const
+{
+ return m_type;
+}
+
+/*!
+ \qmlproperty bool TooltipRequest::accepted
+
+ Indicates whether the tooltip request has been accepted
+ by the signal handler.
+
+ If the property is \c false after any signal handlers
+ for WebEngineView::tooltipRequested have been executed,
+ a default tooltip will be shown.
+ To prevent this, set \c {request.accepted} to \c true.
+
+ The default is \c false.
+*/
+
+bool QQuickWebEngineTooltipRequest::isAccepted() const
+{
+ return m_accepted;
+}
+
+void QQuickWebEngineTooltipRequest::setAccepted(bool accepted)
+{
+ m_accepted = accepted;
+}
+
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebenginedialogrequests_p.h b/src/webengine/api/qquickwebenginedialogrequests_p.h
index cdb10c26b..5e3f7c547 100644
--- a/src/webengine/api/qquickwebenginedialogrequests_p.h
+++ b/src/webengine/api/qquickwebenginedialogrequests_p.h
@@ -260,6 +260,39 @@ private:
friend class QQuickWebEngineViewPrivate;
};
+class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineTooltipRequest : public QObject {
+ Q_OBJECT
+public:
+ enum RequestType {
+ Show,
+ Hide,
+ };
+ Q_ENUM(RequestType)
+ Q_PROPERTY(int x READ x CONSTANT FINAL)
+ Q_PROPERTY(int y READ y CONSTANT FINAL)
+ Q_PROPERTY(QString text READ text CONSTANT FINAL)
+ Q_PROPERTY(RequestType type READ type CONSTANT FINAL)
+ Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted FINAL)
+
+ ~QQuickWebEngineTooltipRequest();
+ int x() const;
+ int y() const;
+ QString text() const;
+ RequestType type() const;
+ bool isAccepted() const;
+ void setAccepted(bool accepted);
+
+private:
+ QQuickWebEngineTooltipRequest(const QString &text = QString(),
+ QObject *parent = nullptr);
+ QPoint m_position;
+ QString m_text;
+ RequestType m_type;
+ bool m_accepted;
+ friend class QQuickWebEngineViewPrivate;
+ Q_DISABLE_COPY(QQuickWebEngineTooltipRequest)
+};
+
QT_END_NAMESPACE
#endif // QQUICKWEBENGINDIALOGREQUESTS_H
diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp
index 7d51ed21d..f9b305e88 100644
--- a/src/webengine/api/qquickwebenginedownloaditem.cpp
+++ b/src/webengine/api/qquickwebenginedownloaditem.cpp
@@ -43,6 +43,7 @@
#include "profile_adapter.h"
#include "qquickwebengineprofile_p.h"
+#include <QDir>
#include "QFileInfo"
using QtWebEngineCore::ProfileAdapterClient;
@@ -98,7 +99,7 @@ static inline QQuickWebEngineDownloadItem::DownloadInterruptReason toDownloadInt
return static_cast<QQuickWebEngineDownloadItem::DownloadInterruptReason>(reason);
}
-QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p)
+QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p, const QUrl &url)
: profile(p)
, downloadId(-1)
, downloadState(QQuickWebEngineDownloadItem::DownloadCancelled)
@@ -110,6 +111,7 @@ QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWeb
, downloadFinished(false)
, downloadPaused(false)
, view(nullptr)
+ , downloadUrl(url)
{
}
@@ -388,6 +390,20 @@ qint64 QQuickWebEngineDownloadItem::receivedBytes() const
}
/*!
+ \qmlproperty url WebEngineDownloadItem::url
+ \readonly
+ \since QtWebEngine 1.10
+
+ Returns the download's origin URL.
+*/
+
+QUrl QQuickWebEngineDownloadItem::url() const
+{
+ Q_D(const QQuickWebEngineDownloadItem);
+ return d->downloadUrl;
+}
+
+/*!
\qmlproperty string WebEngineDownloadItem::mimeType
\since QtWebEngine 1.2
@@ -402,6 +418,7 @@ QString QQuickWebEngineDownloadItem::mimeType() const
/*!
\qmlproperty string WebEngineDownloadItem::path
+ \obsolete
Holds the full target path where data is being downloaded to.
@@ -418,7 +435,7 @@ QString QQuickWebEngineDownloadItem::mimeType() const
QString QQuickWebEngineDownloadItem::path() const
{
Q_D(const QQuickWebEngineDownloadItem);
- return d->downloadPath;
+ return QDir::cleanPath(QDir(d->downloadDirectory).filePath(d->downloadFileName));
}
void QQuickWebEngineDownloadItem::setPath(QString path)
@@ -428,7 +445,7 @@ void QQuickWebEngineDownloadItem::setPath(QString path)
qWarning("Setting the download path is not allowed after the download has been accepted.");
return;
}
- if (d->downloadPath != path) {
+ if (QDir(d->downloadDirectory).filePath(d->downloadFileName) != path) {
if (QFileInfo(path).fileName().isEmpty()) {
qWarning("The download path does not include file name.");
return;
@@ -439,12 +456,127 @@ void QQuickWebEngineDownloadItem::setPath(QString path)
return;
}
- d->downloadPath = path;
+ QString newDirectory;
+ QString newFileName;
+
+ if (QFileInfo(path).fileName() == path) {
+ newDirectory = QStringLiteral("");
+ newFileName = path;
+ } else {
+ newDirectory = QFileInfo(path).filePath();
+ newFileName = QFileInfo(path).fileName();
+ }
+
+ if (d->downloadDirectory != newDirectory) {
+ d->downloadDirectory = newDirectory;
+ Q_EMIT pathChanged();
+ Q_EMIT downloadDirectoryChanged();
+ }
+
+ if (d->downloadFileName != newFileName) {
+ d->downloadFileName = newFileName;
+ Q_EMIT pathChanged();
+ Q_EMIT downloadFileNameChanged();
+ }
+ }
+}
+
+/*!
+ \qmlproperty string WebEngineDownloadItem::downloadDirectory
+ \since QtWebEngine 1.10
+
+ Holds the full target path without file name where data is being downloaded to.
+
+ The download directory can only be set in the
+ \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before
+ the download is accepted.
+
+ \sa WebEngineProfile::downloadRequested(), accept()
+*/
+
+QString QQuickWebEngineDownloadItem::downloadDirectory() const
+{
+ Q_D(const QQuickWebEngineDownloadItem);
+ return d->downloadDirectory;
+}
+
+void QQuickWebEngineDownloadItem::setDownloadDirectory(QString directory)
+{
+ Q_D(QQuickWebEngineDownloadItem);
+ if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested) {
+ qWarning("Setting the download directory is not allowed after the download has been accepted.");
+ return;
+ }
+
+ QString changeDirectory = d->downloadDirectory;
+ if (!directory.isEmpty() && changeDirectory != directory) {
+ changeDirectory = directory;
+
+ if (d->downloadDirectory != changeDirectory) {
+ d->downloadDirectory = changeDirectory;
+ Q_EMIT pathChanged();
+ Q_EMIT downloadDirectoryChanged();
+ }
+
+ QString newFileName = QFileInfo(d->profile->d_ptr->profileAdapter()->updateDownloadPath(d->downloadId,
+ d->downloadDirectory,
+ d->suggestedFileName)).fileName();
+ if (d->downloadFileName != newFileName) {
+ d->downloadFileName = newFileName;
+ Q_EMIT pathChanged();
+ Q_EMIT downloadFileNameChanged();
+ }
+ }
+}
+
+/*!
+ \qmlproperty string WebEngineDownloadItem::downloadFileName
+ \since QtWebEngine 1.10
+
+ Holds the name of the file to which data is being downloaded.
+
+ The download file name can only be set in the
+ \l{WebEngineProfile::downloadRequested}{downloadRequested} handler before
+ the download is accepted.
+
+ \sa WebEngineProfile::downloadRequested(), accept()
+*/
+
+QString QQuickWebEngineDownloadItem::downloadFileName() const
+{
+ Q_D(const QQuickWebEngineDownloadItem);
+ return d->downloadFileName;
+}
+
+void QQuickWebEngineDownloadItem::setDownloadFileName(QString fileName)
+{
+ Q_D(QQuickWebEngineDownloadItem);
+ if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested) {
+ qWarning("Setting the download file name is not allowed after the download has been accepted.");
+ return;
+ }
+
+ if (d->downloadFileName != fileName && !fileName.isEmpty()) {
+ d->downloadFileName = fileName;
Q_EMIT pathChanged();
+ Q_EMIT downloadFileNameChanged();
}
}
/*!
+ \qmlproperty string WebEngineDownloadItem::suggestedFileName
+ \since QtWebEngine 1.10
+
+ Returns the suggested file name.
+*/
+
+QString QQuickWebEngineDownloadItem::suggestedFileName() const
+{
+ Q_D(const QQuickWebEngineDownloadItem);
+ return d->suggestedFileName;
+}
+
+/*!
\qmlproperty enumeration WebEngineDownloadItem::savePageFormat
\since QtWebEngine 1.3
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/webengine/api/qquickwebenginedownloaditem_p.h
index d19ca4828..cef99e534 100644
--- a/src/webengine/api/qquickwebenginedownloaditem_p.h
+++ b/src/webengine/api/qquickwebenginedownloaditem_p.h
@@ -55,6 +55,7 @@
#include <QObject>
#include <QScopedPointer>
#include <QString>
+#include <QUrl>
QT_BEGIN_NAMESPACE
@@ -136,6 +137,10 @@ public:
Q_PROPERTY(bool isPaused READ isPaused NOTIFY isPausedChanged REVISION 5 FINAL)
Q_PROPERTY(bool isSavePageDownload READ isSavePageDownload CONSTANT REVISION 6 FINAL)
Q_PROPERTY(QQuickWebEngineView *view READ view CONSTANT REVISION 7 FINAL)
+ Q_PROPERTY(QUrl url READ url CONSTANT REVISION 8 FINAL)
+ Q_PROPERTY(QString suggestedFileName READ suggestedFileName CONSTANT REVISION 8 FINAL)
+ Q_PROPERTY(QString downloadDirectory READ downloadDirectory WRITE setDownloadDirectory NOTIFY downloadDirectoryChanged REVISION 8 FINAL)
+ Q_PROPERTY(QString downloadFileName READ downloadFileName WRITE setDownloadFileName NOTIFY downloadFileNameChanged REVISION 8 FINAL)
Q_INVOKABLE void accept();
Q_INVOKABLE void cancel();
@@ -147,8 +152,8 @@ public:
qint64 totalBytes() const;
qint64 receivedBytes() const;
QString mimeType() const;
- QString path() const;
- void setPath(QString path);
+ QString Q_DECL_DEPRECATED path() const;
+ void Q_DECL_DEPRECATED setPath(QString path);
SavePageFormat savePageFormat() const;
void setSavePageFormat(SavePageFormat format);
DownloadType Q_DECL_DEPRECATED type() const;
@@ -158,6 +163,12 @@ public:
bool isPaused() const;
bool isSavePageDownload() const;
QQuickWebEngineView *view() const;
+ QUrl url() const;
+ QString suggestedFileName() const;
+ QString downloadDirectory() const;
+ void setDownloadDirectory(QString directory);
+ QString downloadFileName() const;
+ void setDownloadFileName(QString fileName);
Q_SIGNALS:
void stateChanged();
@@ -165,11 +176,13 @@ Q_SIGNALS:
void receivedBytesChanged();
void totalBytesChanged();
Q_REVISION(1) void mimeTypeChanged();
- void pathChanged();
+ void Q_DECL_DEPRECATED pathChanged();
Q_REVISION(3) void typeChanged();
Q_REVISION(4) void interruptReasonChanged();
Q_REVISION(5) void isFinishedChanged();
Q_REVISION(5) void isPausedChanged();
+ Q_REVISION(8) void downloadDirectoryChanged();
+ Q_REVISION(8) void downloadFileNameChanged();
private:
QQuickWebEngineDownloadItem(QQuickWebEngineDownloadItemPrivate*, QObject *parent = 0);
diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
index f444c04a5..51deee18b 100644
--- a/src/webengine/api/qquickwebenginedownloaditem_p_p.h
+++ b/src/webengine/api/qquickwebenginedownloaditem_p_p.h
@@ -67,7 +67,7 @@ class QQuickWebEngineDownloadItemPrivate {
friend class QQuickWebEngineProfilePrivate;
public:
Q_DECLARE_PUBLIC(QQuickWebEngineDownloadItem)
- QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p);
+ QQuickWebEngineDownloadItemPrivate(QQuickWebEngineProfile *p, const QUrl &url);
~QQuickWebEngineDownloadItemPrivate();
quint32 downloadId;
@@ -82,6 +82,10 @@ public:
bool downloadFinished;
bool downloadPaused;
QQuickWebEngineView *view;
+ QUrl downloadUrl;
+ QString suggestedFileName;
+ QString downloadDirectory;
+ QString downloadFileName;
void update(const QtWebEngineCore::ProfileAdapterClient::DownloadItemInfo &info);
void updateState(QQuickWebEngineDownloadItem::DownloadState newState);
diff --git a/src/webengine/api/qquickwebenginenavigationrequest.cpp b/src/webengine/api/qquickwebenginenavigationrequest.cpp
index a6e253561..03c1d3d78 100644
--- a/src/webengine/api/qquickwebenginenavigationrequest.cpp
+++ b/src/webengine/api/qquickwebenginenavigationrequest.cpp
@@ -143,6 +143,8 @@ QQuickWebEngineView::NavigationRequestAction QQuickWebEngineNavigationRequest::a
Using navigation history to go to the previous or next page.
\value WebEngineNavigationRequest.ReloadNavigation
Reloading the page.
+ \value WebEngineNavigationRequest.RedirectNavigation
+ Page content or server triggered a redirection or page refresh.
\value WebEngineNavigationRequest.OtherNavigation
Using some other method to go to a page.
*/
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp
index 4832ba303..57434e296 100644
--- a/src/webengine/api/qquickwebengineprofile.cpp
+++ b/src/webengine/api/qquickwebengineprofile.cpp
@@ -48,6 +48,8 @@
#include "qwebenginecookiestore.h"
#include "qwebenginenotification.h"
+#include <QFileInfo>
+#include <QDir>
#include <QQmlEngine>
#include "profile_adapter.h"
@@ -237,12 +239,14 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
Q_Q(QQuickWebEngineProfile);
Q_ASSERT(!m_ongoingDownloads.contains(info.id));
- QQuickWebEngineDownloadItemPrivate *itemPrivate = new QQuickWebEngineDownloadItemPrivate(q);
+ QQuickWebEngineDownloadItemPrivate *itemPrivate = new QQuickWebEngineDownloadItemPrivate(q, info.url);
itemPrivate->downloadId = info.id;
itemPrivate->downloadState = QQuickWebEngineDownloadItem::DownloadRequested;
itemPrivate->totalBytes = info.totalBytes;
itemPrivate->mimeType = info.mimeType;
- itemPrivate->downloadPath = info.path;
+ itemPrivate->downloadDirectory = QFileInfo(info.path).path();
+ itemPrivate->downloadFileName = QFileInfo(info.path).fileName();
+ itemPrivate->suggestedFileName = info.suggestedFileName;
itemPrivate->savePageFormat = static_cast<QQuickWebEngineDownloadItem::SavePageFormat>(
info.savePageFormat);
itemPrivate->type = static_cast<QQuickWebEngineDownloadItem::DownloadType>(info.downloadType);
@@ -260,7 +264,7 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info)
Q_EMIT q->downloadRequested(download);
QQuickWebEngineDownloadItem::DownloadState state = download->state();
- info.path = download->path();
+ info.path = QDir(download->downloadDirectory()).filePath(download->downloadFileName());
info.savePageFormat = itemPrivate->savePageFormat;
info.accepted = state != QQuickWebEngineDownloadItem::DownloadCancelled
&& state != QQuickWebEngineDownloadItem::DownloadRequested;
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index bb8428951..30283dc03 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -136,7 +136,7 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
memset(actions, 0, sizeof(actions));
QString platform = qApp->platformName().toLower();
- if (platform == QLatin1Literal("eglfs"))
+ if (platform == QLatin1String("eglfs"))
m_ui2Enabled = true;
const QByteArray dialogSet = qgetenv("QTWEBENGINE_DIALOG_SET");
@@ -413,6 +413,11 @@ void QQuickWebEngineViewPrivate::didUpdateTargetURL(const QUrl &hoveredUrl)
Q_EMIT q->linkHovered(hoveredUrl);
}
+void QQuickWebEngineViewPrivate::selectionChanged()
+{
+ updateEditActions();
+}
+
void QQuickWebEngineViewPrivate::recentlyAudibleChanged(bool recentlyAudible)
{
Q_Q(QQuickWebEngineView);
@@ -705,6 +710,25 @@ const QObject *QQuickWebEngineViewPrivate::holdingQObject() const
return q;
}
+void QQuickWebEngineViewPrivate::lifecycleStateChanged(LifecycleState state)
+{
+ Q_Q(QQuickWebEngineView);
+ Q_EMIT q->lifecycleStateChanged(static_cast<QQuickWebEngineView::LifecycleState>(state));
+}
+
+void QQuickWebEngineViewPrivate::recommendedStateChanged(LifecycleState state)
+{
+ Q_Q(QQuickWebEngineView);
+ QTimer::singleShot(0, q, [q, state]() {
+ Q_EMIT q->recommendedStateChanged(static_cast<QQuickWebEngineView::LifecycleState>(state));
+ });
+}
+
+void QQuickWebEngineViewPrivate::visibleChanged(bool visible)
+{
+ Q_UNUSED(visible);
+}
+
#ifndef QT_NO_ACCESSIBILITY
QQuickWebEngineViewAccessible::QQuickWebEngineViewAccessible(QQuickWebEngineView *o)
: QAccessibleObject(o)
@@ -844,8 +868,8 @@ void QQuickWebEngineViewPrivate::initializationFinished()
for (QQuickWebEngineScript *script : qAsConst(m_userScripts))
script->d_func()->bind(profileAdapter()->userResourceController(), adapter.data());
- if (q->window() && q->isVisible())
- adapter->wasShown();
+ if (q->window())
+ adapter->setVisible(q->isVisible());
if (!m_isBeingAdopted)
return;
@@ -944,12 +968,14 @@ void QQuickWebEngineViewPrivate::updateAction(QQuickWebEngineView::WebAction act
break;
case QQuickWebEngineView::Cut:
case QQuickWebEngineView::Copy:
+ case QQuickWebEngineView::Unselect:
+ enabled = adapter->hasFocusedFrame() && !adapter->selectedText().isEmpty();
+ break;
case QQuickWebEngineView::Paste:
case QQuickWebEngineView::Undo:
case QQuickWebEngineView::Redo:
case QQuickWebEngineView::SelectAll:
case QQuickWebEngineView::PasteAndMatchStyle:
- case QQuickWebEngineView::Unselect:
enabled = adapter->hasFocusedFrame();
break;
default:
@@ -1025,13 +1051,13 @@ void QQuickWebEngineView::loadHtml(const QString &html, const QUrl &baseUrl)
void QQuickWebEngineView::goBack()
{
Q_D(QQuickWebEngineView);
- d->adapter->navigateToOffset(-1);
+ d->adapter->navigateBack();
}
void QQuickWebEngineView::goForward()
{
Q_D(QQuickWebEngineView);
- d->adapter->navigateToOffset(1);
+ d->adapter->navigateForward();
}
void QQuickWebEngineView::reload()
@@ -1237,7 +1263,13 @@ bool QQuickWebEngineViewPrivate::isEnabled() const
void QQuickWebEngineViewPrivate::setToolTip(const QString &toolTipText)
{
- ui()->showToolTip(toolTipText);
+ Q_Q(QQuickWebEngineView);
+ QQuickWebEngineTooltipRequest *request = new QQuickWebEngineTooltipRequest(toolTipText, q);
+ // mark the object for gc by creating temporary jsvalue
+ qmlEngine(q)->newQObject(request);
+ Q_EMIT q->tooltipRequested(request);
+ if (!request->isAccepted())
+ ui()->showToolTip(toolTipText);
}
QtWebEngineCore::TouchHandleDrawableClient *QQuickWebEngineViewPrivate::createTouchHandle(const QMap<int, QImage> &images)
@@ -1633,10 +1665,8 @@ void QQuickWebEngineView::itemChange(ItemChange change, const ItemChangeData &va
Q_D(QQuickWebEngineView);
if (d && d->profileInitialized() && d->adapter->isInitialized()
&& (change == ItemSceneChange || change == ItemVisibleHasChanged)) {
- if (window() && isVisible())
- d->adapter->wasShown();
- else
- d->adapter->wasHidden();
+ if (window())
+ d->adapter->setVisible(isVisible());
}
QQuickItem::itemChange(change, value);
}
@@ -1686,10 +1716,10 @@ void QQuickWebEngineView::triggerWebAction(WebAction action)
Q_D(QQuickWebEngineView);
switch (action) {
case Back:
- d->adapter->navigateToOffset(-1);
+ d->adapter->navigateBack();
break;
case Forward:
- d->adapter->navigateToOffset(1);
+ d->adapter->navigateForward();
break;
case Stop:
d->adapter->stop();
@@ -2148,6 +2178,24 @@ void QQuickWebEngineView::lazyInitialize()
d->ensureContentsAdapter();
}
+QQuickWebEngineView::LifecycleState QQuickWebEngineView::lifecycleState() const
+{
+ Q_D(const QQuickWebEngineView);
+ return static_cast<LifecycleState>(d->adapter->lifecycleState());
+}
+
+void QQuickWebEngineView::setLifecycleState(LifecycleState state)
+{
+ Q_D(QQuickWebEngineView);
+ d->adapter->setLifecycleState(static_cast<WebContentsAdapterClient::LifecycleState>(state));
+}
+
+QQuickWebEngineView::LifecycleState QQuickWebEngineView::recommendedState() const
+{
+ Q_D(const QQuickWebEngineView);
+ return static_cast<LifecycleState>(d->adapter->recommendedState());
+}
+
QQuickWebEngineFullScreenRequest::QQuickWebEngineFullScreenRequest()
: m_viewPrivate(0)
, m_toggleOn(false)
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index c851dcb8d..3c8e1d9ec 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -76,6 +76,7 @@ class QQuickWebEngineNavigationRequest;
class QQuickWebEngineNewViewRequest;
class QQuickWebEngineProfile;
class QQuickWebEngineSettings;
+class QQuickWebEngineTooltipRequest;
class QQuickWebEngineFormValidationMessageRequest;
class QQuickWebEngineViewPrivate;
class QWebEngineQuotaRequest;
@@ -104,10 +105,11 @@ private:
const bool m_toggleOn;
};
-#define LATEST_WEBENGINEVIEW_REVISION 9
+#define LATEST_WEBENGINEVIEW_REVISION 10
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_OBJECT
+ Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged FINAL)
Q_PROPERTY(QUrl icon READ icon NOTIFY iconChanged FINAL)
Q_PROPERTY(bool loading READ isLoading NOTIFY loadingChanged FINAL)
@@ -136,6 +138,9 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport NOTIFY testSupportChanged FINAL)
#endif
+ Q_PROPERTY(LifecycleState lifecycleState READ lifecycleState WRITE setLifecycleState NOTIFY lifecycleStateChanged REVISION 11 FINAL)
+ Q_PROPERTY(LifecycleState recommendedState READ recommendedState NOTIFY recommendedStateChanged REVISION 11 FINAL)
+
public:
QQuickWebEngineView(QQuickItem *parent = 0);
~QQuickWebEngineView();
@@ -172,7 +177,8 @@ public:
FormSubmittedNavigation,
BackForwardNavigation,
ReloadNavigation,
- OtherNavigation
+ OtherNavigation,
+ RedirectNavigation,
};
Q_ENUM(NavigationType)
@@ -459,6 +465,14 @@ public:
};
Q_ENUM(PrintedPageOrientation)
+ // must match WebContentsAdapterClient::LifecycleState
+ enum class LifecycleState {
+ Active,
+ Frozen,
+ Discarded,
+ };
+ Q_ENUM(LifecycleState)
+
// QmlParserStatus
void componentComplete() override;
@@ -490,6 +504,11 @@ public:
void setDevToolsView(QQuickWebEngineView *);
QQuickWebEngineView *devToolsView() const;
+ LifecycleState lifecycleState() const;
+ void setLifecycleState(LifecycleState state);
+
+ LifecycleState recommendedState() const;
+
public Q_SLOTS:
void runJavaScript(const QString&, const QJSValue & = QJSValue());
Q_REVISION(3) void runJavaScript(const QString&, quint32 worldId, const QJSValue & = QJSValue());
@@ -552,6 +571,9 @@ Q_SIGNALS:
Q_REVISION(7) void registerProtocolHandlerRequested(const QWebEngineRegisterProtocolHandlerRequest &request);
Q_REVISION(8) void printRequested();
Q_REVISION(9) void selectClientCertificate(QQuickWebEngineClientCertificateSelection *clientCertSelection);
+ Q_REVISION(10) void tooltipRequested(QQuickWebEngineTooltipRequest *request);
+ Q_REVISION(11) void lifecycleStateChanged(LifecycleState state);
+ Q_REVISION(11) void recommendedStateChanged(LifecycleState state);
#if QT_CONFIG(webengine_testsupport)
void testSupportChanged();
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 10fe5c2fd..e0f2595ec 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -101,12 +101,15 @@ public:
QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override;
QtWebEngineCore::RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegateForPopup(QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override;
void initializationFinished() override;
+ void lifecycleStateChanged(LifecycleState state) override;
+ void recommendedStateChanged(LifecycleState state) override;
+ void visibleChanged(bool visible) override;
void titleChanged(const QString&) override;
void urlChanged(const QUrl&) override;
void iconChanged(const QUrl&) override;
void loadProgressChanged(int progress) override;
void didUpdateTargetURL(const QUrl&) override;
- void selectionChanged() override { }
+ void selectionChanged() override;
void recentlyAudibleChanged(bool recentlyAudible) override;
QRectF viewportRect() const override;
QColor backgroundColor() const override;
diff --git a/src/webengine/doc/src/webengineview_lgpl.qdoc b/src/webengine/doc/src/webengineview_lgpl.qdoc
index d256997cc..1c4328d01 100644
--- a/src/webengine/doc/src/webengineview_lgpl.qdoc
+++ b/src/webengine/doc/src/webengineview_lgpl.qdoc
@@ -1506,3 +1506,68 @@
\sa WebEngineClientCertificateSelection
*/
+
+/*!
+ \qmlsignal WebEngineView::tooltipRequested(TooltipRequest request)
+ \since QtWebEngine 1.10
+
+ This signal is emitted when the web page wants to show a tooltip at
+ a specified position.
+
+ \note Signal handlers need to call \c{request.accepted = true} to prevent a default tooltip from showing up.
+
+ \sa TooltipRequest
+*/
+
+/*!
+ \qmlproperty enumeration WebEngineView::LifecycleState
+ \since QtWebEngine 1.11
+
+ This enum describes the lifecycle state of the page:
+
+ \value WebEngineView.LifecycleState.Active
+ Normal state.
+ \value WebEngineView.LifecycleState.Frozen
+ Low CPU usage state where most HTML task sources are suspended.
+ \value WebEngineView.LifecycleState.Discarded
+ Very low resource usage state where the entire browsing context is discarded.
+
+ \sa lifecycleState
+*/
+
+/*!
+ \qmlproperty LifecycleState WebEngineView::lifecycleState
+ \since QtWebEngine 1.11
+
+ \brief The current lifecycle state of the page.
+
+ The following restrictions are enforced by the setter:
+
+ \list
+ \li A visible page must remain in the \c{Active} state.
+ \li If the page is being inspected by a \l{devToolsView} then both pages must
+ remain in the \c{Active} states.
+ \li A page in the \c{Discarded} state can only transition to the \c{Active}
+ state. This will cause a reload of the page.
+ \endlist
+
+ These are the only hard limits on the lifecycle state, but see also
+ \l{recommendedState} for the recommended soft limits.
+
+ \sa recommendedState, {WebEngine Lifecycle Example}
+*/
+
+/*!
+ \qmlproperty LifecycleState WebEngineView::recommendedState
+ \since QtWebEngine 1.11
+
+ \brief The recommended limit for the lifecycle state of the page.
+
+ Setting the lifecycle state to a lower resource usage state than the
+ recommended state may cause side-effects such as stopping background audio
+ playback or loss of HTML form input. Setting the lifecycle state to a higher
+ resource state is however completely safe.
+
+ \sa lifecycleState, {WebEngine Lifecycle Example}
+
+*/
diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp
index 56e5c5c9f..ad49d6543 100644
--- a/src/webengine/plugin/plugin.cpp
+++ b/src/webengine/plugin/plugin.cpp
@@ -95,6 +95,8 @@ public:
qmlRegisterType<QQuickWebEngineView, 7>(uri, 1, 7, "WebEngineView");
qmlRegisterType<QQuickWebEngineView, 8>(uri, 1, 8, "WebEngineView");
qmlRegisterType<QQuickWebEngineView, 9>(uri, 1, 9, "WebEngineView");
+ qmlRegisterType<QQuickWebEngineView, 10>(uri, 1, 10, "WebEngineView");
+ qmlRegisterType<QQuickWebEngineView, 11>(uri, 1, 11, "WebEngineView");
qmlRegisterType<QQuickWebEngineProfile>(uri, 1, 1, "WebEngineProfile");
qmlRegisterType<QQuickWebEngineProfile, 1>(uri, 1, 2, "WebEngineProfile");
qmlRegisterType<QQuickWebEngineProfile, 2>(uri, 1, 3, "WebEngineProfile");
@@ -104,21 +106,23 @@ public:
qmlRegisterType<QQuickWebEngineScript>(uri, 1, 1, "WebEngineScript");
qmlRegisterUncreatableType<QQuickWebEngineCertificateError>(uri, 1, 1, "WebEngineCertificateError", msgUncreatableType("WebEngineCertificateError"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem>(uri, 1, 1, "WebEngineDownloadItem",
- tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 1>(uri, 1, 2, "WebEngineDownloadItem",
- tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 2>(uri, 1, 3, "WebEngineDownloadItem",
- tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 3>(uri, 1, 4, "WebEngineDownloadItem",
- tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 4>(uri, 1, 5, "WebEngineDownloadItem",
- tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 5>(uri, 1, 6, "WebEngineDownloadItem",
- tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 6>(uri, 1, 7, "WebEngineDownloadItem",
- tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 7>(uri, 1, 8, "WebEngineDownloadItem",
- tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ msgUncreatableType("WebEngineDownloadItem"));
+ qmlRegisterUncreatableType<QQuickWebEngineDownloadItem, 8>(uri, 1, 10, "WebEngineDownloadItem",
+ msgUncreatableType("WebEngineDownloadItem"));
qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest>(uri, 1, 1, "WebEngineNewViewRequest", msgUncreatableType("WebEngineNewViewRequest"));
qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest, 1>(uri, 1, 5, "WebEngineNewViewRequest", tr("Cannot create separate instance of WebEngineNewViewRequest"));
qmlRegisterUncreatableType<QQuickWebEngineSettings>(uri, 1, 1, "WebEngineSettings", msgUncreatableType("WebEngineSettings"));
@@ -132,11 +136,11 @@ public:
qmlRegisterUncreatableType<QQuickWebEngineSettings, 8>(uri, 1, 9, "WebEngineSettings", msgUncreatableType("WebEngineSettings"));
qmlRegisterSingletonType<QQuickWebEngineSingleton>(uri, 1, 1, "WebEngine", webEngineSingletonProvider);
qmlRegisterUncreatableType<QQuickWebEngineHistory>(uri, 1, 1, "NavigationHistory",
- tr("Cannot create a separate instance of NavigationHistory"));
+ msgUncreatableType("NavigationHistory"));
qmlRegisterUncreatableType<QQuickWebEngineHistoryListModel>(uri, 1, 1, "NavigationHistoryListModel",
- tr("Cannot create a separate instance of NavigationHistory"));
+ msgUncreatableType("NavigationHistory"));
qmlRegisterUncreatableType<QQuickWebEngineFullScreenRequest>(uri, 1, 1, "FullScreenRequest",
- tr("Cannot create a separate instance of FullScreenRequest"));
+ msgUncreatableType("FullScreenRequest"));
qmlRegisterUncreatableType<QQuickWebEngineContextMenuRequest>(uri, 1, 4, "ContextMenuRequest",
msgUncreatableType("ContextMenuRequest"));
@@ -164,6 +168,8 @@ public:
qmlRegisterUncreatableType<QQuickWebEngineClientCertificateOption>(uri, 1, 9, "WebEngineClientCertificateOption",
msgUncreatableType("WebEngineClientCertificateOption"));
qmlRegisterUncreatableType<QWebEngineNotification>(uri, 1, 9, "WebEngineNotification", msgUncreatableType("WebEngineNotification"));
+ qmlRegisterUncreatableType<QQuickWebEngineTooltipRequest>(uri, 1, 10, "TooltipRequest",
+ msgUncreatableType("TooltipRequest"));
}
private:
diff --git a/src/webengine/plugin/plugin.pro b/src/webengine/plugin/plugin.pro
index 0c1310de3..3b30bece2 100644
--- a/src/webengine/plugin/plugin.pro
+++ b/src/webengine/plugin/plugin.pro
@@ -1,7 +1,7 @@
CXX_MODULE = qml
TARGET = qtwebengineplugin
TARGETPATH = QtWebEngine
-IMPORT_VERSION = 1.9
+IMPORT_VERSION = 1.10
QT += qml quick
QT_PRIVATE += core-private webenginecore-private webengine-private
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
index b636448b3..3a103b9aa 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
+++ b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
@@ -170,12 +170,6 @@ QSGLayer *RenderWidgetHostViewQtDelegateQuick::createLayer()
return renderContext->sceneGraphContext()->createLayer(renderContext);
}
-QSGInternalImageNode *RenderWidgetHostViewQtDelegateQuick::createInternalImageNode()
-{
- QSGRenderContext *renderContext = QQuickWindowPrivate::get(QQuickItem::window())->context;
- return renderContext->sceneGraphContext()->createInternalImageNode();
-}
-
QSGImageNode *RenderWidgetHostViewQtDelegateQuick::createImageNode()
{
return QQuickItem::window()->createImageNode();
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.h b/src/webengine/render_widget_host_view_qt_delegate_quick.h
index 00158b3ac..b55b2d658 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.h
+++ b/src/webengine/render_widget_host_view_qt_delegate_quick.h
@@ -71,7 +71,6 @@ public:
QWindow* window() const override;
QSGTexture *createTextureFromImage(const QImage &) override;
QSGLayer *createLayer() override;
- QSGInternalImageNode *createInternalImageNode() override;
QSGImageNode *createImageNode() override;
QSGRectangleNode *createRectangleNode() override;
void update() override;
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp
index c085aacd7..23b9e02c2 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp
+++ b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp
@@ -131,11 +131,6 @@ QSGLayer *RenderWidgetHostViewQtDelegateQuickWindow::createLayer()
return m_realDelegate->createLayer();
}
-QSGInternalImageNode *RenderWidgetHostViewQtDelegateQuickWindow::createInternalImageNode()
-{
- return m_realDelegate->createInternalImageNode();
-}
-
QSGImageNode *RenderWidgetHostViewQtDelegateQuickWindow::createImageNode()
{
return m_realDelegate->createImageNode();
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h
index ab583bd63..bebbfa439 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h
+++ b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h
@@ -68,7 +68,6 @@ public:
QWindow* window() const override;
QSGTexture *createTextureFromImage(const QImage &) override;
QSGLayer *createLayer() override;
- QSGInternalImageNode *createInternalImageNode() override;
QSGImageNode *createImageNode() override;
QSGRectangleNode *createRectangleNode() override;
void update() override;
diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp
index 2f371efd5..19274bedf 100644
--- a/src/webengine/ui_delegates_manager.cpp
+++ b/src/webengine/ui_delegates_manager.cpp
@@ -539,14 +539,14 @@ void UIDelegatesManager::showMenu(QObject *menu)
void UIDelegatesManager::showToolTip(const QString &text)
{
- if (!ensureComponentLoaded(ToolTip))
- return;
-
if (text.isEmpty()) {
m_toolTip.reset();
return;
}
+ if (!ensureComponentLoaded(ToolTip))
+ return;
+
if (!m_toolTip.isNull())
return;