diff options
author | Liang Qi <liang.qi@qt.io> | 2016-08-04 07:29:26 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-08-05 11:35:18 +0200 |
commit | 179463fd2b17343dae291ab6f7617311bcfbdb75 (patch) | |
tree | e32e298ca5d6e2b6e206dab7d42538a6ce68eba1 /src/webengine/api | |
parent | c8851dd1a77e730bc6a3c17b7c75b1a4c6b41f53 (diff) | |
parent | 336e706cbc839dd7b7c1d461b6b015600b5f009e (diff) |
Merge remote-tracking branch 'origin/5.7' into dev
Also blacklist tst_QWebEnginePage::comboBoxPopupPositionAfterChildMove()
and comboBoxPopupPositionAfterMove().
Conflicts:
.qmake.conf
src/3rdparty
src/core/render_widget_host_view_qt.cpp
src/core/resources/resources.gyp
src/webengine/doc/src/qtwebengine-platform-notes.qdoc
src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
tests/auto/widgets/qwebenginepage/BLACKLIST
tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
tools/qmake/mkspecs/features/functions.prf
Task-number: QTBUG-55158
Change-Id: I1d73ac9b3ca5293ad3c7e3a56f4c395da930e6f4
Diffstat (limited to 'src/webengine/api')
-rw-r--r-- | src/webengine/api/qquickwebenginecontextmenudata.cpp | 16 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginenewviewrequest_p.h | 2 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview.cpp | 48 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview_p_p.h | 6 |
4 files changed, 54 insertions, 18 deletions
diff --git a/src/webengine/api/qquickwebenginecontextmenudata.cpp b/src/webengine/api/qquickwebenginecontextmenudata.cpp index 16cb4ff69..269d655a2 100644 --- a/src/webengine/api/qquickwebenginecontextmenudata.cpp +++ b/src/webengine/api/qquickwebenginecontextmenudata.cpp @@ -74,7 +74,7 @@ QQuickWebEngineContextMenuData::~QQuickWebEngineContextMenuData() } /*! - \qmlproperty bool WebEngineDownloadItem::isValid + \qmlproperty bool WebEngineContextMenuData::isValid Is \c true if the context data is valid; otherwise \c false. */ @@ -84,7 +84,7 @@ bool QQuickWebEngineContextMenuData::isValid() const } /*! - \qmlproperty QPoint WebEngineDownloadItem::position + \qmlproperty QPoint WebEngineContextMenuData::position Returns the position of the context, usually the mouse position where the context menu event was triggered. @@ -95,7 +95,7 @@ QPoint QQuickWebEngineContextMenuData::position() const } /*! - \qmlproperty QString WebEngineDownloadItem::linkText + \qmlproperty QString WebEngineContextMenuData::linkText Returns the text of a link if the context is a link. */ @@ -105,7 +105,7 @@ QString QQuickWebEngineContextMenuData::linkText() const } /*! - \qmlproperty QUrl WebEngineDownloadItem::linkUrl + \qmlproperty QUrl WebEngineContextMenuData::linkUrl Returns the URL of a link if the context is a link. */ @@ -115,7 +115,7 @@ QUrl QQuickWebEngineContextMenuData::linkUrl() const } /*! - \qmlproperty QString WebEngineDownloadItem::selectedText + \qmlproperty QString WebEngineContextMenuData::selectedText Returns the selected text of the context. */ @@ -125,7 +125,7 @@ QString QQuickWebEngineContextMenuData::selectedText() const } /*! - \qmlproperty QUrl WebEngineDownloadItem::mediaUrl + \qmlproperty QUrl WebEngineContextMenuData::mediaUrl If the context is a media element, returns the URL of that media. */ @@ -135,7 +135,7 @@ QUrl QQuickWebEngineContextMenuData::mediaUrl() const } /*! - \qmlproperty MediaType WebEngineDownloadItem::mediaType + \qmlproperty MediaType WebEngineContextMenuData::mediaType Returns the type of the media element or \c MediaTypeNone if the context is not a media element. @@ -161,7 +161,7 @@ QQuickWebEngineContextMenuData::MediaType QQuickWebEngineContextMenuData::mediaT } /*! - \qmlproperty bool WebEngineDownloadItem::isContentEditable + \qmlproperty bool WebEngineContextMenuData::isContentEditable Returns \c true if the content is editable by the user; otherwise returns \c false. */ diff --git a/src/webengine/api/qquickwebenginenewviewrequest_p.h b/src/webengine/api/qquickwebenginenewviewrequest_p.h index e8665ba45..fd7fc42f4 100644 --- a/src/webengine/api/qquickwebenginenewviewrequest_p.h +++ b/src/webengine/api/qquickwebenginenewviewrequest_p.h @@ -75,7 +75,7 @@ private: QQuickWebEngineNewViewRequest(); QQuickWebEngineView::NewViewDestination m_destination; bool m_isUserInitiated; - QExplicitlySharedDataPointer<QtWebEngineCore::WebContentsAdapter> m_adapter; + QSharedPointer<QtWebEngineCore::WebContentsAdapter> m_adapter; QUrl m_requestedUrl; friend class QQuickWebEngineView; friend class QQuickWebEngineViewPrivate; diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 0170018e7..02484548b 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -93,6 +93,27 @@ QT_BEGIN_NAMESPACE using namespace QtWebEngineCore; +QQuickWebEngineView::WebAction editorActionForKeyEvent(QKeyEvent* event) +{ + static struct { + QKeySequence::StandardKey standardKey; + QQuickWebEngineView::WebAction action; + } editorActions[] = { + { QKeySequence::Cut, QQuickWebEngineView::Cut }, + { QKeySequence::Copy, QQuickWebEngineView::Copy }, + { QKeySequence::Paste, QQuickWebEngineView::Paste }, + { QKeySequence::Undo, QQuickWebEngineView::Undo }, + { QKeySequence::Redo, QQuickWebEngineView::Redo }, + { QKeySequence::SelectAll, QQuickWebEngineView::SelectAll }, + { QKeySequence::UnknownKey, QQuickWebEngineView::NoWebAction } + }; + for (int i = 0; editorActions[i].standardKey != QKeySequence::UnknownKey; ++i) + if (event == editorActions[i].standardKey) + return editorActions[i].action; + + return QQuickWebEngineView::NoWebAction; +} + #ifndef QT_NO_ACCESSIBILITY static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *object) { @@ -356,7 +377,8 @@ void QQuickWebEngineViewPrivate::allowCertificateError(const QSharedPointer<Cert Q_Q(QQuickWebEngineView); QQuickWebEngineCertificateError *quickController = new QQuickWebEngineCertificateError(errorController); - QQmlEngine::setObjectOwnership(quickController, QQmlEngine::JavaScriptOwnership); + // mark the object for gc by creating temporary jsvalue + qmlEngine(q)->newQObject(quickController); Q_EMIT q->certificateError(quickController); if (!quickController->deferred() && !quickController->answered()) quickController->rejectCertificate(); @@ -539,11 +561,23 @@ void QQuickWebEngineViewPrivate::focusContainer() void QQuickWebEngineViewPrivate::unhandledKeyEvent(QKeyEvent *event) { Q_Q(QQuickWebEngineView); +#ifdef Q_OS_OSX + if (event->type() == QEvent::KeyPress) { + QQuickWebEngineView::WebAction action = editorActionForKeyEvent(event); + if (action != QQuickWebEngineView::NoWebAction) { + // Try triggering a registered short-cut + if (QGuiApplicationPrivate::instance()->shortcutMap.tryShortcut(event)) + return; + q->triggerWebAction(action); + return; + } + } +#endif if (q->parentItem()) q->window()->sendEvent(q->parentItem(), event); } -void QQuickWebEngineViewPrivate::adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &) +void QQuickWebEngineViewPrivate::adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &) { Q_Q(QQuickWebEngineView); QQuickWebEngineNewViewRequest request; @@ -749,7 +783,7 @@ QAccessible::State QQuickWebEngineViewAccessible::state() const class WebContentsAdapterOwner : public QObject { public: - typedef QExplicitlySharedDataPointer<QtWebEngineCore::WebContentsAdapter> AdapterPtr; + typedef QSharedPointer<QtWebEngineCore::WebContentsAdapter> AdapterPtr; WebContentsAdapterOwner(const AdapterPtr &ptr) : adapter(ptr) {} @@ -776,9 +810,9 @@ void QQuickWebEngineViewPrivate::adoptWebContents(WebContentsAdapter *webContent // This throws away the WebContentsAdapter that has been used until now. // All its states, particularly the loading URL, are replaced by the adopted WebContentsAdapter. - WebContentsAdapterOwner *adapterOwner = new WebContentsAdapterOwner(adapter); + WebContentsAdapterOwner *adapterOwner = new WebContentsAdapterOwner(adapter->sharedFromThis()); adapterOwner->deleteLater(); - adapter = webContents; + adapter = webContents->sharedFromThis(); adapter->initialize(this); // associate the webChannel with the new adapter @@ -835,7 +869,7 @@ void QQuickWebEngineViewPrivate::ensureContentsAdapter() { Q_Q(QQuickWebEngineView); if (!adapter) { - adapter = new WebContentsAdapter(); + adapter = QSharedPointer<WebContentsAdapter>::create(); adapter->initialize(this); if (m_backgroundColor != Qt::white) adapter->backgroundColorChanged(); @@ -995,7 +1029,7 @@ void QQuickWebEngineViewPrivate::setProfile(QQuickWebEngineProfile *profile) if (adapter && adapter->browserContext() != browserContextAdapter()->browserContext()) { // When the profile changes we need to create a new WebContentAdapter and reload the active URL. QUrl activeUrl = adapter->activeUrl(); - adapter = 0; + adapter.reset(); ensureContentsAdapter(); if (!explicitUrl.isValid() && activeUrl.isValid()) diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index 45332ddb1..66952ca6e 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -73,6 +73,8 @@ class QQmlContext; class QQuickWebEngineSettings; class QQuickWebEngineFaviconProvider; +QQuickWebEngineView::WebAction editorActionForKeyEvent(QKeyEvent* event); + #ifdef ENABLE_QML_TESTSUPPORT_API class QQuickWebEngineTestSupport; #endif @@ -150,7 +152,7 @@ public: virtual void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) Q_DECL_OVERRIDE; virtual void focusContainer() Q_DECL_OVERRIDE; virtual void unhandledKeyEvent(QKeyEvent *event) Q_DECL_OVERRIDE; - virtual void adoptNewWindow(QtWebEngineCore::WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &) Q_DECL_OVERRIDE; + virtual void adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &) Q_DECL_OVERRIDE; virtual bool isBeingAdopted() Q_DECL_OVERRIDE; virtual void close() Q_DECL_OVERRIDE; virtual void windowCloseRejected() Q_DECL_OVERRIDE; @@ -206,7 +208,7 @@ public: static QQuickWebEngineScript *userScripts_at(QQmlListProperty<QQuickWebEngineScript> *p, int idx); static void userScripts_clear(QQmlListProperty<QQuickWebEngineScript> *p); - QExplicitlySharedDataPointer<QtWebEngineCore::WebContentsAdapter> adapter; + QSharedPointer<QtWebEngineCore::WebContentsAdapter> adapter; QScopedPointer<QQuickWebEngineViewExperimental> e; QScopedPointer<QQuickWebEngineViewport> v; QScopedPointer<QQuickWebEngineHistory> m_history; |