Skip to content

Commit da4d5bd

Browse files
author
Allan Sandfeld Jensen
committed
Merge branch '5.6' into 5.7
Conflicts: src/core/api/qwebengineurlrequestinfo.cpp src/core/api/qwebengineurlrequestinfo.h src/core/core_gyp_generator.pro Change-Id: I5c78f0c86f6dcd61697148f0729d3d3a2cb2c76f
2 parents b44962c + 95a2223 commit da4d5bd

File tree

11 files changed

+111
-13
lines changed

11 files changed

+111
-13
lines changed

src/core/api/qwebengineurlrequestinfo.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypePing, content::RESOURCE
6464
ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeServiceWorker, content::RESOURCE_TYPE_SERVICE_WORKER)
6565
ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeCspReport, content::RESOURCE_TYPE_CSP_REPORT)
6666
ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypePluginResource, content::RESOURCE_TYPE_PLUGIN_RESOURCE)
67-
ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeUnknown, content::RESOURCE_TYPE_LAST_TYPE)
67+
ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeLast, content::RESOURCE_TYPE_LAST_TYPE)
6868

6969
ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::LinkNavigation, QWebEngineUrlRequestInfo::NavigationTypeLink)
7070
ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::TypedNavigation, QWebEngineUrlRequestInfo::NavigationTypeTyped)
@@ -175,6 +175,9 @@ QWebEngineUrlRequestInfo::QWebEngineUrlRequestInfo(QWebEngineUrlRequestInfoPriva
175175
HTTP POST requests to specified servers. (Added in Qt 5.7)
176176
\value ResourceTypePluginResource A resource requested by a plugin. (Added in Qt 5.7)
177177
\value ResourceTypeUnknown Unknown request type.
178+
179+
\note For forward compatibility all values not matched should be treated as unknown,
180+
not just \c ResourceTypeUnknown.
178181
*/
179182

180183
/*!

src/core/api/qwebengineurlrequestinfo.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ class QWEBENGINE_EXPORT QWebEngineUrlRequestInfo {
7575
ResourceTypeServiceWorker, // the main resource of a service worker.
7676
ResourceTypeCspReport, // Content Security Policy (CSP) violation report
7777
ResourceTypePluginResource, // A resource requested by a plugin
78-
ResourceTypeUnknown
78+
#ifndef Q_QDOC
79+
ResourceTypeLast,
80+
#endif
81+
ResourceTypeUnknown = 255
7982
};
8083

8184
enum NavigationType {

src/core/common/qt_ipc_logging.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/****************************************************************************
2+
**
3+
** Copyright (C) 2016 The Qt Company Ltd.
4+
** Contact: https://www.qt.io/licensing/
5+
**
6+
** This file is part of the QtWebEngine module of the Qt Toolkit.
7+
**
8+
** $QT_BEGIN_LICENSE:LGPL$
9+
** Commercial License Usage
10+
** Licensees holding valid commercial Qt licenses may use this file in
11+
** accordance with the commercial license agreement provided with the
12+
** Software or, alternatively, in accordance with the terms contained in
13+
** a written agreement between you and The Qt Company. For licensing terms
14+
** and conditions see https://www.qt.io/terms-conditions. For further
15+
** information use the contact form at https://www.qt.io/contact-us.
16+
**
17+
** GNU Lesser General Public License Usage
18+
** Alternatively, this file may be used under the terms of the GNU Lesser
19+
** General Public License version 3 as published by the Free Software
20+
** Foundation and appearing in the file LICENSE.LGPL3 included in the
21+
** packaging of this file. Please review the following information to
22+
** ensure the GNU Lesser General Public License version 3 requirements
23+
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24+
**
25+
** GNU General Public License Usage
26+
** Alternatively, this file may be used under the terms of the GNU
27+
** General Public License version 2.0 or (at your option) the GNU General
28+
** Public license version 3 or any later version approved by the KDE Free
29+
** Qt Foundation. The licenses are as published by the Free Software
30+
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31+
** included in the packaging of this file. Please review the following
32+
** information to ensure the GNU General Public License requirements will
33+
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34+
** https://www.gnu.org/licenses/gpl-3.0.html.
35+
**
36+
** $QT_END_LICENSE$
37+
**
38+
****************************************************************************/
39+
40+
#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED
41+
42+
#if defined(IPC_MESSAGE_LOG_ENABLED)
43+
#define IPC_MESSAGE_MACROS_LOG_ENABLED
44+
#include "content/public/common/content_ipc_logging.h"
45+
#define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \
46+
content::RegisterIPCLogger(msg_id, logger)
47+
#include "common/qt_messages.h"
48+
#endif

src/core/core_gyp_generator.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ SOURCES = \
4646
clipboard_qt.cpp \
4747
color_chooser_qt.cpp \
4848
color_chooser_controller.cpp \
49+
common/qt_ipc_logging.cpp \
4950
common/qt_messages.cpp \
5051
common/user_script_data.cpp \
5152
content_client_qt.cpp \

src/core/network_delegate_qt.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
namespace QtWebEngineCore {
6060

61-
int pageTransitionToNavigationType(ui::PageTransition transition)
61+
WebContentsAdapterClient::NavigationType pageTransitionToNavigationType(ui::PageTransition transition)
6262
{
6363
int32_t qualifier = ui::PageTransitionGetQualifier(transition);
6464

@@ -81,6 +81,18 @@ int pageTransitionToNavigationType(ui::PageTransition transition)
8181
}
8282
}
8383

84+
QWebEngineUrlRequestInfo::ResourceType toQt(content::ResourceType resourceType)
85+
{
86+
if (resourceType >= 0 && resourceType < content::ResourceType(QWebEngineUrlRequestInfo::ResourceTypeLast))
87+
return static_cast<QWebEngineUrlRequestInfo::ResourceType>(resourceType);
88+
return QWebEngineUrlRequestInfo::ResourceTypeUnknown;
89+
}
90+
91+
QWebEngineUrlRequestInfo::NavigationType toQt(WebContentsAdapterClient::NavigationType navigationType)
92+
{
93+
return static_cast<QWebEngineUrlRequestInfo::NavigationType>(navigationType);
94+
}
95+
8496
NetworkDelegateQt::NetworkDelegateQt(URLRequestContextGetterQt *requestContext)
8597
: m_requestContextGetter(requestContext)
8698
{
@@ -94,7 +106,7 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, const net::C
94106
const content::ResourceRequestInfo *resourceInfo = content::ResourceRequestInfo::ForRequest(request);
95107

96108
content::ResourceType resourceType = content::RESOURCE_TYPE_LAST_TYPE;
97-
int navigationType = QWebEngineUrlRequestInfo::NavigationTypeOther;
109+
WebContentsAdapterClient::NavigationType navigationType = WebContentsAdapterClient::OtherNavigation;
98110

99111
if (resourceInfo) {
100112
resourceType = resourceInfo->GetResourceType();
@@ -105,11 +117,11 @@ int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, const net::C
105117

106118
QWebEngineUrlRequestInterceptor* interceptor = m_requestContextGetter->m_requestInterceptor;
107119
if (interceptor) {
108-
QWebEngineUrlRequestInfoPrivate *infoPrivate = new QWebEngineUrlRequestInfoPrivate(static_cast<QWebEngineUrlRequestInfo::ResourceType>(resourceType)
109-
, static_cast<QWebEngineUrlRequestInfo::NavigationType>(navigationType)
110-
, qUrl
111-
, toQt(request->first_party_for_cookies())
112-
, QByteArray::fromStdString(request->method()));
120+
QWebEngineUrlRequestInfoPrivate *infoPrivate = new QWebEngineUrlRequestInfoPrivate(toQt(resourceType),
121+
toQt(navigationType),
122+
qUrl,
123+
toQt(request->first_party_for_cookies()),
124+
QByteArray::fromStdString(request->method()));
113125
QWebEngineUrlRequestInfo requestInfo(infoPrivate);
114126
interceptor->interceptRequest(requestInfo);
115127
if (requestInfo.changed()) {

src/core/web_contents_delegate_qt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ void WebContentsDelegateQt::requestGeolocationPermission(const QUrl &requestingO
421421
m_viewClient->runGeolocationPermissionRequest(requestingOrigin);
422422
}
423423

424-
extern int pageTransitionToNavigationType(ui::PageTransition transition);
424+
extern WebContentsAdapterClient::NavigationType pageTransitionToNavigationType(ui::PageTransition transition);
425425

426426
void WebContentsDelegateQt::launchExternalURL(const QUrl &url, ui::PageTransition page_transition, bool is_main_frame)
427427
{

src/webenginewidgets/api/qwebenginepage.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,16 @@ QWebEnginePagePrivate::~QWebEnginePagePrivate()
152152

153153
RenderWidgetHostViewQtDelegate *QWebEnginePagePrivate::CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQtDelegateClient *client)
154154
{
155-
return new RenderWidgetHostViewQtDelegateWidget(client);
155+
// Set the QWebEngineView as the parent for a popup delegate, so that the new popup window
156+
// responds properly to clicks in case the QWebEngineView is inside a modal QDialog. Setting the
157+
// parent essentially notifies the OS that the popup window is part of the modal session, and
158+
// should allow interaction.
159+
// The new delegate will not be deleted by the parent view though, because we unset the parent
160+
// when the parent is destroyed. The delegate will be destroyed by Chromium when the popup is
161+
// dismissed.
162+
// If the delegate is not for a popup, but for a newly created QWebEngineView, the parent is 0
163+
// just like before.
164+
return new RenderWidgetHostViewQtDelegateWidget(client, this->view);
156165
}
157166

158167
void QWebEnginePagePrivate::titleChanged(const QString &title)

src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende
106106
setAttribute(Qt::WA_AcceptTouchEvents);
107107
setAttribute(Qt::WA_OpaquePaintEvent);
108108
setAttribute(Qt::WA_AlwaysShowToolTips);
109+
110+
if (parent) {
111+
// Unset the popup parent if the parent is being destroyed, thus making sure a double
112+
// delete does not happen.
113+
// Also in case the delegate is destroyed before its parent (when a popup is simply
114+
// dismissed), this connection will automatically be removed by ~QObject(), preventing
115+
// a use-after-free.
116+
connect(parent, &QObject::destroyed,
117+
this, &RenderWidgetHostViewQtDelegateWidget::removeParentBeforeParentDelete);
118+
}
119+
}
120+
121+
void RenderWidgetHostViewQtDelegateWidget::removeParentBeforeParentDelete()
122+
{
123+
setParent(Q_NULLPTR);
109124
}
110125

111126
void RenderWidgetHostViewQtDelegateWidget::initAsChild(WebContentsAdapterClient* container)
@@ -128,7 +143,11 @@ void RenderWidgetHostViewQtDelegateWidget::initAsPopup(const QRect& screenRect)
128143
// to be destroyed.
129144
setAttribute(Qt::WA_ShowWithoutActivating);
130145
setFocusPolicy(Qt::NoFocus);
131-
setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
146+
147+
// macOS doesn't like Qt::ToolTip when QWebEngineView is inside a modal dialog, specifically by
148+
// not forwarding click events to the popup. So we use Qt::Tool which behaves the same way, but
149+
// works on macOS too.
150+
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
132151

133152
setGeometry(screenRect);
134153
show();

src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class RenderWidgetHostViewQtDelegateWidget : public QOpenGLWidget, public Render
9595

9696
private slots:
9797
void onWindowPosChanged();
98+
void removeParentBeforeParentDelete();
9899

99100
private:
100101
RenderWidgetHostViewQtDelegateClient *m_client;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[doNotSendMouseKeyboardEventsWhenDisabled]
2+
windows

tools/qmake/mkspecs/features/functions.prf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ defineReplace(getConfigDir) {
155155
}
156156

157157
defineReplace(getChromiumSrcDir) {
158-
git_chromium_src_dir = $$system("git config qtwebengine.chromiumsrcdir")
158+
exists($$QTWEBENGINE_ROOT/.git): git_chromium_src_dir = $$system("git config qtwebengine.chromiumsrcdir")
159159
# Fall back to the snapshot path if git does not know about chromium sources (i.e. init-repository.py has not been used)
160160
isEmpty(git_chromium_src_dir): git_chromium_src_dir = "src/3rdparty/chromium"
161161
return($$git_chromium_src_dir)

0 commit comments

Comments
 (0)