summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-05-14 10:49:00 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-05-15 18:05:27 +0200
commit57ae490b073ea14a9e7b3439031040515237eeb6 (patch)
treea66d05c6c2c30643b77f204cb20b9e2ac4815804 /src/core
parent4d4330116471a495796e9d2723b3b5c508fc26b1 (diff)
parentbc6df3888128e3a0e0d4e2f8a69970ac36d8abe7 (diff)
Merge "Merge remote-tracking branch 'origin/5.15' into dev"
Diffstat (limited to 'src/core')
-rw-r--r--src/core/accessibility_activation_observer.cpp4
-rw-r--r--src/core/accessibility_activation_observer.h5
-rw-r--r--src/core/accessibility_tree_formatter_qt.cpp6
-rw-r--r--src/core/api/qtwebenginecoreglobal.cpp12
-rw-r--r--src/core/browser_accessibility_manager_qt.cpp12
-rw-r--r--src/core/browser_accessibility_manager_qt.h7
-rw-r--r--src/core/browser_accessibility_qt.cpp4
-rw-r--r--src/core/browser_accessibility_qt.h4
-rw-r--r--src/core/compositor/delegated_frame_node.cpp46
-rw-r--r--src/core/content_browser_client_qt.cpp2
-rw-r--r--src/core/core_module.pro11
-rw-r--r--src/core/net/cookie_monster_delegate_qt.cpp18
-rw-r--r--src/core/net/cookie_monster_delegate_qt.h3
-rw-r--r--src/core/net/system_network_context_manager.cpp12
-rw-r--r--src/core/net/system_network_context_manager.h4
-rw-r--r--src/core/ozone/gl_context_qt.cpp6
-rw-r--r--src/core/ozone/gl_ozone_egl_qt.cpp6
-rw-r--r--src/core/permission_manager_qt.cpp7
-rw-r--r--src/core/render_widget_host_view_qt.cpp30
-rw-r--r--src/core/render_widget_host_view_qt.h3
-rw-r--r--src/core/render_widget_host_view_qt_delegate.h4
-rw-r--r--src/core/web_contents_adapter.cpp30
-rw-r--r--src/core/web_contents_adapter.h4
-rw-r--r--src/core/web_contents_adapter_client.h5
-rw-r--r--src/core/web_contents_delegate_qt.cpp24
-rw-r--r--src/core/web_contents_delegate_qt.h6
-rw-r--r--src/core/web_engine_context.cpp71
-rw-r--r--src/core/web_engine_context.h3
-rw-r--r--src/core/web_event_factory.cpp79
-rw-r--r--src/core/web_event_factory.h6
30 files changed, 319 insertions, 115 deletions
diff --git a/src/core/accessibility_activation_observer.cpp b/src/core/accessibility_activation_observer.cpp
index 75ad90c54..833190844 100644
--- a/src/core/accessibility_activation_observer.cpp
+++ b/src/core/accessibility_activation_observer.cpp
@@ -39,7 +39,7 @@
#include "accessibility_activation_observer.h"
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
#include "content/browser/accessibility/browser_accessibility_state_impl.h"
@@ -86,4 +86,4 @@ void AccessibilityActivationObserver::accessibilityActiveChanged(bool active)
} // namespace QtWebEngineCore
-#endif // QT_NO_ACCESSIBILITY
+#endif // QT_CONFIG(accessibility)
diff --git a/src/core/accessibility_activation_observer.h b/src/core/accessibility_activation_observer.h
index e42c83eb5..23fd2101e 100644
--- a/src/core/accessibility_activation_observer.h
+++ b/src/core/accessibility_activation_observer.h
@@ -40,9 +40,10 @@
#ifndef ACCESSIBILITY_ACTIVATION_OBSERVER_H
#define ACCESSIBILITY_ACTIVATION_OBSERVER_H
-#ifndef QT_NO_ACCESSIBILITY
#include <QtGui/qaccessible.h>
+#if QT_CONFIG(accessibility)
+
namespace QtWebEngineCore {
class RenderWidgetHostViewQt;
@@ -58,6 +59,6 @@ public:
} // namespace QtWebEngineCore
-#endif // QT_NO_ACCESSIBILITY
+#endif // QT_CONFIG(accessibility)
#endif // ACCESSIBILITY_ACTIVATION_OBSERVER_H
diff --git a/src/core/accessibility_tree_formatter_qt.cpp b/src/core/accessibility_tree_formatter_qt.cpp
index 334759abb..081856b37 100644
--- a/src/core/accessibility_tree_formatter_qt.cpp
+++ b/src/core/accessibility_tree_formatter_qt.cpp
@@ -52,7 +52,7 @@
namespace content {
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
class AccessibilityTreeFormatterQt : public AccessibilityTreeFormatterBrowser {
public:
explicit AccessibilityTreeFormatterQt();
@@ -204,12 +204,12 @@ const std::string AccessibilityTreeFormatterQt::GetDenyNodeString()
return "@QT-DENY-NODE:";
}
-#endif // QT_NO_ACCESSIBILITY
+#endif // QT_CONFIG(accessibility)
// static
std::unique_ptr<AccessibilityTreeFormatter> AccessibilityTreeFormatter::Create()
{
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
return std::unique_ptr<AccessibilityTreeFormatter>(new AccessibilityTreeFormatterQt());
#else
return nullptr;
diff --git a/src/core/api/qtwebenginecoreglobal.cpp b/src/core/api/qtwebenginecoreglobal.cpp
index 9e2a4a5b1..ce4362741 100644
--- a/src/core/api/qtwebenginecoreglobal.cpp
+++ b/src/core/api/qtwebenginecoreglobal.cpp
@@ -40,7 +40,7 @@
#include "qtwebenginecoreglobal_p.h"
#include <QGuiApplication>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QOpenGLContext>
#ifdef Q_OS_MACOS
#include <sys/types.h>
@@ -49,14 +49,14 @@
#endif
#include <QThread>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QT_BEGIN_NAMESPACE
Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context);
Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
QT_END_NAMESPACE
#endif
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
#ifdef Q_OS_MACOS
static bool needsOfflineRendererWorkaround()
{
@@ -75,7 +75,7 @@ static bool needsOfflineRendererWorkaround()
#endif
namespace QtWebEngineCore {
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
static QOpenGLContext *shareContext;
static void deleteShareContext()
@@ -94,7 +94,7 @@ static void deleteShareContext()
Q_WEBENGINECORE_PRIVATE_EXPORT void initialize()
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
#ifdef Q_OS_WIN32
qputenv("QT_D3DCREATE_MULTITHREADED", "1");
#endif
@@ -134,6 +134,6 @@ Q_WEBENGINECORE_PRIVATE_EXPORT void initialize()
// Classes like QOpenGLWidget check for the attribute
app->setAttribute(Qt::AA_ShareOpenGLContexts);
-#endif // QT_NO_OPENGL
+#endif // QT_CONFIG(opengl)
}
} // namespace QtWebEngineCore
diff --git a/src/core/browser_accessibility_manager_qt.cpp b/src/core/browser_accessibility_manager_qt.cpp
index 8e3ee5940..5968bfd30 100644
--- a/src/core/browser_accessibility_manager_qt.cpp
+++ b/src/core/browser_accessibility_manager_qt.cpp
@@ -51,24 +51,24 @@ BrowserAccessibilityManager* BrowserAccessibilityManager::Create(
BrowserAccessibilityDelegate* delegate,
BrowserAccessibilityFactory* factory)
{
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
return new BrowserAccessibilityManagerQt(nullptr, initialTree, delegate, factory);
#else
delete factory;
return nullptr;
-#endif // QT_NO_ACCESSIBILITY
+#endif // QT_CONFIG(accessibility)
}
BrowserAccessibility *BrowserAccessibility::Create()
{
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
return new BrowserAccessibilityQt();
#else
return nullptr;
-#endif // QT_NO_ACCESSIBILITY
+#endif // QT_CONFIG(accessibility)
}
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
BrowserAccessibilityManagerQt::BrowserAccessibilityManagerQt(
QObject *parentObject, const ui::AXTreeUpdate &initialTree,
BrowserAccessibilityDelegate* delegate, BrowserAccessibilityFactory* factory)
@@ -164,6 +164,6 @@ void BrowserAccessibilityManagerQt::FireGeneratedEvent(ui::AXEventGenerator::Eve
}
}
-#endif // QT_NO_ACCESSIBILITY
+#endif // QT_CONFIG(accessibility)
}
diff --git a/src/core/browser_accessibility_manager_qt.h b/src/core/browser_accessibility_manager_qt.h
index 16e2d1fe7..6d6086811 100644
--- a/src/core/browser_accessibility_manager_qt.h
+++ b/src/core/browser_accessibility_manager_qt.h
@@ -41,8 +41,11 @@
#define BROWSER_ACCESSIBILITY_MANAGER_QT_H
#include "content/browser/accessibility/browser_accessibility_manager.h"
-#ifndef QT_NO_ACCESSIBILITY
+
#include <QtCore/qobject.h>
+#include <QtGui/qtgui-config.h>
+
+#if QT_CONFIG(accessibility)
QT_BEGIN_NAMESPACE
class QAccessibleInterface;
@@ -74,5 +77,5 @@ private:
}
-#endif // QT_NO_ACCESSIBILITY
+#endif // QT_CONFIG(accessibility)
#endif
diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp
index 6104fb1f8..de78eb85d 100644
--- a/src/core/browser_accessibility_qt.cpp
+++ b/src/core/browser_accessibility_qt.cpp
@@ -43,7 +43,7 @@
#include "browser_accessibility_qt.h"
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
#include "ui/accessibility/ax_enums.mojom.h"
@@ -996,4 +996,4 @@ void BrowserAccessibilityQt::modelChange(QAccessibleTableModelChangeEvent *)
} // namespace content
-#endif // QT_NO_ACCESSIBILITY
+#endif // QT_CONFIG(accessibility)
diff --git a/src/core/browser_accessibility_qt.h b/src/core/browser_accessibility_qt.h
index 4acac6aa7..19c7a1e54 100644
--- a/src/core/browser_accessibility_qt.h
+++ b/src/core/browser_accessibility_qt.h
@@ -43,7 +43,7 @@
#include <QtGui/qaccessible.h>
#include "content/browser/accessibility/browser_accessibility.h"
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
namespace content {
@@ -151,5 +151,5 @@ QAccessibleInterface *toQAccessibleInterface(BrowserAccessibility *acc);
} // namespace content
-#endif // QT_NO_ACCESSIBILITY
+#endif // QT_CONFIG(accessibility)
#endif
diff --git a/src/core/compositor/delegated_frame_node.cpp b/src/core/compositor/delegated_frame_node.cpp
index d41d21e93..c20069558 100644
--- a/src/core/compositor/delegated_frame_node.cpp
+++ b/src/core/compositor/delegated_frame_node.cpp
@@ -68,7 +68,7 @@
#include "components/viz/service/display/bsp_tree.h"
#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QOpenGLContext>
# include <QOpenGLFunctions>
# include <QSGFlatColorMaterial>
@@ -79,7 +79,7 @@
#include <QSGImageNode>
#include <QSGRectangleNode>
-#if !defined(QT_NO_EGL)
+#if QT_CONFIG(egl)
#include <EGL/egl.h>
#include <EGL/eglext.h>
#endif
@@ -108,14 +108,14 @@
#define GL_LINE_LOOP 0x0002
#endif
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QT_BEGIN_NAMESPACE
Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
QT_END_NAMESPACE
#endif
namespace QtWebEngineCore {
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
class MailboxTexture : public QSGTexture, protected QOpenGLFunctions {
public:
MailboxTexture(const CompositorResource *resource, bool hasAlphaChannel, int target = -1);
@@ -147,7 +147,7 @@ private:
#endif
friend class DelegatedFrameNode;
};
-#endif // QT_NO_OPENGL
+#endif // QT_CONFIG(opengl)
class RectClipNode : public QSGClipNode
{
@@ -173,7 +173,7 @@ public:
QSGNode *) = 0;
virtual void setupSolidColorNode(const QRect &, const QColor &, QSGNode *) = 0;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
virtual void setupDebugBorderNode(QSGGeometry *, QSGFlatColorMaterial *, QSGNode *) = 0;
virtual void setupYUVVideoNode(QSGTexture *, QSGTexture *, QSGTexture *, QSGTexture *,
const QRectF &, const QRectF &, const QSizeF &, const QSizeF &,
@@ -183,7 +183,7 @@ public:
virtual void setupStreamVideoNode(MailboxTexture *, const QRectF &,
const QMatrix4x4 &, QSGNode *) = 0;
#endif // GL_OES_EGL_image_external
-#endif // QT_NO_OPENGL
+#endif // QT_CONFIG(opengl)
protected:
QVector<QSGNode*> *m_sceneGraphNodes;
};
@@ -240,7 +240,7 @@ public:
if (rectangleNode->color() != color)
rectangleNode->setColor(color);
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
void setupDebugBorderNode(QSGGeometry *geometry, QSGFlatColorMaterial *material,
QSGNode *) override
{
@@ -265,7 +265,7 @@ public:
Q_UNREACHABLE();
}
#endif // GL_OES_EGL_image_external
-#endif // QT_NO_OPENGL
+#endif // QT_CONFIG(opengl)
private:
QVector<QSGNode*>::iterator m_nodeIterator;
@@ -320,7 +320,7 @@ public:
m_sceneGraphNodes->append(rectangleNode);
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
void setupDebugBorderNode(QSGGeometry *geometry, QSGFlatColorMaterial *material,
QSGNode *layerChain) override
{
@@ -369,7 +369,7 @@ public:
m_sceneGraphNodes->append(svideoNode);
}
#endif // GL_OES_EGL_image_external
-#endif // QT_NO_OPENGL
+#endif // QT_CONFIG(opengl)
private:
RenderWidgetHostViewQtDelegate *m_apiDelegate;
@@ -427,7 +427,7 @@ static QSGNode *buildLayerChain(QSGNode *chainParent, const viz::SharedQuadState
return layerChain;
}
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
MailboxTexture::MailboxTexture(const CompositorResource *resource, bool hasAlphaChannel, int target)
: m_textureId(resource->texture_id)
, m_fence(resource->texture_fence)
@@ -482,7 +482,7 @@ void MailboxTexture::bind()
}
#endif
}
-#endif // !QT_NO_OPENGL
+#endif // QT_CONFIG(opengl)
RectClipNode::RectClipNode(const QRectF &rect)
: m_geometry(QSGGeometry::defaultAttributes_Point2D(), 4)
@@ -494,12 +494,12 @@ RectClipNode::RectClipNode(const QRectF &rect)
}
DelegatedFrameNode::DelegatedFrameNode()
-#if defined(USE_OZONE) && !defined(QT_NO_OPENGL)
+#if defined(USE_OZONE) && QT_CONFIG(opengl)
: m_contextShared(true)
#endif
{
setFlag(UsePreprocess);
-#if defined(USE_OZONE) && !defined(QT_NO_OPENGL)
+#if defined(USE_OZONE) && QT_CONFIG(opengl)
QOpenGLContext *currentContext = QOpenGLContext::currentContext() ;
QOpenGLContext *sharedContext = qt_gl_global_share_context();
if (currentContext && sharedContext && !QOpenGLContext::areSharing(currentContext, sharedContext)) {
@@ -575,14 +575,14 @@ static bool areRenderPassStructuresEqual(const viz::CompositorFrame *frameData,
const viz::DrawQuad *prevQuad = *prevIt;
if (quad->material != prevQuad->material)
return false;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (quad->material == viz::DrawQuad::Material::kYuvVideoContent)
return false;
#ifdef GL_OES_EGL_image_external
if (quad->material == viz::DrawQuad::Material::kStreamVideoContent)
return false;
#endif // GL_OES_EGL_image_external
-#endif // QT_NO_OPENGL
+#endif // QT_CONFIG(opengl)
if (!areSharedQuadStatesEqual(quad->shared_quad_state, prevQuad->shared_quad_state))
return false;
if (quad->shared_quad_state->is_clipped && quad->visible_rect != prevQuad->visible_rect) {
@@ -686,7 +686,7 @@ void DelegatedFrameNode::commit(const viz::CompositorFrame &pendingFrame,
rpLayer->setSize(toQt(pass->output_rect.size()));
rpLayer->setFormat(pass->has_transparent_background ? GL_RGBA : GL_RGB);
rpLayer->setHasMipmaps(pass->generate_mipmap);
- rpLayer->setMirrorVertical(true);
+ rpLayer->setMirrorVertical(false);
scissorRect = pass->output_rect;
} else {
renderPassParent = this;
@@ -886,7 +886,7 @@ void DelegatedFrameNode::handleQuad(
Q_UNUSED(scquad->force_anti_aliasing_off);
nodeHandler->setupSolidColorNode(toQt(quad->rect), toQt(scquad->color), currentLayerChain);
break;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
}
case viz::DrawQuad::Material::kDebugBorder: {
const viz::DebugBorderDrawQuad *dbquad = viz::DebugBorderDrawQuad::MaterialCast(quad);
@@ -919,7 +919,7 @@ void DelegatedFrameNode::handleQuad(
toQt(quad->rect), toQt(tquad->tex_coord_rect),
QSGImageNode::NoTransform, currentLayerChain);
break;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
}
case viz::DrawQuad::Material::kYuvVideoContent: {
const viz::YUVVideoDrawQuad *vquad = viz::YUVVideoDrawQuad::MaterialCast(quad);
@@ -958,7 +958,7 @@ void DelegatedFrameNode::handleQuad(
nodeHandler->setupStreamVideoNode(texture, toQt(squad->rect), qMatrix, currentLayerChain);
break;
#endif // GL_OES_EGL_image_external
-#endif // QT_NO_OPENGL
+#endif // QT_CONFIG(opengl)
}
case viz::DrawQuad::Material::kSurfaceContent:
Q_UNREACHABLE();
@@ -1056,7 +1056,7 @@ QSharedPointer<QSGTexture> DelegatedFrameNode::createBitmapTexture(const Composi
QSharedPointer<MailboxTexture> DelegatedFrameNode::createMailboxTexture(const CompositorResource *resource, bool hasAlphaChannel, int target)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
return QSharedPointer<MailboxTexture>::create(resource, hasAlphaChannel, target);
#else
Q_UNREACHABLE();
@@ -1065,7 +1065,7 @@ QSharedPointer<MailboxTexture> DelegatedFrameNode::createMailboxTexture(const Co
void DelegatedFrameNode::copyMailboxTextures()
{
-#if !defined(QT_NO_OPENGL) && defined(USE_OZONE)
+#if QT_CONFIG(opengl) && defined(USE_OZONE)
// Workaround when context is not shared QTBUG-48969
// Make slow copy between two contexts.
if (!m_contextShared) {
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index cac392182..05957c26f 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -312,7 +312,7 @@ private:
void ShareGroupQtQuick::AboutToAddFirstContext()
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
// This currently has to be setup by ::main in all applications using QQuickWebEngineView with delegated rendering.
QOpenGLContext *shareContext = qt_gl_global_share_context();
if (!shareContext) {
diff --git a/src/core/core_module.pro b/src/core/core_module.pro
index d7e2ab8da..5007012ac 100644
--- a/src/core/core_module.pro
+++ b/src/core/core_module.pro
@@ -29,12 +29,11 @@ write_file($$RSP_OBJECT_FILE, RSP_O_CONTENT)
RSP_ARCHIVE_FILE = $$OUT_PWD/$$getConfigDir()/$${TARGET}_a.rsp
for(archive, NINJA_ARCHIVES): RSP_A_CONTENT += $$archive
write_file($$RSP_ARCHIVE_FILE, RSP_A_CONTENT)
-macos:LIBS_PRIVATE += -Wl,-filelist,$$shell_quote($$RSP_OBJECT_FILE)
-linux:QMAKE_LFLAGS += @$${RSP_OBJECT_FILE}
-# QTBUG-58710 add main rsp file on windows
-win32:QMAKE_LFLAGS += @$${RSP_OBJECT_FILE}
-linux:QMAKE_LFLAGS += -Wl,--start-group @$${RSP_ARCHIVE_FILE} -Wl,--end-group
-else: LIBS_PRIVATE += $$NINJA_ARCHIVES
+
+macos:LIBS_PRIVATE += -Wl,-filelist,$$shell_quote($${RSP_OBJECT_FILE}) @$${RSP_ARCHIVE_FILE}
+linux:QMAKE_LFLAGS += @$${RSP_OBJECT_FILE} -Wl,--start-group @$${RSP_ARCHIVE_FILE} -Wl,--end-group
+win32:QMAKE_LFLAGS += @$${RSP_OBJECT_FILE} @$${RSP_ARCHIVE_FILE}
+
LIBS_PRIVATE += $$NINJA_LIB_DIRS $$NINJA_LIBS
# GN's LFLAGS doesn't always work across all the Linux configurations we support.
# The Windows and macOS ones from GN does provide a few useful flags however
diff --git a/src/core/net/cookie_monster_delegate_qt.cpp b/src/core/net/cookie_monster_delegate_qt.cpp
index cf114406b..d3157f760 100644
--- a/src/core/net/cookie_monster_delegate_qt.cpp
+++ b/src/core/net/cookie_monster_delegate_qt.cpp
@@ -223,20 +223,11 @@ void CookieMonsterDelegateQt::OnCookieChanged(const net::CookieChangeInfo &chang
m_client->d_func()->onCookieChanged(toQt(change.cookie), change.cause != net::CookieChangeCause::INSERTED);
}
-void CookieMonsterDelegateQt::GetAllCookiesCallbackOnUIThread(qint64 callbackId, const std::vector<net::CanonicalCookie> &cookies)
-{
- DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- QByteArray rawCookies;
- for (auto &&cookie : cookies)
- rawCookies += toQt(cookie).toRawForm() % QByteArrayLiteral("\n");
-
- GetAllCookiesResultOnUIThread(callbackId, rawCookies);
-}
-
-void CookieMonsterDelegateQt::GetAllCookiesResultOnUIThread(qint64 callbackId, const QByteArray &cookies)
+void CookieMonsterDelegateQt::GetAllCookiesCallbackOnUIThread(qint64 callbackId, const net::CookieList &cookies)
{
+ QByteArray rawCookies = QByteArray::fromStdString(net::CanonicalCookie::BuildCookieLine(cookies));
if (m_client)
- m_client->d_func()->onGetAllCallbackResult(callbackId, cookies);
+ m_client->d_func()->onGetAllCallbackResult(callbackId, rawCookies);
}
void CookieMonsterDelegateQt::SetCookieCallbackOnUIThread(qint64 callbackId, net::CanonicalCookie::CookieInclusionStatus status)
@@ -250,4 +241,5 @@ void CookieMonsterDelegateQt::DeleteCookiesCallbackOnUIThread(qint64 callbackId,
if (m_client)
m_client->d_func()->onDeleteCallbackResult(callbackId, numCookies);
}
-}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/net/cookie_monster_delegate_qt.h b/src/core/net/cookie_monster_delegate_qt.h
index 6caaeea94..bcbbe4c52 100644
--- a/src/core/net/cookie_monster_delegate_qt.h
+++ b/src/core/net/cookie_monster_delegate_qt.h
@@ -115,8 +115,7 @@ public:
void OnCookieChanged(const net::CookieChangeInfo &change);
private:
- void GetAllCookiesCallbackOnUIThread(qint64 callbackId, const std::vector<net::CanonicalCookie> &cookies);
- void GetAllCookiesResultOnUIThread(qint64 callbackId, const QByteArray &cookies);
+ void GetAllCookiesCallbackOnUIThread(qint64 callbackId, const net::CookieList &cookies);
void SetCookieCallbackOnUIThread(qint64 callbackId, net::CanonicalCookie::CookieInclusionStatus status);
void DeleteCookiesCallbackOnUIThread(qint64 callbackId, uint numCookies);
};
diff --git a/src/core/net/system_network_context_manager.cpp b/src/core/net/system_network_context_manager.cpp
index 43b2b2557..29cc82abf 100644
--- a/src/core/net/system_network_context_manager.cpp
+++ b/src/core/net/system_network_context_manager.cpp
@@ -166,7 +166,8 @@ private:
network::mojom::NetworkContext *SystemNetworkContextManager::GetContext()
{
- if (!network_service_network_context_ || network_service_network_context_.encountered_error()) {
+ if (!network_service_network_context_ ||
+ !network_service_network_context_.is_connected()) {
// This should call into OnNetworkServiceCreated(), which will re-create
// the network service, if needed. There's a chance that it won't be
// invoked, if the NetworkContext has encountered an error but the
@@ -182,14 +183,14 @@ network::mojom::NetworkContext *SystemNetworkContextManager::GetContext()
network::mojom::URLLoaderFactory *SystemNetworkContextManager::GetURLLoaderFactory()
{
// Create the URLLoaderFactory as needed.
- if (url_loader_factory_ && !url_loader_factory_.encountered_error()) {
+ if (url_loader_factory_ && url_loader_factory_.is_connected()) {
return url_loader_factory_.get();
}
network::mojom::URLLoaderFactoryParamsPtr params = network::mojom::URLLoaderFactoryParams::New();
params->process_id = network::mojom::kBrowserProcessId;
params->is_corb_enabled = false;
- GetContext()->CreateURLLoaderFactory(mojo::MakeRequest(&url_loader_factory_), std::move(params));
+ GetContext()->CreateURLLoaderFactory(url_loader_factory_.BindNewPipeAndPassReceiver(), std::move(params));
return url_loader_factory_.get();
}
@@ -252,7 +253,10 @@ void SystemNetworkContextManager::OnNetworkServiceCreated(network::mojom::Networ
// The system NetworkContext must be created first, since it sets
// |primary_network_context| to true.
- network_service->CreateNetworkContext(MakeRequest(&network_service_network_context_), CreateNetworkContextParams());
+ network_service_network_context_.reset();
+ network_service->CreateNetworkContext(
+ network_service_network_context_.BindNewPipeAndPassReceiver(),
+ CreateNetworkContextParams());
// Configure the stub resolver. This must be done after the system
// NetworkContext is created, but before anything has the chance to use it.
diff --git a/src/core/net/system_network_context_manager.h b/src/core/net/system_network_context_manager.h
index e429453a2..5094008f2 100644
--- a/src/core/net/system_network_context_manager.h
+++ b/src/core/net/system_network_context_manager.h
@@ -167,12 +167,12 @@ private:
// NetworkContext using the network service, if the network service is
// enabled. nullptr, otherwise.
- network::mojom::NetworkContextPtr network_service_network_context_;
+ mojo::Remote<network::mojom::NetworkContext> network_service_network_context_;
// URLLoaderFactory backed by the NetworkContext returned by GetContext(), so
// consumers don't all need to create their own factory.
scoped_refptr<URLLoaderFactoryForSystem> shared_url_loader_factory_;
- network::mojom::URLLoaderFactoryPtr url_loader_factory_;
+ mojo::Remote<network::mojom::URLLoaderFactory> url_loader_factory_;
ProxyConfigMonitor proxy_config_monitor_;
diff --git a/src/core/ozone/gl_context_qt.cpp b/src/core/ozone/gl_context_qt.cpp
index e9337874a..10347bdc7 100644
--- a/src/core/ozone/gl_context_qt.cpp
+++ b/src/core/ozone/gl_context_qt.cpp
@@ -59,7 +59,7 @@ namespace {
inline void *resourceForContext(const QByteArray &resource)
{
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QOpenGLContext *shareContext = qt_gl_global_share_context();
if (!shareContext) {
qFatal("QWebEngine: OpenGL resource sharing is not set up in QtQuick. Please make sure to call QtWebEngine::initialize() in your main() function.");
@@ -153,7 +153,7 @@ void* GLContextHelper::getNativeDisplay()
QFunctionPointer GLContextHelper::getGlXGetProcAddress()
{
QFunctionPointer get_proc_address = nullptr;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (QOpenGLContext *context = qt_gl_global_share_context()) {
get_proc_address = context->getProcAddress("glXGetProcAddress");
}
@@ -164,7 +164,7 @@ QFunctionPointer GLContextHelper::getGlXGetProcAddress()
QFunctionPointer GLContextHelper::getEglGetProcAddress()
{
QFunctionPointer get_proc_address = nullptr;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (QOpenGLContext *context = qt_gl_global_share_context()) {
get_proc_address = context->getProcAddress("eglGetProcAddress");
}
diff --git a/src/core/ozone/gl_ozone_egl_qt.cpp b/src/core/ozone/gl_ozone_egl_qt.cpp
index 2fa86d79b..c692920cf 100644
--- a/src/core/ozone/gl_ozone_egl_qt.cpp
+++ b/src/core/ozone/gl_ozone_egl_qt.cpp
@@ -55,9 +55,9 @@
#include <EGL/egl.h>
#include <dlfcn.h>
-#include <QtGui/qtgui-config.h> // for QT_NO_OPENGL
+#include <QtGui/qtgui-config.h>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
#include <QOpenGLContext>
QT_BEGIN_NAMESPACE
Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
@@ -88,7 +88,7 @@ bool GLOzoneEGLQt::LoadGLES2Bindings(gl::GLImplementation /*implementation*/)
reinterpret_cast<gl::GLGetProcAddressProc>(
base::GetFunctionPointerFromNativeLibrary(eglgles2Library,
"eglGetProcAddress"));
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
if (!get_proc_address) {
// QTBUG-63341 most likely libgles2 not linked with libegl -> fallback to qpa
if (QOpenGLContext *context = qt_gl_global_share_context()) {
diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp
index 16a7b25bf..2f9543769 100644
--- a/src/core/permission_manager_qt.cpp
+++ b/src/core/permission_manager_qt.cpp
@@ -112,8 +112,13 @@ PermissionManagerQt::~PermissionManagerQt()
{
}
-void PermissionManagerQt::permissionRequestReply(const QUrl &origin, ProfileAdapter::PermissionType type, bool reply)
+void PermissionManagerQt::permissionRequestReply(const QUrl &url, ProfileAdapter::PermissionType type, bool reply)
{
+ // Normalize the QUrl to GURL origin form.
+ const GURL gorigin = toGurl(url).GetOrigin();
+ const QUrl origin = gorigin.is_empty() ? url : toQt(gorigin);
+ if (origin.isEmpty())
+ return;
QPair<QUrl, ProfileAdapter::PermissionType> key(origin, type);
m_permissions[key] = reply;
blink::mojom::PermissionStatus status = reply ? blink::mojom::PermissionStatus::GRANTED : blink::mojom::PermissionStatus::DENIED;
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 5887b356e..c4d6200b7 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -286,6 +286,7 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget
, m_adapterClient(0)
, m_imeInProgress(false)
, m_receivedEmptyImeEvent(false)
+ , m_isMouseLocked(false)
, m_imState(0)
, m_anchorPositionWithinSelection(-1)
, m_cursorPositionWithinSelection(-1)
@@ -425,14 +426,14 @@ gfx::NativeViewAccessible RenderWidgetHostViewQt::GetNativeViewAccessible()
content::BrowserAccessibilityManager* RenderWidgetHostViewQt::CreateBrowserAccessibilityManager(content::BrowserAccessibilityDelegate* delegate, bool for_root_frame)
{
Q_UNUSED(for_root_frame); // FIXME
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
return new content::BrowserAccessibilityManagerQt(
m_adapterClient->accessibilityParentObject(),
content::BrowserAccessibilityManagerQt::GetEmptyDocument(),
delegate);
#else
return 0;
-#endif // QT_NO_ACCESSIBILITY
+#endif // QT_CONFIG(accessibility)
}
// Set focus to the associated View component.
@@ -448,6 +449,11 @@ bool RenderWidgetHostViewQt::HasFocus()
return m_delegate->hasKeyboardFocus();
}
+bool RenderWidgetHostViewQt::IsMouseLocked()
+{
+ return m_isMouseLocked;
+}
+
bool RenderWidgetHostViewQt::IsSurfaceAvailableForCopy()
{
if (m_enableViz)
@@ -520,6 +526,7 @@ bool RenderWidgetHostViewQt::LockMouse(bool)
{
m_previousMousePosition = QCursor::pos();
m_delegate->lockMouse();
+ m_isMouseLocked = true;
qApp->setOverrideCursor(Qt::BlankCursor);
return true;
}
@@ -528,6 +535,7 @@ void RenderWidgetHostViewQt::UnlockMouse()
{
m_delegate->unlockMouse();
qApp->restoreOverrideCursor();
+ m_isMouseLocked = false;
host()->LostMouseLock();
}
@@ -1530,7 +1538,21 @@ void RenderWidgetHostViewQt::WheelEventAck(const blink::WebMouseWheelEvent &even
m_mouseWheelPhaseHandler.AddPhaseIfNeededAndScheduleEndEvent(webEvent, false);
host()->ForwardWheelEvent(webEvent);
}
- // TODO: We could forward unhandled wheelevents to our parent.
+}
+
+void RenderWidgetHostViewQt::GestureEventAck(const blink::WebGestureEvent &event, content::InputEventAckState ack_result)
+{
+ // Forward unhandled scroll events back as wheel events
+ if (event.GetType() != blink::WebInputEvent::kGestureScrollUpdate)
+ return;
+ switch (ack_result) {
+ case content::INPUT_EVENT_ACK_STATE_NOT_CONSUMED:
+ case content::INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS:
+ WebEventFactory::sendUnhandledWheelEvent(event, delegate());
+ break;
+ default:
+ break;
+ }
}
content::MouseWheelPhaseHandler *RenderWidgetHostViewQt::GetMouseWheelPhaseHandler()
@@ -1770,6 +1792,8 @@ void RenderWidgetHostViewQt::handleFocusEvent(QFocusEvent *ev)
else if (ev->reason() == Qt::BacktabFocusReason)
viewHost->SetInitialFocus(true);
ev->accept();
+
+ m_adapterClient->webContentsAdapter()->handlePendingMouseLockPermission();
} else if (ev->lostFocus()) {
host()->SetActive(false);
host()->LostFocus();
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index 41ce50b34..453b90888 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -132,6 +132,7 @@ public:
gfx::NativeViewAccessible GetNativeViewAccessible() override;
void Focus() override;
bool HasFocus() override;
+ bool IsMouseLocked() override;
bool IsSurfaceAvailableForCopy() override;
void CopyFromSurface(const gfx::Rect &src_rect,
const gfx::Size &output_size,
@@ -155,6 +156,7 @@ public:
void DidCreateNewRendererCompositorFrameSink(viz::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink) override;
void SubmitCompositorFrame(const viz::LocalSurfaceId&, viz::CompositorFrame, base::Optional<viz::HitTestRegionList>) override;
void WheelEventAck(const blink::WebMouseWheelEvent &event, content::InputEventAckState ack_result) override;
+ void GestureEventAck(const blink::WebGestureEvent &event, content::InputEventAckState ack_result) override;
content::MouseWheelPhaseHandler *GetMouseWheelPhaseHandler() override;
viz::ScopedSurfaceIdAllocator DidUpdateVisualProperties(const cc::RenderFrameMetadata &metadata) override;
void OnDidUpdateVisualPropertiesComplete(const cc::RenderFrameMetadata &metadata);
@@ -288,6 +290,7 @@ private:
bool m_imeInProgress;
bool m_receivedEmptyImeEvent;
QPoint m_previousMousePosition;
+ bool m_isMouseLocked;
gfx::Vector2dF m_lastScrollOffset;
gfx::SizeF m_lastContentsSize;
diff --git a/src/core/render_widget_host_view_qt_delegate.h b/src/core/render_widget_host_view_qt_delegate.h
index 4ee790ce9..46f1802a6 100644
--- a/src/core/render_widget_host_view_qt_delegate.h
+++ b/src/core/render_widget_host_view_qt_delegate.h
@@ -58,12 +58,13 @@
QT_BEGIN_NAMESPACE
class QEvent;
+class QInputMethodEvent;
class QSGLayer;
class QSGNode;
class QSGRectangleNode;
class QSGTexture;
class QVariant;
-class QInputMethodEvent;
+class QWheelEvent;
class QSGImageNode;
@@ -111,6 +112,7 @@ public:
virtual void setInputMethodHints(Qt::InputMethodHints hints) = 0;
virtual void setClearColor(const QColor &color) = 0;
virtual bool copySurface(const QRect &, const QSize &, QImage &) = 0;
+ virtual void unhandledWheelEvent(QWheelEvent *) {}
};
} // namespace QtWebEngineCore
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 2d559bb38..0f2f21f83 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -1024,7 +1024,7 @@ QWebEngineUrlRequestInterceptor* WebContentsAdapter::requestInterceptor() const
return m_requestInterceptor;
}
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
QAccessibleInterface *WebContentsAdapter::browserAccessible()
{
CHECK_INITIALIZED(nullptr);
@@ -1040,7 +1040,7 @@ QAccessibleInterface *WebContentsAdapter::browserAccessible()
return content::toQAccessibleInterface(acc);
}
-#endif // QT_NO_ACCESSIBILITY
+#endif // QT_CONFIG(accessibility)
void WebContentsAdapter::runJavaScript(const QString &javaScript, quint32 worldId)
{
@@ -1372,20 +1372,40 @@ void WebContentsAdapter::runFeatureRequestCallback(const QUrl &securityOrigin, P
m_profileAdapter->permissionRequestReply(securityOrigin, feature, allowed);
}
-void WebContentsAdapter::grantMouseLockPermission(bool granted)
+void WebContentsAdapter::grantMouseLockPermission(const QUrl &securityOrigin, bool granted)
{
CHECK_INITIALIZED();
+ if (securityOrigin != toQt(m_webContents->GetLastCommittedURL().GetOrigin()))
+ return;
if (granted) {
- if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView()))
+ if (RenderWidgetHostViewQt *rwhv = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView())) {
rwhv->Focus();
- else
+ if (!rwhv->HasFocus()) {
+ // We tried to activate our RWHVQtDelegate, but we failed. This probably means that
+ // the permission was granted from a modal dialog and the windowing system is not ready
+ // to set focus on the originating view. Since pointer lock strongly requires it, we just
+ // wait until the next FocusIn event.
+ m_pendingMouseLockPermissions.insert(securityOrigin, granted);
+ return;
+ }
+ } else
granted = false;
}
m_webContents->GotResponseToLockMouseRequest(granted);
}
+void WebContentsAdapter::handlePendingMouseLockPermission()
+{
+ CHECK_INITIALIZED();
+ auto it = m_pendingMouseLockPermissions.find(toQt(m_webContents->GetLastCommittedURL().GetOrigin()));
+ if (it != m_pendingMouseLockPermissions.end()) {
+ m_webContents->GotResponseToLockMouseRequest(it.value());
+ m_pendingMouseLockPermissions.erase(it);
+ }
+}
+
void WebContentsAdapter::setBackgroundColor(const QColor &color)
{
CHECK_INITIALIZED();
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index cc041ed55..66808ce5e 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -194,7 +194,8 @@ public:
void devToolsFrontendDestroyed(DevToolsFrontendQt *frontend);
void grantMediaAccessPermission(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags flags);
- void grantMouseLockPermission(bool granted);
+ void grantMouseLockPermission(const QUrl &securityOrigin, bool granted);
+ void handlePendingMouseLockPermission();
void runFeatureRequestCallback(const QUrl &securityOrigin, ProfileAdapter::PermissionType feature, bool allowed);
void setBackgroundColor(const QColor &color);
@@ -268,6 +269,7 @@ private:
#endif
WebContentsAdapterClient *m_adapterClient;
quint64 m_nextRequestId;
+ QMap<QUrl, bool> m_pendingMouseLockPermissions;
std::unique_ptr<content::DropData> m_currentDropData;
uint m_currentDropAction;
bool m_updateDragActionCalled;
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 250801f51..04df99f0e 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -469,7 +469,10 @@ 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 QSharedPointer<WebContentsAdapter>
+ adoptNewWindow(QSharedPointer<WebContentsAdapter> newWebContents,
+ WindowOpenDisposition disposition, bool userGesture,
+ const QRect &initialGeometry, const QUrl &targetUrl) = 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 fada874a3..bf0254e82 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -655,7 +655,7 @@ void WebContentsDelegateQt::RequestToLockMouse(content::WebContents *web_content
if (last_unlocked_by_target)
web_contents->GotResponseToLockMouseRequest(true);
else
- m_viewClient->runMouseLockPermissionRequest(toQt(web_contents->GetVisibleURL()));
+ m_viewClient->runMouseLockPermissionRequest(toQt(web_contents->GetLastCommittedURL().GetOrigin()));
}
void WebContentsDelegateQt::overrideWebPreferences(content::WebContents *webContents, content::WebPreferences *webPreferences)
@@ -663,14 +663,17 @@ void WebContentsDelegateQt::overrideWebPreferences(content::WebContents *webCont
m_viewClient->webEngineSettings()->overrideWebPreferences(webContents, webPreferences);
}
-QWeakPointer<WebContentsAdapter> WebContentsDelegateQt::createWindow(std::unique_ptr<content::WebContents> new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture)
+QSharedPointer<WebContentsAdapter>
+WebContentsDelegateQt::createWindow(std::unique_ptr<content::WebContents> new_contents,
+ WindowOpenDisposition disposition, const gfx::Rect &initial_pos,
+ bool user_gesture)
{
QSharedPointer<WebContentsAdapter> newAdapter = QSharedPointer<WebContentsAdapter>::create(std::move(new_contents));
- m_viewClient->adoptNewWindow(newAdapter, static_cast<WebContentsAdapterClient::WindowOpenDisposition>(disposition), user_gesture, toQt(initial_pos), m_initialTargetUrl);
-
- // If the client didn't reference the adapter, it will be deleted now, and the weak pointer zeroed.
- return newAdapter;
+ return m_viewClient->adoptNewWindow(
+ std::move(newAdapter),
+ static_cast<WebContentsAdapterClient::WindowOpenDisposition>(disposition), user_gesture,
+ toQt(initial_pos), m_initialTargetUrl);
}
void WebContentsDelegateQt::allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController)
@@ -797,6 +800,15 @@ bool WebContentsDelegateQt::TakeFocus(content::WebContents *source, bool reverse
return m_viewClient->passOnFocus(reverse);
}
+void WebContentsDelegateQt::ContentsZoomChange(bool zoom_in)
+{
+ WebContentsAdapter *adapter = webContentsAdapter();
+ if (zoom_in)
+ adapter->setZoomFactor(adapter->currentZoomFactor() + 0.1f);
+ else
+ adapter->setZoomFactor(adapter->currentZoomFactor() - 0.1f);
+}
+
FaviconManager *WebContentsDelegateQt::faviconManager()
{
return m_faviconManager.data();
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index f32b02caf..bfef9a1df 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -148,6 +148,7 @@ public:
void RegisterProtocolHandler(content::WebContents* web_contents, const std::string& protocol, const GURL& url, bool user_gesture) override;
void UnregisterProtocolHandler(content::WebContents* web_contents, const std::string& protocol, const GURL& url, bool user_gesture) override;
bool TakeFocus(content::WebContents *source, bool reverse) override;
+ void ContentsZoomChange(bool zoom_in) override;
// WebContentsObserver overrides
void RenderFrameCreated(content::RenderFrameHost *render_frame_host) override;
@@ -200,7 +201,10 @@ public:
base::WeakPtr<WebContentsDelegateQt> AsWeakPtr() { return m_weakPtrFactory.GetWeakPtr(); }
private:
- QWeakPointer<WebContentsAdapter> createWindow(std::unique_ptr<content::WebContents> new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture);
+ QSharedPointer<WebContentsAdapter>
+ createWindow(std::unique_ptr<content::WebContents> new_contents,
+ WindowOpenDisposition disposition, const gfx::Rect &initial_pos,
+ bool user_gesture);
void EmitLoadStarted(const QUrl &url, bool isErrorPage = false);
void EmitLoadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString());
void EmitLoadCommitted();
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 17742e1d7..a28e469a3 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -106,7 +106,7 @@
#include "base/mac/foundation_util.h"
#endif
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
#include "accessibility_activation_observer.h"
#endif
#include "api/qwebengineurlscheme.h"
@@ -125,7 +125,7 @@
#include <QGuiApplication>
#include <QMutex>
#include <QOffscreenSurface>
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
# include <QOpenGLContext>
#endif
#include <QQuickWindow>
@@ -138,7 +138,7 @@
using namespace QtWebEngineCore;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
QT_BEGIN_NAMESPACE
Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
QT_END_NAMESPACE
@@ -146,7 +146,7 @@ QT_END_NAMESPACE
namespace {
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
bool usingANGLE()
{
#if defined(Q_OS_WIN)
@@ -179,7 +179,7 @@ bool usingDefaultSGBackend()
return device.isEmpty();
}
-#endif //QT_NO_OPENGL
+#endif // QT_CONFIG(opengl)
#if QT_CONFIG(webengine_pepper_plugins)
void dummyGetPluginCallback(const std::vector<content::WebPluginInfo>&)
{
@@ -208,7 +208,7 @@ bool usingSoftwareDynamicGL()
{
if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL))
return true;
-#if defined(Q_OS_WIN) && !defined(QT_NO_OPENGL)
+#if defined(Q_OS_WIN) && QT_CONFIG(opengl)
HMODULE handle = static_cast<HMODULE>(QOpenGLContext::openGLModuleHandle());
wchar_t path[MAX_PATH];
DWORD size = GetModuleFileName(handle, path, MAX_PATH);
@@ -261,6 +261,52 @@ static void cleanupVizProcess()
vizCompositorThreadRunner->CleanupForShutdown(base::BindOnce(&completeVizCleanup));
}
+static QStringList parseEnvCommandLine(const QString &cmdLine)
+{
+ QString arg;
+ QStringList arguments;
+ enum { Parse, Quoted, Unquoted } state = Parse;
+ for (const QChar c : cmdLine) {
+ switch (state) {
+ case Parse:
+ if (c == '"') {
+ state = Quoted;
+ } else if (c != ' ' ) {
+ arg += c;
+ state = Unquoted;
+ }
+ // skips spaces
+ break;
+ case Quoted:
+ if (c == '"') {
+ DCHECK(!arg.isEmpty());
+ state = Unquoted;
+ } else {
+ // includes spaces
+ arg += c;
+ }
+ break;
+ case Unquoted:
+ if (c == '"') {
+ // skips quotes
+ state = Quoted;
+ } else if (c == ' ') {
+ arguments.append(arg);
+ arg.clear();
+ state = Parse;
+ } else {
+ arg += c;
+ }
+ break;
+ }
+ }
+ // last arg
+ if (!arg.isEmpty()) {
+ arguments.append(arg);
+ }
+ return arguments;
+}
+
scoped_refptr<QtWebEngineCore::WebEngineContext> WebEngineContext::m_handle;
bool WebEngineContext::m_destroyed = false;
@@ -559,7 +605,7 @@ WebEngineContext::WebEngineContext()
parsedCommandLine->AppendSwitch(switches::kDisableES3GLContext);
#endif
bool threadedGpu = false;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
threadedGpu = QOpenGLContext::supportsThreadedOpenGL();
#if defined(Q_OS_MACOS)
// QtBase disabled it when building on 10.14+, unfortunately we still need it
@@ -595,6 +641,9 @@ WebEngineContext::WebEngineContext()
appendToFeatureList(disableFeatures, network::features::kDnsOverHttpsUpgrade.name);
+ // When enabled, event.movement is calculated in blink instead of in browser.
+ appendToFeatureList(disableFeatures, features::kConsolidatedMovementXY.name);
+
// Explicitly tell Chromium about default-on features we do not support
appendToFeatureList(disableFeatures, features::kBackgroundFetch.name);
appendToFeatureList(disableFeatures, features::kSmsReceiver.name);
@@ -643,7 +692,7 @@ WebEngineContext::WebEngineContext()
GLContextHelper::initialize();
const char *glType = 0;
-#ifndef QT_NO_OPENGL
+#if QT_CONFIG(opengl)
const bool tryGL = (usingDefaultSGBackend() && !usingSoftwareDynamicGL() &&
QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
@@ -709,7 +758,7 @@ WebEngineContext::WebEngineContext()
qWarning("WebEngineContext used before QtWebEngine::initialize() or OpenGL context creation failed.");
}
}
-#endif
+#endif // QT_CONFIG(opengl)
if (glType) {
parsedCommandLine->AppendSwitchASCII(switches::kUseGL, glType);
@@ -796,7 +845,7 @@ WebEngineContext::WebEngineContext()
m_printJobManager.reset(new printing::PrintJobManager());
#endif
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
m_accessibilityActivationObserver.reset(new AccessibilityActivationObserver());
#endif
@@ -829,7 +878,7 @@ base::CommandLine* WebEngineContext::commandLine() {
QStringList appArgs = QCoreApplication::arguments();
if (qEnvironmentVariableIsSet(kChromiumFlagsEnv)) {
appArgs = appArgs.mid(0, 1); // Take application name and drop the rest
- appArgs.append(QString::fromLocal8Bit(qgetenv(kChromiumFlagsEnv)).split(' '));
+ appArgs.append(parseEnvCommandLine(QString::fromLocal8Bit(qgetenv(kChromiumFlagsEnv))));
}
#ifdef Q_OS_WIN
appArgs.removeAll(QStringLiteral("--enable-webgl-software-rendering"));
diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h
index ac0536596..6cbd5c8e5 100644
--- a/src/core/web_engine_context.h
+++ b/src/core/web_engine_context.h
@@ -46,6 +46,7 @@
#include "base/memory/ref_counted.h"
#include "base/values.h"
+#include <QtGui/qtgui-config.h>
#include <QVector>
namespace base {
@@ -142,7 +143,7 @@ private:
std::unique_ptr<ProfileAdapter> m_defaultProfileAdapter;
std::unique_ptr<DevToolsServerQt> m_devtoolsServer;
QVector<ProfileAdapter*> m_profileAdapters;
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
std::unique_ptr<AccessibilityActivationObserver> m_accessibilityActivationObserver;
#endif
diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp
index f37cce6c7..e1db69b16 100644
--- a/src/core/web_event_factory.cpp
+++ b/src/core/web_event_factory.cpp
@@ -71,6 +71,8 @@
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/keycodes/keyboard_code_conversion.h"
+#include "render_widget_host_view_qt_delegate.h"
+
#include <QtGui/private/qtgui-config_p.h>
#include <QCoreApplication>
@@ -84,6 +86,8 @@
#endif
#include <QWheelEvent>
+namespace QtWebEngineCore {
+
using namespace blink;
enum class KeyboardDriver { Unknown, Windows, Cocoa, Xkb, Evdev };
@@ -174,8 +178,13 @@ static QString qtTextForKeyEvent(const QKeyEvent *ev, int qtKey, Qt::KeyboardMod
{
QString text = ev->text();
- if ((qtModifiers & Qt::ControlModifier) &&
- (keyboardDriver() == KeyboardDriver::Xkb || keyboardDriver() == KeyboardDriver::Windows)) {
+ if (keyboardDriver() == KeyboardDriver::Xkb && (qtModifiers & Qt::ControlModifier)) {
+ text.clear();
+ }
+
+ // Keep text for Ctrl+Alt key combinations on Windows. It is an alternative for AltGr.
+ if (keyboardDriver() == KeyboardDriver::Windows
+ && (qtModifiers & Qt::ControlModifier) && !(qtModifiers & Qt::AltModifier)) {
text.clear();
}
@@ -1306,6 +1315,42 @@ static inline WebInputEvent::Modifiers modifiersForEvent(const QInputEvent* even
return (WebInputEvent::Modifiers)result;
}
+static inline Qt::KeyboardModifiers keyboardModifiersForModifier(unsigned int modifier)
+{
+ Qt::KeyboardModifiers modifiers = {};
+ if (modifier & WebInputEvent::kControlKey)
+ modifiers |= Qt::ControlModifier;
+ if (modifier & WebInputEvent::kMetaKey)
+ modifiers |= Qt::MetaModifier;
+ if (modifier & WebInputEvent::kShiftKey)
+ modifiers |= Qt::ShiftModifier;
+ if (modifier & WebInputEvent::kAltKey)
+ modifiers |= Qt::AltModifier;
+ if (modifier & WebInputEvent::kIsKeyPad)
+ modifiers |= Qt::KeypadModifier;
+
+ if (keyboardDriver() == KeyboardDriver::Cocoa && !qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
+ bool controlModifier = modifiers.testFlag(Qt::ControlModifier);
+ bool metaModifier = modifiers.testFlag(Qt::MetaModifier);
+ modifiers.setFlag(Qt::ControlModifier, metaModifier);
+ modifiers.setFlag(Qt::MetaModifier, controlModifier);
+ }
+
+ return modifiers;
+}
+
+static inline Qt::MouseButtons mouseButtonsForModifier(unsigned int modifier)
+{
+ Qt::MouseButtons buttons = {};
+ if (modifier & WebInputEvent::kLeftButtonDown)
+ buttons |= Qt::LeftButton;
+ if (modifier & WebInputEvent::kRightButtonDown)
+ buttons |= Qt::RightButton;
+ if (modifier & WebInputEvent::kMiddleButtonDown)
+ buttons |= Qt::MiddleButton;
+ return buttons;
+}
+
static WebInputEvent::Type webEventTypeForEvent(const QEvent* event)
{
switch (event->type()) {
@@ -1471,6 +1516,14 @@ static void setBlinkWheelEventDelta(blink::WebMouseWheelEvent &webEvent)
webEvent.delta_y = webEvent.wheel_ticks_y * wheelScrollLines * cDefaultQtScrollStep;
}
+static QPoint getWheelEventDelta(const blink::WebGestureEvent &webEvent)
+{
+ static const float cDefaultQtScrollStep = 20.f;
+ static const int wheelScrollLines = QGuiApplication::styleHints()->wheelScrollLines();
+ return QPoint(webEvent.data.scroll_update.delta_x * QWheelEvent::DefaultDeltasPerStep / (wheelScrollLines * cDefaultQtScrollStep),
+ webEvent.data.scroll_update.delta_y * QWheelEvent::DefaultDeltasPerStep / (wheelScrollLines * cDefaultQtScrollStep));
+}
+
blink::WebMouseWheelEvent::Phase toBlinkPhase(QWheelEvent *ev)
{
switch (ev->phase()) {
@@ -1552,6 +1605,26 @@ bool WebEventFactory::coalesceWebWheelEvent(blink::WebMouseWheelEvent &webEvent,
return true;
}
+static QPointF toQt(blink::WebFloatPoint p)
+{
+ return QPointF(p.x, p.y);
+}
+
+void WebEventFactory::sendUnhandledWheelEvent(const blink::WebGestureEvent &event,
+ RenderWidgetHostViewQtDelegate *delegate)
+{
+ Q_ASSERT(event.GetType() == blink::WebInputEvent::kGestureScrollUpdate);
+
+ QWheelEvent ev(toQt(event.PositionInWidget()),
+ toQt(event.PositionInScreen()),
+ QPoint(event.data.scroll_update.delta_x, event.data.scroll_update.delta_y),
+ getWheelEventDelta(event),
+ mouseButtonsForModifier(event.GetModifiers()),
+ keyboardModifiersForModifier(event.GetModifiers()),
+ Qt::NoScrollPhase, false);
+ delegate->unhandledWheelEvent(&ev);
+}
+
content::NativeWebKeyboardEvent WebEventFactory::toWebKeyboardEvent(QKeyEvent *ev)
{
content::NativeWebKeyboardEvent webKitEvent(reinterpret_cast<gfx::NativeEvent>(ev));
@@ -1686,3 +1759,5 @@ bool WebEventFactory::getEditCommand(QKeyEvent *event, std::string *editCommand)
return false;
}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/web_event_factory.h b/src/core/web_event_factory.h
index 526202cfb..390502a9d 100644
--- a/src/core/web_event_factory.h
+++ b/src/core/web_event_factory.h
@@ -63,6 +63,10 @@ class QNativeGestureEvent;
#endif
QT_END_NAMESPACE
+namespace QtWebEngineCore {
+
+class RenderWidgetHostViewQtDelegate;
+
class WebEventFactory {
public:
@@ -77,9 +81,11 @@ public:
#endif
static blink::WebMouseWheelEvent toWebWheelEvent(QWheelEvent *);
static bool coalesceWebWheelEvent(blink::WebMouseWheelEvent &, QWheelEvent *);
+ static void sendUnhandledWheelEvent(const blink::WebGestureEvent &, RenderWidgetHostViewQtDelegate *);
static content::NativeWebKeyboardEvent toWebKeyboardEvent(QKeyEvent*);
static bool getEditCommand(QKeyEvent *event, std::string *editCommand);
};
+} // namespace QtWebEngineCore
#endif // WEB_EVENT_FACTORY_H