ca92b35948
Moved from aports/main to aports/luna, so we can disable the entire folder from building in the binary repository: * qt5-qtwebengine * postmarketos-ui-luna
221 lines
14 KiB
Diff
221 lines
14 KiB
Diff
From 6b2af4e2c792469a15f53e6dd115357490a2b92a Mon Sep 17 00:00:00 2001
|
|
From: Christophe Chapuis <chris.chapuis@gmail.com>
|
|
Date: Mon, 28 Sep 2015 20:19:14 +0200
|
|
Subject: [PATCH 02/18] WebEngineView: provide additionnal features from
|
|
window.open on the Qt side
|
|
|
|
Signed-off-by: Christophe Chapuis <chris.chapuis@gmail.com>
|
|
---
|
|
src/core/web_contents_adapter_client.h | 2 +-
|
|
src/core/web_contents_delegate_qt.cpp | 17 ++++++++++++-----
|
|
src/core/web_contents_delegate_qt.h | 4 ++--
|
|
src/webengine/api/qquickwebenginenewviewrequest.cpp | 5 +++++
|
|
src/webengine/api/qquickwebenginenewviewrequest_p.h | 5 +++++
|
|
src/webengine/api/qquickwebengineview.cpp | 3 ++-
|
|
src/webengine/api/qquickwebengineview_p_p.h | 2 +-
|
|
src/webenginewidgets/api/qwebenginepage.cpp | 3 ++-
|
|
src/webenginewidgets/api/qwebenginepage_p.h | 2 +-
|
|
9 files changed, 31 insertions(+), 12 deletions(-)
|
|
|
|
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
|
|
index e1fb3dc..ad62397 100644
|
|
--- a/src/core/web_contents_adapter_client.h
|
|
+++ b/src/core/web_contents_adapter_client.h
|
|
@@ -330,7 +330,7 @@ public:
|
|
virtual void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) = 0;
|
|
virtual void focusContainer() = 0;
|
|
virtual void unhandledKeyEvent(QKeyEvent *event) = 0;
|
|
- virtual void adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect & initialGeometry, const QUrl &targetUrl) = 0;
|
|
+ virtual void adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect & initialGeometry, const QUrl &targetUrl, const QStringList &additionalFeatures) = 0;
|
|
virtual bool isBeingAdopted() = 0;
|
|
virtual void close() = 0;
|
|
virtual void windowCloseRejected() = 0;
|
|
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
|
|
index 86366ab..68d5abc 100644
|
|
--- a/src/core/web_contents_delegate_qt.cpp
|
|
+++ b/src/core/web_contents_delegate_qt.cpp
|
|
@@ -102,7 +102,8 @@ content::WebContents *WebContentsDelegateQt::OpenURLFromTab(content::WebContents
|
|
{
|
|
content::WebContents *target = source;
|
|
if (params.disposition != WindowOpenDisposition::CURRENT_TAB) {
|
|
- QSharedPointer<WebContentsAdapter> targetAdapter = createWindow(0, params.disposition, gfx::Rect(), params.user_gesture);
|
|
+ std::vector<base::string16> additional_features;
|
|
+ QSharedPointer<WebContentsAdapter> targetAdapter = createWindow(0, params.disposition, gfx::Rect(), params.user_gesture, additional_features);
|
|
if (targetAdapter)
|
|
target = targetAdapter->webContents();
|
|
}
|
|
@@ -158,10 +159,10 @@ bool WebContentsDelegateQt::ShouldPreserveAbortedURLs(content::WebContents *sour
|
|
return false;
|
|
}
|
|
|
|
-void WebContentsDelegateQt::AddNewContents(content::WebContents* source, content::WebContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture, bool* was_blocked)
|
|
+void WebContentsDelegateQt::AddNewContents(content::WebContents* source, content::WebContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture, bool* was_blocked, std::vector<base::string16> additional_features)
|
|
{
|
|
Q_UNUSED(source)
|
|
- QWeakPointer<WebContentsAdapter> newAdapter = createWindow(new_contents, disposition, initial_pos, user_gesture);
|
|
+ QWeakPointer<WebContentsAdapter> newAdapter = createWindow(new_contents, disposition, initial_pos, user_gesture, additional_features);
|
|
if (was_blocked)
|
|
*was_blocked = !newAdapter;
|
|
}
|
|
@@ -423,11 +424,17 @@ void WebContentsDelegateQt::overrideWebPreferences(content::WebContents *, conte
|
|
m_viewClient->webEngineSettings()->overrideWebPreferences(webPreferences);
|
|
}
|
|
|
|
-QWeakPointer<WebContentsAdapter> WebContentsDelegateQt::createWindow(content::WebContents *new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture)
|
|
+QWeakPointer<WebContentsAdapter> WebContentsDelegateQt::createWindow(content::WebContents *new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture, std::vector<base::string16> additional_features)
|
|
{
|
|
QSharedPointer<WebContentsAdapter> newAdapter = QSharedPointer<WebContentsAdapter>::create(new_contents);
|
|
|
|
- m_viewClient->adoptNewWindow(newAdapter, static_cast<WebContentsAdapterClient::WindowOpenDisposition>(disposition), user_gesture, toQt(initial_pos), m_initialTargetUrl);
|
|
+ QStringList additionalFeaturesStringList;
|
|
+ std::vector<base::string16>::const_iterator iter;
|
|
+ for( iter = additional_features.begin(); iter != additional_features.end(); iter++ )
|
|
+ {
|
|
+ additionalFeaturesStringList << toQt(*iter);
|
|
+ }
|
|
+ m_viewClient->adoptNewWindow(newAdapter, static_cast<WebContentsAdapterClient::WindowOpenDisposition>(disposition), user_gesture, toQt(initial_pos), m_initialTargetUrl, additionalFeaturesStringList);
|
|
|
|
// If the client didn't reference the adapter, it will be deleted now, and the weak pointer zeroed.
|
|
return newAdapter;
|
|
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
|
|
index 913bf35..a8db7b7 100644
|
|
--- a/src/core/web_contents_delegate_qt.h
|
|
+++ b/src/core/web_contents_delegate_qt.h
|
|
@@ -99,7 +99,7 @@ public:
|
|
// WebContentsDelegate overrides
|
|
content::WebContents *OpenURLFromTab(content::WebContents *source, const content::OpenURLParams ¶ms) override;
|
|
void NavigationStateChanged(content::WebContents* source, content::InvalidateTypes changed_flags) override;
|
|
- void AddNewContents(content::WebContents* source, content::WebContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture, bool* was_blocked) override;
|
|
+ void AddNewContents(content::WebContents* source, content::WebContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture, bool* was_blocked, std::vector<base::string16> additional_features) override;
|
|
void CloseContents(content::WebContents *source) override;
|
|
void LoadProgressChanged(content::WebContents* source, double progress) override;
|
|
void HandleKeyboardEvent(content::WebContents *source, const content::NativeWebKeyboardEvent &event) override;
|
|
@@ -148,7 +148,7 @@ public:
|
|
const SavePageInfo &savePageInfo() { return m_savePageInfo; }
|
|
|
|
private:
|
|
- QWeakPointer<WebContentsAdapter> createWindow(content::WebContents *new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture);
|
|
+ QWeakPointer<WebContentsAdapter> createWindow(content::WebContents *new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture, std::vector<base::string16> additional_features);
|
|
|
|
WebContentsAdapterClient *m_viewClient;
|
|
QString m_lastSearchedString;
|
|
diff --git a/src/webengine/api/qquickwebenginenewviewrequest.cpp b/src/webengine/api/qquickwebenginenewviewrequest.cpp
|
|
index 0af943d..99e3794 100644
|
|
--- a/src/webengine/api/qquickwebenginenewviewrequest.cpp
|
|
+++ b/src/webengine/api/qquickwebenginenewviewrequest.cpp
|
|
@@ -92,6 +92,11 @@ bool QQuickWebEngineNewViewRequest::isUserInitiated() const
|
|
return m_isUserInitiated;
|
|
}
|
|
|
|
+const QStringList &QQuickWebEngineNewViewRequest::additionalFeatures() const
|
|
+{
|
|
+ return m_additionalFeatures;
|
|
+}
|
|
+
|
|
/*!
|
|
\qmlmethod WebEngineNewViewRequest::openIn(WebEngineView view)
|
|
|
|
diff --git a/src/webengine/api/qquickwebenginenewviewrequest_p.h b/src/webengine/api/qquickwebenginenewviewrequest_p.h
|
|
index 9cc0f29..304c6c0 100644
|
|
--- a/src/webengine/api/qquickwebenginenewviewrequest_p.h
|
|
+++ b/src/webengine/api/qquickwebenginenewviewrequest_p.h
|
|
@@ -54,6 +54,8 @@
|
|
#include "qtwebengineglobal_p.h"
|
|
#include "qquickwebengineview_p.h"
|
|
|
|
+#include <QStringList>
|
|
+
|
|
namespace QtWebEngineCore {
|
|
class WebContentsAdapter;
|
|
}
|
|
@@ -65,12 +67,14 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineNewViewRequest : public QObject
|
|
Q_PROPERTY(QQuickWebEngineView::NewViewDestination destination READ destination CONSTANT FINAL)
|
|
Q_PROPERTY(QUrl requestedUrl READ requestedUrl CONSTANT REVISION 1 FINAL)
|
|
Q_PROPERTY(bool userInitiated READ isUserInitiated CONSTANT FINAL)
|
|
+ Q_PROPERTY(QStringList additionalFeatures READ additionalFeatures CONSTANT FINAL)
|
|
public:
|
|
~QQuickWebEngineNewViewRequest();
|
|
|
|
QQuickWebEngineView::NewViewDestination destination() const;
|
|
QUrl requestedUrl() const;
|
|
bool isUserInitiated() const;
|
|
+ const QStringList &additionalFeatures() const;
|
|
Q_INVOKABLE void openIn(QQuickWebEngineView *view);
|
|
|
|
private:
|
|
@@ -80,6 +84,7 @@ private:
|
|
QSharedPointer<QtWebEngineCore::WebContentsAdapter> m_adapter;
|
|
QUrl m_requestedUrl;
|
|
friend class QQuickWebEngineView;
|
|
+ QStringList m_additionalFeatures;
|
|
friend class QQuickWebEngineViewPrivate;
|
|
};
|
|
|
|
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
|
|
index ae75b7f..c8e9e51 100644
|
|
--- a/src/webengine/api/qquickwebengineview.cpp
|
|
+++ b/src/webengine/api/qquickwebengineview.cpp
|
|
@@ -588,7 +588,7 @@ void QQuickWebEngineViewPrivate::unhandledKeyEvent(QKeyEvent *event)
|
|
q->window()->sendEvent(q->parentItem(), event);
|
|
}
|
|
|
|
-void QQuickWebEngineViewPrivate::adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &, const QUrl &targetUrl)
|
|
+void QQuickWebEngineViewPrivate::adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &, const QUrl &targetUrl, const QStringList &additionalFeaturesStringList)
|
|
{
|
|
Q_Q(QQuickWebEngineView);
|
|
QQuickWebEngineNewViewRequest request;
|
|
@@ -597,6 +597,7 @@ void QQuickWebEngineViewPrivate::adoptNewWindow(QSharedPointer<WebContentsAdapte
|
|
request.m_adapter = newWebContents;
|
|
request.m_isUserInitiated = userGesture;
|
|
request.m_requestedUrl = targetUrl;
|
|
+ request.m_additionalFeatures = additionalFeaturesStringList;
|
|
|
|
switch (disposition) {
|
|
case WebContentsAdapterClient::NewForegroundTabDisposition:
|
|
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
|
|
index f6f638e..41178e0 100644
|
|
--- a/src/webengine/api/qquickwebengineview_p_p.h
|
|
+++ b/src/webengine/api/qquickwebengineview_p_p.h
|
|
@@ -109,7 +109,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(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &, const QUrl &targetUrl) Q_DECL_OVERRIDE;
|
|
+ virtual void adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &, const QUrl &targetUrl, const QStringList &additionalFeatures) Q_DECL_OVERRIDE;
|
|
virtual bool isBeingAdopted() Q_DECL_OVERRIDE;
|
|
virtual void close() Q_DECL_OVERRIDE;
|
|
virtual void windowCloseRejected() Q_DECL_OVERRIDE;
|
|
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
|
|
index 5145612..db9baca 100644
|
|
--- a/src/webenginewidgets/api/qwebenginepage.cpp
|
|
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
|
|
@@ -399,11 +399,12 @@ void QWebEnginePagePrivate::unhandledKeyEvent(QKeyEvent *event)
|
|
QGuiApplication::sendEvent(view->parentWidget(), event);
|
|
}
|
|
|
|
-void QWebEnginePagePrivate::adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry, const QUrl &targetUrl)
|
|
+void QWebEnginePagePrivate::adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry, const QUrl &targetUrl, const QStringList &additionalFeatures)
|
|
{
|
|
Q_Q(QWebEnginePage);
|
|
Q_UNUSED(userGesture);
|
|
Q_UNUSED(targetUrl);
|
|
+ Q_UNUSED(additionalFeatures);
|
|
|
|
QWebEnginePage *newPage = q->createWindow(toWindowType(disposition));
|
|
if (!newPage)
|
|
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
|
|
index ec84f05..2426e2c 100644
|
|
--- a/src/webenginewidgets/api/qwebenginepage_p.h
|
|
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
|
|
@@ -100,7 +100,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(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry, const QUrl &targetUrl) Q_DECL_OVERRIDE;
|
|
+ virtual void adoptNewWindow(QSharedPointer<QtWebEngineCore::WebContentsAdapter> newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &initialGeometry, const QUrl &targetUrl, const QStringList &additionalFeatures) Q_DECL_OVERRIDE;
|
|
void adoptNewWindowImpl(QWebEnginePage *newPage,
|
|
const QSharedPointer<QtWebEngineCore::WebContentsAdapter> &newWebContents,
|
|
const QRect &initialGeometry);
|
|
--
|
|
2.7.4
|
|
|