diff options
author | Michael BrĂ¼ning <michael.bruning@qt.io> | 2018-08-20 16:26:03 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-08-21 15:18:19 +0200 |
commit | be18c1dcfa68328acdf11e0a534749d9a5d75f8b (patch) | |
tree | 53a7b347d2771f4502338ac973a80a37edacdee7 /src | |
parent | b74e93a9b07243da4f3d2784cde49916de455364 (diff) | |
parent | e56dd7e37ea96c4ba1354e319bdaa9d01c401747 (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')
23 files changed, 137 insertions, 45 deletions
diff --git a/src/3rdparty b/src/3rdparty -Subproject d4ae420c54b0e8b4660b5c41ec0c38049115f9a +Subproject 922a17dfc0045e5ca565faf446c8ce09557e92c 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); diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 02666d363..f0c071161 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -1497,7 +1497,7 @@ void QQuickWebEngineView::dropEvent(QDropEvent *e) { Q_D(QQuickWebEngineView); e->accept(); - d->adapter->endDragging(e->pos(), mapToScreen(this, e->pos())); + d->adapter->endDragging(e, mapToScreen(this, e->pos())); } #endif // QT_CONFIG(draganddrop) diff --git a/src/webengine/doc/src/qtwebengine-module.qdoc b/src/webengine/doc/src/qtwebengine-module.qdoc index 97657f6a9..2d4d1b8da 100644 --- a/src/webengine/doc/src/qtwebengine-module.qdoc +++ b/src/webengine/doc/src/qtwebengine-module.qdoc @@ -38,7 +38,9 @@ \snippet qtwebengine_build_snippet.qdoc 1 + \if !defined(qtforpython) To link against the module, add the following to your qmake project file: \snippet qtwebengine_build_snippet.qdoc 0 + \endif */ diff --git a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc index 403cdf330..6c8703fe4 100644 --- a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc +++ b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc @@ -73,7 +73,7 @@ \section2 Linux - On Linux, Clang or GCC version 4.7 or later is required. + On Linux, Clang or GCC version 5 or later is required. Supported configurations are \c linux-g++ and \c{linux-clang}. Qt WebEngine requires \c pkg-config to detect most of its dependencies. The diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 6a4554b57..96468f173 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -2365,6 +2365,11 @@ void QWebEnginePage::printToPdf(const QWebEngineCallback<const QByteArray&> &res It is the users responsibility to ensure the \a printer remains valid until \a resultCallback has been called. + \note The rendering of the current content into a temporary PDF document is asynchronous and does + not block the main thread. However, the subsequent rendering of PDF into \a printer runs on the + main thread and will therefore block the event loop. Moreover, printing runs on the browser + process, which is by default not sandboxed. + The \a resultCallback must take a boolean as parameter. If printing was successful, this boolean will have the value \c true, otherwise, its value will be \c false. \since 5.8 diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp index 369c6b02b..a207af392 100644 --- a/src/webenginewidgets/api/qwebengineview.cpp +++ b/src/webenginewidgets/api/qwebengineview.cpp @@ -423,7 +423,7 @@ void QWebEngineView::dropEvent(QDropEvent *e) if (!d->m_dragEntered) return; e->accept(); - d->page->d_ptr->adapter->endDragging(e->pos(), mapToGlobal(e->pos())); + d->page->d_ptr->adapter->endDragging(e, mapToGlobal(e->pos())); d->m_dragEntered = false; } #endif // QT_CONFIG(draganddrop) diff --git a/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc b/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc index e4f259882..35fed802c 100644 --- a/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc +++ b/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc @@ -41,7 +41,9 @@ \snippet qtwebenginewidgets_build_snippet.qdoc 1 + \if !defined(qtforpython) To link against the module, add the following to your qmake project file: \snippet qtwebenginewidgets_build_snippet.qdoc 0 + \endif */ diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp index 9497ba0fa..d7bcd0ae3 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp @@ -218,20 +218,24 @@ void RenderWidgetHostViewQtDelegateWidget::initAsPopup(const QRect& screenRect) // to be destroyed. setAttribute(Qt::WA_ShowWithoutActivating); setFocusPolicy(Qt::NoFocus); - -#ifdef Q_OS_MACOS - // macOS doesn't like Qt::ToolTip when QWebEngineView is inside a modal dialog, specifically by - // not forwarding click events to the popup. So we use Qt::Tool which behaves the same way, but - // works on macOS too. - setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus); -#else - setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus); -#endif + setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus); setGeometry(screenRect); show(); } +void RenderWidgetHostViewQtDelegateWidget::closeEvent(QCloseEvent *event) +{ + Q_UNUSED(event); + + // If a close event was received from the window manager (e.g. when moving the parent window, + // clicking outside the popup area) + // make sure to notify the Chromium WebUI popup and its underlying + // RenderWidgetHostViewQtDelegate instance to be closed. + if (m_isPopup) + m_client->closePopup(); +} + QRectF RenderWidgetHostViewQtDelegateWidget::screenRect() const { return QRectF(x(), y(), width(), height()); diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h index 79958132c..42b454bc5 100644 --- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h +++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h @@ -48,6 +48,12 @@ namespace QtWebEngineCore { +// Useful information keyboard and mouse QEvent propagation. +// A RenderWidgetHostViewQtDelegateWidget instance initialized as a popup will receive +// no keyboard focus (so all keyboard QEvents will be sent to the parent RWHVQD instance), +// but will still receive mouse input (all mouse QEvent moves and clicks will be given to the popup +// RWHVQD instance, and the mouse interaction area covers the surface of the whole parent +// QWebEngineView, and not only the smaller surface that an HTML select popup would occupy). class RenderWidgetHostViewQtDelegateWidget : public QQuickWidget, public RenderWidgetHostViewQtDelegate { Q_OBJECT public: @@ -83,6 +89,7 @@ protected: void resizeEvent(QResizeEvent *resizeEvent) override; void showEvent(QShowEvent *) override; void hideEvent(QHideEvent *) override; + void closeEvent(QCloseEvent *event) override; QVariant inputMethodQuery(Qt::InputMethodQuery query) const override; |