summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorMichael BrĂ¼ning <michael.bruning@qt.io>2018-08-20 16:26:03 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-08-21 15:18:19 +0200
commitbe18c1dcfa68328acdf11e0a534749d9a5d75f8b (patch)
tree53a7b347d2771f4502338ac973a80a37edacdee7 /src/core
parentb74e93a9b07243da4f3d2784cde49916de455364 (diff)
parente56dd7e37ea96c4ba1354e319bdaa9d01c401747 (diff)
Merge remote-tracking branch 'origin/5.11' into 5.12
Conflicts: .qmake.conf configure.json examples/webenginewidgets/markdowneditor/resources/3rdparty/marked.js examples/webenginewidgets/markdowneditor/resources/3rdparty/qt_attribution.json examples/webenginewidgets/markdowneditor/resources/markdowneditor.qrc mkspecs/features/platform.prf src/3rdparty src/core/media_capture_devices_dispatcher.cpp src/core/net/url_request_context_getter_qt.cpp src/core/net/url_request_context_getter_qt.h src/core/web_contents_adapter.cpp Change-Id: I467133ba455b1f85f6bb61793794c31cb1094541
Diffstat (limited to 'src/core')
-rw-r--r--src/core/api/qwebengineurlrequestjob.cpp26
-rw-r--r--src/core/config/windows.pri4
-rw-r--r--src/core/devtools_frontend_qt.cpp11
-rw-r--r--src/core/doc/src/qtwebenginecore-module.qdoc2
-rw-r--r--src/core/media_capture_devices_dispatcher.cpp11
-rw-r--r--src/core/net/url_request_custom_job_proxy.cpp2
-rw-r--r--src/core/render_widget_host_view_qt.cpp19
-rw-r--r--src/core/render_widget_host_view_qt.h3
-rw-r--r--src/core/render_widget_host_view_qt_delegate.h1
-rw-r--r--src/core/web_contents_adapter.cpp42
-rw-r--r--src/core/web_contents_adapter.h3
-rw-r--r--src/core/web_engine_context.cpp4
-rw-r--r--src/core/web_event_factory.cpp6
-rw-r--r--src/core/web_event_factory.h4
14 files changed, 105 insertions, 33 deletions
diff --git a/src/core/api/qwebengineurlrequestjob.cpp b/src/core/api/qwebengineurlrequestjob.cpp
index c028a1167..c3541598b 100644
--- a/src/core/api/qwebengineurlrequestjob.cpp
+++ b/src/core/api/qwebengineurlrequestjob.cpp
@@ -115,9 +115,24 @@ QByteArray QWebEngineUrlRequestJob::requestMethod() const
/*!
\since 5.11
- Returns the origin URL of the content that initiated the request. If the
- request was not initiated by web content the function will return an
- empty QUrl.
+ Returns the serialized origin of the content that initiated the request.
+
+ Generally, the origin consists of a scheme, hostname, and port. For example,
+ \c "http://localhost:8080" would be a valid origin. The port is omitted if
+ it is the scheme's default port (80 for \c http, 443 for \c https). The
+ hostname is omitted for non-network schemes such as \c file and \c qrc.
+
+ However, there is also the special value \c "null" representing a unique
+ origin. It is, for example, the origin of a sandboxed iframe. The purpose of
+ this special origin is to be always different from all other origins in the
+ same-origin check. In other words, content with a unique origin should never
+ have privileged access to any other content.
+
+ Finally, if the request was not initiated by web content, the function will
+ return an empty QUrl. This happens, for example, when you call \l
+ QWebEnginePage::setUrl().
+
+ This value can be used for implementing secure cross-origin checks.
*/
QUrl QWebEngineUrlRequestJob::initiator() const
{
@@ -136,9 +151,10 @@ QUrl QWebEngineUrlRequestJob::initiator() const
The device should remain available at least as long as the job exists.
When calling this method with a newly constructed device, one solution is to
- make the device delete itself when closed, like this:
+ make the device as a child of the job or delete itself when job is deleted,
+ like this:
\code
- connect(device, &QIODevice::aboutToClose, device, &QObject::deleteLater);
+ connect(job, &QObject::destroyed, device, &QObject::deleteLater);
\endcode
*/
void QWebEngineUrlRequestJob::reply(const QByteArray &contentType, QIODevice *device)
diff --git a/src/core/config/windows.pri b/src/core/config/windows.pri
index b3e4cf77d..5aa511da3 100644
--- a/src/core/config/windows.pri
+++ b/src/core/config/windows.pri
@@ -57,7 +57,7 @@ msvc {
equals(MSVC_VER, 15.0) {
MSVS_VERSION = 2017
} else {
- fatal("Visual Studio compiler version \"$$MSVC_VER\" is not supported by Qt WebEngine")
+ error("Visual Studio compiler version \"$$MSVC_VER\" is not supported by Qt WebEngine")
}
gn_args += visual_studio_version=$$MSVS_VERSION
@@ -71,5 +71,5 @@ msvc {
gn_args += target_cpu=\"$$GN_TARGET_CPU\"
} else {
- fatal("Qt WebEngine for Windows can only be built with the Microsoft Visual Studio C++ compiler")
+ error("Qt WebEngine for Windows can only be built with the Microsoft Visual Studio C++ compiler")
}
diff --git a/src/core/devtools_frontend_qt.cpp b/src/core/devtools_frontend_qt.cpp
index 154b275b5..bd9e0ebe7 100644
--- a/src/core/devtools_frontend_qt.cpp
+++ b/src/core/devtools_frontend_qt.cpp
@@ -446,7 +446,16 @@ void DevToolsFrontendQt::HandleMessageFromDevToolsFrontend(const std::string &me
WindowOpenDisposition::NEW_FOREGROUND_TAB,
ui::PAGE_TRANSITION_LINK,
false);
- m_frontendDelegate->OpenURLFromTab(nullptr, openParams);
+ // OpenURL will (via WebContentsDelegateQt::OpenURLFromTab) call
+ // application code, which may decide to close this devtools view (see
+ // quicknanobrowser for example).
+ //
+ // Chromium always calls SendMessageAck through a callback bound to a
+ // WeakPtr, we do the same here, except without the callback.
+ base::WeakPtr<DevToolsFrontendQt> weakThis = m_weakFactory.GetWeakPtr();
+ web_contents()->OpenURL(openParams);
+ if (!weakThis)
+ return;
} else if (method == "bringToFront") {
Activate();
} else {
diff --git a/src/core/doc/src/qtwebenginecore-module.qdoc b/src/core/doc/src/qtwebenginecore-module.qdoc
index 2ed0a4c06..65e0766de 100644
--- a/src/core/doc/src/qtwebenginecore-module.qdoc
+++ b/src/core/doc/src/qtwebenginecore-module.qdoc
@@ -43,9 +43,11 @@
indirectly included through the \l{Qt WebEngine QML Types}{Qt WebEngine} or
\l{Qt WebEngine Widgets C++ Classes}{Qt WebEngine Widgets} modules.
+ \if !defined(qtforpython)
To link against the module, add this line to your qmake project file:
\snippet qtwebenginecore_build_snippet.qdoc 0
However, \c webenginecore is implied by adding \c webengine or \c webenginewidgets.
+ \endif
*/
diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp
index 5298e29cf..b6e59f3bb 100644
--- a/src/core/media_capture_devices_dispatcher.cpp
+++ b/src/core/media_capture_devices_dispatcher.cpp
@@ -114,7 +114,16 @@ void getDevicesForDesktopCapture(
content::DesktopMediaID getDefaultScreenId()
{
-#if QT_CONFIG(webengine_webrtc)
+ // While this function is executing another thread may also want to create a
+ // DesktopCapturer [1]. Unfortunately, creating a DesktopCapturer is not
+ // thread safe on X11 due to the use of webrtc::XErrorTrap. It's safe to
+ // disable this code on X11 since we don't actually need to create a
+ // DesktopCapturer to get the screen id anyway
+ // (ScreenCapturerLinux::GetSourceList always returns 0 as the id).
+ //
+ // [1]: webrtc::InProcessVideoCaptureDeviceLauncher::DoStartDesktopCaptureOnDeviceThread
+
+#if QT_CONFIG(webengine_webrtc) && !defined(USE_X11)
// Source id patterns are different across platforms.
// On Linux, the hardcoded value "0" is used.
// On Windows, the screens are enumerated consecutively in increasing order from 0.
diff --git a/src/core/net/url_request_custom_job_proxy.cpp b/src/core/net/url_request_custom_job_proxy.cpp
index 5280318ad..b5f10388c 100644
--- a/src/core/net/url_request_custom_job_proxy.cpp
+++ b/src/core/net/url_request_custom_job_proxy.cpp
@@ -159,7 +159,7 @@ void URLRequestCustomJobProxy::initialize(GURL url, std::string method, base::Op
QUrl initiatorOrigin;
if (initiator.has_value())
- initiatorOrigin = toQt(initiator.value().GetURL());
+ initiatorOrigin = QUrl::fromEncoded(QByteArray::fromStdString(initiator.value().Serialize()));
QWebEngineUrlSchemeHandler *schemeHandler = nullptr;
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 3e5d9bc4b..e706c5869 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -1073,7 +1073,11 @@ bool RenderWidgetHostViewQt::forwardEvent(QEvent *event)
case QEvent::MouseMove:
// Skip second MouseMove event when a window is being adopted, so that Chromium
// can properly handle further move events.
- if (m_adapterClient->isBeingAdopted())
+ // Also make sure the adapter client exists to prevent a null pointer dereference,
+ // because it's possible for a QWebEnginePagePrivate (adapter) instance to be destroyed,
+ // and then the OS (observed on Windows) might still send mouse move events to a still
+ // existing popup RWHVQDW instance.
+ if (m_adapterClient && m_adapterClient->isBeingAdopted())
return false;
handleMouseEvent(static_cast<QMouseEvent*>(event));
break;
@@ -1091,12 +1095,14 @@ bool RenderWidgetHostViewQt::forwardEvent(QEvent *event)
case QEvent::TouchCancel:
handleTouchEvent(static_cast<QTouchEvent*>(event));
break;
+#if QT_CONFIG(tabletevent)
case QEvent::TabletPress:
Focus(); // Fall through.
case QEvent::TabletRelease:
case QEvent::TabletMove:
handleTabletEvent(static_cast<QTabletEvent*>(event));
break;
+#endif
#ifndef QT_NO_GESTURES
case QEvent::NativeGesture:
handleGestureEvent(static_cast<QNativeGestureEvent *>(event));
@@ -1172,6 +1178,15 @@ QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query)
}
}
+void RenderWidgetHostViewQt::closePopup()
+{
+ // We notify the popup to be closed by telling it that it lost focus. WebKit does the rest
+ // (hiding the widget and automatic memory cleanup via
+ // RenderWidget::CloseWidgetSoon() -> RenderWidgetHostImpl::ShutdownAndDestroyWidget(true).
+ m_host->SetActive(false);
+ m_host->Blur();
+}
+
void RenderWidgetHostViewQt::ProcessAckedTouchEvent(const content::TouchEventWithLatencyInfo &touch, content::InputEventAckState ack_result) {
Q_UNUSED(touch);
const bool eventConsumed = ack_result == content::INPUT_EVENT_ACK_STATE_CONSUMED;
@@ -1617,10 +1632,12 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev)
}
}
+#if QT_CONFIG(tabletevent)
void RenderWidgetHostViewQt::handleTabletEvent(QTabletEvent *event)
{
handlePointerEvent<QTabletEvent>(event);
}
+#endif
template<class T>
void RenderWidgetHostViewQt::handlePointerEvent(T *event)
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index 0779136f0..7b270e2b3 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -173,6 +173,7 @@ public:
void windowChanged() override;
bool forwardEvent(QEvent *) override;
QVariant inputMethodQuery(Qt::InputMethodQuery query) override;
+ void closePopup() override;
// Overridden from content::TextInputManager::Observer
void OnUpdateTextInputStateCalled(content::TextInputManager *text_input_manager, RenderWidgetHostViewBase *updated_view, bool did_update_state) override;
@@ -187,7 +188,9 @@ public:
void handleKeyEvent(QKeyEvent*);
void handleWheelEvent(QWheelEvent*);
void handleTouchEvent(QTouchEvent*);
+#if QT_CONFIG(tabletevent)
void handleTabletEvent(QTabletEvent *ev);
+#endif
#ifndef QT_NO_GESTURES
void handleGestureEvent(QNativeGestureEvent *);
#endif
diff --git a/src/core/render_widget_host_view_qt_delegate.h b/src/core/render_widget_host_view_qt_delegate.h
index 55dd1923a..051e3f9cc 100644
--- a/src/core/render_widget_host_view_qt_delegate.h
+++ b/src/core/render_widget_host_view_qt_delegate.h
@@ -89,6 +89,7 @@ public:
virtual void windowChanged() = 0;
virtual bool forwardEvent(QEvent *) = 0;
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) = 0;
+ virtual void closePopup() = 0;
};
class QWEBENGINECORE_PRIVATE_EXPORT RenderWidgetHostViewQtDelegate {
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 84b97412b..c7c20c23e 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -1450,23 +1450,6 @@ static void fillDropDataFromMimeData(content::DropData *dropData, const QMimeDat
}
}
-void WebContentsAdapter::enterDrag(QDragEnterEvent *e, const QPointF &screenPos)
-{
- CHECK_INITIALIZED();
-
- if (!m_currentDropData) {
- // The drag originated outside the WebEngineView.
- m_currentDropData.reset(new content::DropData);
- fillDropDataFromMimeData(m_currentDropData.get(), e->mimeData());
- }
-
- content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
- rvh->GetWidget()->FilterDropData(m_currentDropData.get());
- rvh->GetWidget()->DragTargetDragEnter(*m_currentDropData, toGfx(e->posF()), toGfx(screenPos),
- toWeb(e->possibleActions()),
- flagsFromModifiers(e->keyboardModifiers()));
-}
-
Qt::DropAction toQt(blink::WebDragOperation op)
{
if (op & blink::kWebDragOperationCopy)
@@ -1504,6 +1487,23 @@ static int toWeb(Qt::KeyboardModifiers modifiers)
return result;
}
+void WebContentsAdapter::enterDrag(QDragEnterEvent *e, const QPointF &screenPos)
+{
+ CHECK_INITIALIZED();
+
+ if (!m_currentDropData) {
+ // The drag originated outside the WebEngineView.
+ m_currentDropData.reset(new content::DropData);
+ fillDropDataFromMimeData(m_currentDropData.get(), e->mimeData());
+ }
+
+ content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
+ rvh->GetWidget()->FilterDropData(m_currentDropData.get());
+ rvh->GetWidget()->DragTargetDragEnter(*m_currentDropData, toGfx(e->posF()), toGfx(screenPos),
+ toWeb(e->possibleActions()),
+ toWeb(e->mouseButtons()) | toWeb(e->keyboardModifiers()));
+}
+
Qt::DropAction WebContentsAdapter::updateDragPosition(QDragMoveEvent *e, const QPointF &screenPos)
{
CHECK_INITIALIZED(Qt::DropAction());
@@ -1545,14 +1545,16 @@ void WebContentsAdapter::updateDragAction(int action)
m_currentDropAction = static_cast<blink::WebDragOperation>(action);
}
-void WebContentsAdapter::endDragging(const QPointF &clientPos, const QPointF &screenPos)
+void WebContentsAdapter::endDragging(QDropEvent *e, const QPointF &screenPos)
{
CHECK_INITIALIZED();
content::RenderViewHost *rvh = m_webContents->GetRenderViewHost();
rvh->GetWidget()->FilterDropData(m_currentDropData.get());
- m_lastDragClientPos = clientPos;
+ m_lastDragClientPos = e->posF();
m_lastDragScreenPos = screenPos;
- rvh->GetWidget()->DragTargetDrop(*m_currentDropData, toGfx(m_lastDragClientPos), toGfx(m_lastDragScreenPos), 0);
+ rvh->GetWidget()->DragTargetDrop(*m_currentDropData, toGfx(m_lastDragClientPos), toGfx(m_lastDragScreenPos),
+ toWeb(e->mouseButtons()) | toWeb(e->keyboardModifiers()));
+
m_currentDropData.reset();
}
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index bd2ca4b23..99114546d 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -73,6 +73,7 @@ QT_BEGIN_NAMESPACE
class QAccessibleInterface;
class QDragEnterEvent;
class QDragMoveEvent;
+class QDropEvent;
class QMimeData;
class QPageLayout;
class QString;
@@ -205,7 +206,7 @@ public:
void enterDrag(QDragEnterEvent *e, const QPointF &screenPos);
Qt::DropAction updateDragPosition(QDragMoveEvent *e, const QPointF &screenPos);
void updateDragAction(int action);
- void endDragging(const QPointF &clientPos, const QPointF &screenPos);
+ void endDragging(QDropEvent *e, const QPointF &screenPos);
void leaveDrag();
#endif // QT_CONFIG(draganddrop)
void printToPDF(const QPageLayout&, const QString&);
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index a7301e02d..899e50e16 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -516,8 +516,10 @@ WebEngineContext::WebEngineContext()
parsedCommandLine->AppendSwitchASCII(switches::kUseGL, glType);
parsedCommandLine->AppendSwitch(switches::kInProcessGPU);
#ifdef Q_OS_WIN
- if (enableWebGLSoftwareRendering)
+ if (enableWebGLSoftwareRendering) {
parsedCommandLine->AppendSwitch(switches::kDisableGpuRasterization);
+ parsedCommandLine->AppendSwitch(switches::kIgnoreGpuBlacklist);
+ }
#endif
} else {
parsedCommandLine->AppendSwitch(switches::kDisableGpu);
diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp
index b8e8b1689..a1fd3e55b 100644
--- a/src/core/web_event_factory.cpp
+++ b/src/core/web_event_factory.cpp
@@ -76,7 +76,9 @@
#include <QKeyEvent>
#include <QMouseEvent>
#include <QStyleHints>
+#if QT_CONFIG(tabletevent)
#include <QTabletEvent>
+#endif
#include <QWheelEvent>
using namespace blink;
@@ -1186,6 +1188,7 @@ static WebInputEvent::Type webEventTypeForEvent(const QEvent* event)
}
}
+#if QT_CONFIG(tabletevent)
static WebPointerProperties::PointerType pointerTypeForTabletEvent(const QTabletEvent *ev)
{
switch (ev->pointerType()) {
@@ -1199,6 +1202,7 @@ static WebPointerProperties::PointerType pointerTypeForTabletEvent(const QTablet
return WebPointerProperties::PointerType::kMouse;
}
}
+#endif
WebMouseEvent WebEventFactory::toWebMouseEvent(QMouseEvent *ev, double dpiScale)
{
@@ -1230,6 +1234,7 @@ WebMouseEvent WebEventFactory::toWebMouseEvent(QHoverEvent *ev, double dpiScale)
return webKitEvent;
}
+#if QT_CONFIG(tabletevent)
WebMouseEvent WebEventFactory::toWebMouseEvent(QTabletEvent *ev, double dpiScale)
{
WebMouseEvent webKitEvent(webEventTypeForEvent(ev),
@@ -1248,6 +1253,7 @@ WebMouseEvent WebEventFactory::toWebMouseEvent(QTabletEvent *ev, double dpiScale
webKitEvent.pointer_type = pointerTypeForTabletEvent(ev);
return webKitEvent;
}
+#endif
WebMouseEvent WebEventFactory::toWebMouseEvent(QEvent *ev)
{
diff --git a/src/core/web_event_factory.h b/src/core/web_event_factory.h
index dc29970a7..4b22de7d7 100644
--- a/src/core/web_event_factory.h
+++ b/src/core/web_event_factory.h
@@ -54,7 +54,9 @@ class QEvent;
class QHoverEvent;
class QKeyEvent;
class QMouseEvent;
+#ifndef QT_NO_TABLETEVENT
class QTabletEvent;
+#endif
class QWheelEvent;
#ifndef QT_NO_GESTURES
class QNativeGestureEvent;
@@ -66,7 +68,9 @@ class WebEventFactory {
public:
static blink::WebMouseEvent toWebMouseEvent(QMouseEvent*, double dpiScale);
static blink::WebMouseEvent toWebMouseEvent(QHoverEvent*, double dpiScale);
+#ifndef QT_NO_TABLETEVENT
static blink::WebMouseEvent toWebMouseEvent(QTabletEvent*, double dpiScale);
+#endif
static blink::WebMouseEvent toWebMouseEvent(QEvent *);
#ifndef QT_NO_GESTURES
static blink::WebGestureEvent toWebGestureEvent(QNativeGestureEvent *, double dpiScale);