diff options
Diffstat (limited to 'src/webengine')
-rw-r--r-- | src/webengine/api/qquickwebenginedownloaditem.cpp | 9 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginedownloaditem_p.h | 10 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineprofile.cpp | 8 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginesettings.cpp | 2 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview.cpp | 6 | ||||
-rw-r--r-- | src/webengine/doc/src/qtwebengine-features.qdoc | 85 | ||||
-rw-r--r-- | src/webengine/doc/src/qtwebengine-platform-notes.qdoc | 2 | ||||
-rw-r--r-- | src/webengine/doc/src/qtwebengine-qmlmodule.qdoc | 4 | ||||
-rw-r--r-- | src/webengine/doc/src/webengineview_lgpl.qdoc | 30 | ||||
-rw-r--r-- | src/webengine/plugin/plugin.cpp | 2 | ||||
-rw-r--r-- | src/webengine/render_widget_host_view_qt_delegate_quick.cpp | 4 | ||||
-rw-r--r-- | src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp | 2 | ||||
-rw-r--r-- | src/webengine/ui/ToolTip.qml | 8 |
13 files changed, 134 insertions, 38 deletions
diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp index f9b305e88..878dddadb 100644 --- a/src/webengine/api/qquickwebenginedownloaditem.cpp +++ b/src/webengine/api/qquickwebenginedownloaditem.cpp @@ -420,6 +420,9 @@ QString QQuickWebEngineDownloadItem::mimeType() const \qmlproperty string WebEngineDownloadItem::path \obsolete + Use \l suggestedFileName, \l downloadDirectory, and + \l downloadFileName instead. + Holds the full target path where data is being downloaded to. The path includes the file name. The default suggested path is the standard @@ -463,7 +466,7 @@ void QQuickWebEngineDownloadItem::setPath(QString path) newDirectory = QStringLiteral(""); newFileName = path; } else { - newDirectory = QFileInfo(path).filePath(); + newDirectory = QFileInfo(path).path(); newFileName = QFileInfo(path).fileName(); } @@ -500,7 +503,7 @@ QString QQuickWebEngineDownloadItem::downloadDirectory() const return d->downloadDirectory; } -void QQuickWebEngineDownloadItem::setDownloadDirectory(QString directory) +void QQuickWebEngineDownloadItem::setDownloadDirectory(const QString &directory) { Q_D(QQuickWebEngineDownloadItem); if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested) { @@ -548,7 +551,7 @@ QString QQuickWebEngineDownloadItem::downloadFileName() const return d->downloadFileName; } -void QQuickWebEngineDownloadItem::setDownloadFileName(QString fileName) +void QQuickWebEngineDownloadItem::setDownloadFileName(const QString &fileName) { Q_D(QQuickWebEngineDownloadItem); if (d->downloadState != QQuickWebEngineDownloadItem::DownloadRequested) { diff --git a/src/webengine/api/qquickwebenginedownloaditem_p.h b/src/webengine/api/qquickwebenginedownloaditem_p.h index cef99e534..96ef0daf0 100644 --- a/src/webengine/api/qquickwebenginedownloaditem_p.h +++ b/src/webengine/api/qquickwebenginedownloaditem_p.h @@ -152,8 +152,8 @@ public: qint64 totalBytes() const; qint64 receivedBytes() const; QString mimeType() const; - QString Q_DECL_DEPRECATED path() const; - void Q_DECL_DEPRECATED setPath(QString path); + QString path() const; + void setPath(QString path); SavePageFormat savePageFormat() const; void setSavePageFormat(SavePageFormat format); DownloadType Q_DECL_DEPRECATED type() const; @@ -166,9 +166,9 @@ public: QUrl url() const; QString suggestedFileName() const; QString downloadDirectory() const; - void setDownloadDirectory(QString directory); + void setDownloadDirectory(const QString &directory); QString downloadFileName() const; - void setDownloadFileName(QString fileName); + void setDownloadFileName(const QString &fileName); Q_SIGNALS: void stateChanged(); @@ -176,7 +176,7 @@ Q_SIGNALS: void receivedBytesChanged(); void totalBytesChanged(); Q_REVISION(1) void mimeTypeChanged(); - void Q_DECL_DEPRECATED pathChanged(); + void pathChanged(); Q_REVISION(3) void typeChanged(); Q_REVISION(4) void interruptReasonChanged(); Q_REVISION(5) void isFinishedChanged(); diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index 57434e296..edad7ec44 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -157,7 +157,10 @@ ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineC \fn QQuickWebEngineProfile::presentNotification(QWebEngineNotification *notification) This signal is emitted whenever there is a newly created user notification. - The \a notification argument holds the notification instance to query data and interact with. + The \a notification argument holds the \l {QWebEngineNotification} instance + to query data and interact with. + + \sa WebEngineProfile::presentNotification */ QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(ProfileAdapter *profileAdapter) @@ -395,7 +398,8 @@ void QQuickWebEngineProfilePrivate::userScripts_clear(QQmlListProperty<QQuickWeb \since QtWebEngine 1.9 This signal is emitted whenever there is a newly created user notification. - The \a notification argument holds the notification instance to query data and interact with. + The \a notification argument holds the \l {WebEngineNotification} instance + to query data and interact with. */ /*! diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp index 93a3668ed..9a102a504 100644 --- a/src/webengine/api/qquickwebenginesettings.cpp +++ b/src/webengine/api/qquickwebenginesettings.cpp @@ -250,7 +250,7 @@ bool QQuickWebEngineSettings::pluginsEnabled() const Tells the web engine whether fullscreen is supported in this application or not. - Enabled by default. + Disabled by default. */ bool QQuickWebEngineSettings::fullScreenSupportEnabled() const { diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 58d950cd9..8a1a3c516 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -297,7 +297,7 @@ void QQuickWebEngineViewPrivate::allowCertificateError(const QSharedPointer<Cert // mark the object for gc by creating temporary jsvalue qmlEngine(q)->newQObject(quickController); Q_EMIT q->certificateError(quickController); - if (!quickController->deferred() && !quickController->answered()) + if (!quickController->overridable() || (!quickController->deferred() && !quickController->answered())) quickController->rejectCertificate(); else m_certificateErrorControllers.append(errorController); @@ -1152,9 +1152,7 @@ void QQuickWebEngineViewPrivate::updateAdapter() adapter->setClient(this); if (wasInitialized) { if (!m_html.isEmpty()) - adapter->setContent(m_html.toUtf8(), defaultMimeType, m_url); - else if (m_url.isValid()) - adapter->load(m_url); + adapter->setContent(m_html.toUtf8(), defaultMimeType, activeUrl); else if (activeUrl.isValid()) adapter->load(activeUrl); else diff --git a/src/webengine/doc/src/qtwebengine-features.qdoc b/src/webengine/doc/src/qtwebengine-features.qdoc index 08c189740..22eb72408 100644 --- a/src/webengine/doc/src/qtwebengine-features.qdoc +++ b/src/webengine/doc/src/qtwebengine-features.qdoc @@ -45,12 +45,13 @@ \li \l{Native Dialogs} \li \l{Pepper Plugin API} \li \l{PDF File Viewing} + \li \l{Page Lifecycle API} \li \l{Print to PDF} \li \l{Process Models} \li \l{Spellchecker} \li \l{Touch} \li \l{View Source} - \li \l{WebRTC} + \li \l{webrtc_feature}{WebRTC} \li \l{Web Notifications} \endlist @@ -126,7 +127,9 @@ so uniquely identifies the user and might violate privacy expectations. To activate support for client certificates, an application needs to listen to - the QWebEnginePage::selectClientCertificate signal and select one of the offered + the QWebEnginePage::selectClientCertificate or + \l{WebEnginePage::selectClientCertificate}{WebEnginePage.selectClientCertificate} + signals and select one of the offered certificates. For applications that can navigate to untrusted web sites, it is recommended to always give the user a choice before uniquely identifying them to a remote server. @@ -335,6 +338,83 @@ Support for this feature was added in Qt 5.13.0. + \section1 Page Lifecycle API + + \QWE supports the \l {https://wicg.github.io/page-lifecycle/spec.html}{Page + Lifecycle API specification}, a work-in-progress extension to the HTML + standard for allowing user agents to reduce their resource consumption by + freezing or discarding background pages. The feature is exposed both in the + Widgets and QML APIs. + + For an example of the QML API in use, see the \l {WebEngine Lifecycle + Example}. + + Support for this feature was added in Qt 5.14.0. + + \section2 Overview of Lifecycle States + + Each \l {WebEngineView} item (or \l {QWebEnginePage} object) can be in one + of three \e {lifecycle states}: active, frozen, or discarded. These states, + like the sleep states of a CPU, control the resource usage of web views. + + The \e {active} state is the normal, unrestricted state of a web view. All + visible web views are always in the active state, as are all web views that + have not yet finished loading. Only invisible, idle web views can be + transitioned to other lifecycle states. + + The \e {frozen} state is a low CPU usage state. In this state, most HTML + task sources are suspended (frozen) and, as a result, most DOM event + processing and JavaScript execution will also be suspended. The web view + must be invisible in order to be frozen as rendering is not possible in this + state. + + The \e {discarded} state is an extreme resource-saving state. In this state, + the browsing context of the web view will be discarded and the corresponding + renderer subprocess shut down. CPU and memory usage in this state is reduced + virtually to zero. On exiting this state the web page will be automatically + reloaded. The process of entering and exiting the discarded state is similar + to serializing the browsing history of the web view and destroying the view, + then creating a new view and restoring its history. + + See also \l {WebEngineView::LifecycleState}. The equivalent in the Widgets + API is \l {QWebEnginePage::LifecycleState}. + + \section2 The \c {lifecycleState} and \c {recommendedState} Properties + + The \l {WebEngineView::}{lifecycleState} property of the \l {WebEngineView} + type is a read-write property that controls the current lifecycle state of + the web view. This property is designed to place as few restrictions as + possible on what states can be transitioned to. For example, it is allowed + to freeze a web view that is currently playing music in the background, + stopping the music. In order to implement a less aggressive resource-saving + strategy that avoids interrupting user-visible background activity, the \l + {WebEngineView::} {recommendedState} property must be used. + + The \l {WebEngineView::}{recommendedState} property of the \l + {WebEngineView} type is a read-only property that calculates a safe limit on + the \l {WebEngineView::}{lifecycleState} property, taking into account the + current activity of the web view. So, in the example of a web view playing + music in the background, the recommended state will be \c {Active} since a + more aggressive state would stop the music. If the application wants to + avoid interrupting background activity, then it should avoid putting the web + view into a more aggressively resource-saving lifecycle state than what's + given by \l {WebEngineView::}{recommendedState}. + + See also \l {WebEngineView::lifecycleState} and \l + {WebEngineView::recommendedState}. The equivalents in the Widgets API are \l + {QWebEnginePage::lifecycleState} and \l {QWebEnginePage::recommendedState}. + + \section2 The DOM Extensions + + The \l {WebEngineView::}{lifecycleState} property is connected to the \l + {https://wicg.github.io/page-lifecycle/spec.html}{Page Lifecycle API + specification}, which specifies two new DOM events, \c {freeze} and \c + {resume}, and adds a new \c {Document.wasDiscarded} boolean property. The \c + {freeze} and \c {resume} events are fired when transitioning from the \c + {Active} to the \c {Frozen state}, and vice-versa. The \c + {Document.wasDiscarded} property is set to \c {true} when transitioning from + the \c {Discarded} state to the \c {Active} state. + \section1 Print to PDF \QWE supports printing a web page to a PDF file. For more @@ -519,6 +599,7 @@ Support for this feature was added in Qt 5.8.0. + \target webrtc_feature \section1 WebRTC WebRTC provides browsers with Real-Time Communications (RTC) capabilities diff --git a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc index 5b7d750ff..5d32fa6c7 100644 --- a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc +++ b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc @@ -73,6 +73,8 @@ \list \li Visual Studio 2017 version 15.8 or later + \li Active Template Library (ATL), usually included in the Visual Studio + installation \li Windows 10 SDK \endlist diff --git a/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc b/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc index 540d74035..44e6c7e27 100644 --- a/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc +++ b/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \qmlmodule QtWebEngine 1.9 + \qmlmodule QtWebEngine 1.10 \title Qt WebEngine QML Types \brief Provides QML types for rendering web content within a QML application. \ingroup qtwebengine-modules @@ -36,7 +36,7 @@ your .qml file: \badcode - import QtWebEngine 1.9 + import QtWebEngine 1.10 \endcode To link against the module, add the following QT variable to your qmake .pro diff --git a/src/webengine/doc/src/webengineview_lgpl.qdoc b/src/webengine/doc/src/webengineview_lgpl.qdoc index 8f03774c8..3a7717bd2 100644 --- a/src/webengine/doc/src/webengineview_lgpl.qdoc +++ b/src/webengine/doc/src/webengineview_lgpl.qdoc @@ -396,7 +396,7 @@ runJavaScript("document.title", function(result) { console.log(result); }); \endcode - Only "plain data" can be returned from JavaScript as the result value. + Only plain data can be returned from JavaScript as the result value. Supported data types include all of the JSON data types as well as, for example, \c{Date} and \c{ArrayBuffer}. Unsupported data types include, for example, \c{Function} and \c{Promise}. @@ -407,7 +407,8 @@ \warning Do not execute lengthy routines in the callback function, because it might block the rendering of the web content. - See WebEngineView::userScripts for an alternative API to inject scripts. + For more information about injecting scripts, see \l {Script Injection}. + For an alternative way to inject scripts, see WebEngineView::userScripts. */ /*! @@ -444,14 +445,13 @@ To clear the search highlight, just pass an empty string. - The \a resultCallback must take a boolean parameter. It will be called with - a value of true if the \a subString was found; otherwise the callback value - will be false. + The \a resultCallback must take an integer parameter. It will be called with + the number of found occurrences of the \a subString. \code - findText("Qt", WebEngineView.FindCaseSensitively, function(success) { - if (success) - console.log("Qt was found!"); + findText("Qt", WebEngineView.FindCaseSensitively, function(matchCount) { + if (matchCount > 0) + console.log("'Qt' tokens found:", matchCount); }); \endcode @@ -1530,7 +1530,7 @@ /*! \qmlproperty enumeration WebEngineView::LifecycleState - \since QtWebEngine 1.11 + \since QtWebEngine 1.10 This enum describes the lifecycle state of the page: @@ -1541,12 +1541,12 @@ \value WebEngineView.LifecycleState.Discarded Very low resource usage state where the entire browsing context is discarded. - \sa lifecycleState + \sa lifecycleState, {Page Lifecycle API}, {WebEngine Lifecycle Example} */ /*! \qmlproperty LifecycleState WebEngineView::lifecycleState - \since QtWebEngine 1.11 + \since QtWebEngine 1.10 \brief The current lifecycle state of the page. @@ -1563,12 +1563,12 @@ 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} + \sa recommendedState, {Page Lifecycle API}, {WebEngine Lifecycle Example} */ /*! \qmlproperty LifecycleState WebEngineView::recommendedState - \since QtWebEngine 1.11 + \since QtWebEngine 1.10 \brief The recommended limit for the lifecycle state of the page. @@ -1577,14 +1577,14 @@ 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} + \sa lifecycleState, {Page Lifecycle API}, {WebEngine Lifecycle Example} */ /*! \qmltype FindTextResult \instantiates QWebEngineFindTextResult \inqmlmodule QtWebEngine - \since QtWebEngine 1.11 + \since QtWebEngine 1.10 \brief A utility type for encapsulating the result of a string search on a page. diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp index e47a46a95..5fb48d867 100644 --- a/src/webengine/plugin/plugin.cpp +++ b/src/webengine/plugin/plugin.cpp @@ -164,10 +164,12 @@ public: qmlRegisterUncreatableType<QWebEngineRegisterProtocolHandlerRequest>(uri, 1, 7, "RegisterProtocolHandlerRequest", msgUncreatableType("RegisterProtocolHandlerRequest")); qmlRegisterUncreatableType<QQuickWebEngineAction>(uri, 1, 8, "WebEngineAction", msgUncreatableType("WebEngineAction")); +#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) qmlRegisterUncreatableType<QQuickWebEngineClientCertificateSelection>(uri, 1, 9, "WebEngineClientCertificateSelection", msgUncreatableType("WebEngineClientCertificateSelection")); qmlRegisterUncreatableType<QQuickWebEngineClientCertificateOption>(uri, 1, 9, "WebEngineClientCertificateOption", msgUncreatableType("WebEngineClientCertificateOption")); +#endif qmlRegisterUncreatableType<QWebEngineNotification>(uri, 1, 9, "WebEngineNotification", msgUncreatableType("WebEngineNotification")); qmlRegisterUncreatableType<QQuickWebEngineTooltipRequest>(uri, 1, 10, "TooltipRequest", msgUncreatableType("TooltipRequest")); 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 3a103b9aa..ac32671aa 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp +++ b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp @@ -106,7 +106,11 @@ QRectF RenderWidgetHostViewQtDelegateQuick::viewGeometry() const const QPointF p2 = mapToGlobal(mapFromScene(QPointF(width(), height()))); QRectF geometry = QRectF(p1, p2).normalized(); // But keep the size untransformed to behave like other QQuickItems. +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) geometry.setSize(size()); +#else + geometry.setSize(QSizeF(width(), height())); +#endif return geometry; } 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 23b9e02c2..d3ebdbf27 100644 --- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp +++ b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.cpp @@ -48,7 +48,7 @@ RenderWidgetHostViewQtDelegateQuickWindow::RenderWidgetHostViewQtDelegateQuickWi : m_realDelegate(realDelegate) , m_virtualParent(nullptr) { - setFlags(Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus); + setFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus); } RenderWidgetHostViewQtDelegateQuickWindow::~RenderWidgetHostViewQtDelegateQuickWindow() diff --git a/src/webengine/ui/ToolTip.qml b/src/webengine/ui/ToolTip.qml index 96033e8f1..2bfe9eaf5 100644 --- a/src/webengine/ui/ToolTip.qml +++ b/src/webengine/ui/ToolTip.qml @@ -47,8 +47,9 @@ Item { visible: false property alias text: toolTip.text - property int delayTimerInterval: 1000 - property int hideTimerInterval: 1500 + property int delayTimerInterval: 500 + property int hideTimerInterval: 10000 + property int toolTipMaxWidth: 400 Timer { id: delayTimer @@ -77,7 +78,8 @@ Item { Text { id: toolTip anchors {fill: parent; margins: 5} - wrapMode: Text.WrapAnywhere + wrapMode: Text.Wrap + width: Math.min(toolTipMaxWidth, (toolTip.text.length +1) * 8) } } |