From 41efbaf2d737ef35808ce19e1125db35757bfdce Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 16 Nov 2018 12:04:30 +0100 Subject: Clean-up coding style in content_utility_client_qt Change-Id: I619874b4c90bc5f5d57c68c8a106ab686702ff12 Reviewed-by: Michal Klocek --- src/core/content_utility_client_qt.cpp | 23 ++++++++++++----------- src/core/content_utility_client_qt.h | 15 ++++++++++----- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/core/content_utility_client_qt.cpp b/src/core/content_utility_client_qt.cpp index 9e86826fe..f49fa6386 100644 --- a/src/core/content_utility_client_qt.cpp +++ b/src/core/content_utility_client_qt.cpp @@ -42,19 +42,20 @@ #include "content/public/utility/utility_thread.h" #include "services/proxy_resolver/proxy_resolver_service.h" -ContentUtilityClientQt::ContentUtilityClientQt() { +namespace QtWebEngineCore { + +ContentUtilityClientQt::ContentUtilityClientQt() +{ } ContentUtilityClientQt::~ContentUtilityClientQt() = default; - -void ContentUtilityClientQt::RegisterServices( - ContentUtilityClient::StaticServiceMap* services) { - service_manager::EmbeddedServiceInfo proxy_resolver_info; - proxy_resolver_info.task_runner = - content::ChildThread::Get()->GetIOTaskRunner(); - proxy_resolver_info.factory = - base::Bind(&proxy_resolver::ProxyResolverService::CreateService); - services->emplace(proxy_resolver::mojom::kProxyResolverServiceName, - proxy_resolver_info); +void ContentUtilityClientQt::RegisterServices(ContentUtilityClient::StaticServiceMap *services) +{ + service_manager::EmbeddedServiceInfo proxy_resolver_info; + proxy_resolver_info.task_runner = content::ChildThread::Get()->GetIOTaskRunner(); + proxy_resolver_info.factory = base::BindRepeating(&proxy_resolver::ProxyResolverService::CreateService); + services->emplace(proxy_resolver::mojom::kProxyResolverServiceName, proxy_resolver_info); } + +} // namespace diff --git a/src/core/content_utility_client_qt.h b/src/core/content_utility_client_qt.h index df1eb5557..3fb7c97d5 100644 --- a/src/core/content_utility_client_qt.h +++ b/src/core/content_utility_client_qt.h @@ -39,18 +39,23 @@ #ifndef CONTENT_UTILITY_CLIENT_QT_H #define CONTENT_UTILITY_CLIENT_QT_H + #include "content/public/utility/content_utility_client.h" class MashServiceFactory; class UtilityMessageHandler; +namespace QtWebEngineCore { + class ContentUtilityClientQt : public content::ContentUtilityClient { - public: - ContentUtilityClientQt(); - ~ContentUtilityClientQt() override; +public: + ContentUtilityClientQt(); + ~ContentUtilityClientQt() override; - // content::ContentUtilityClient: - void RegisterServices(StaticServiceMap* services) override; + // content::ContentUtilityClient: + void RegisterServices(StaticServiceMap *services) override; }; +} // namespace + #endif -- cgit v1.2.3 From 0f551f6ea9bbc14822e116800160789b746d5dd2 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 21 Nov 2018 12:22:42 +0100 Subject: Init the idle monitor on macOS As the only platform macOS needs it initialized manually Change-Id: I922aea7e9f19abac6c1b46822d48646d68784014 Reviewed-by: Alexandru Croitor --- src/core/browser_main_parts_qt.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/browser_main_parts_qt.cpp b/src/core/browser_main_parts_qt.cpp index 38e048470..dbd123586 100644 --- a/src/core/browser_main_parts_qt.cpp +++ b/src/core/browser_main_parts_qt.cpp @@ -60,6 +60,10 @@ #include #include +#if defined(OS_MACOSX) +#include "ui/base/idle/idle.h" +#endif + #if defined(Q_OS_WIN) #include "ui/display/win/screen_win.h" #else @@ -208,6 +212,11 @@ void BrowserMainPartsQt::PostMainMessageLoopRun() int BrowserMainPartsQt::PreCreateThreads() { base::ThreadRestrictions::SetIOAllowed(true); + +#if defined(OS_MACOSX) + ui::InitIdleMonitor(); +#endif + // Like ChromeBrowserMainExtraPartsViews::PreCreateThreads does. #if defined(Q_OS_WIN) display::Screen::SetScreenInstance(new display::win::ScreenWin); -- cgit v1.2.3 From a5b82567f8f29885aa62044b920ab669f3726047 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Wed, 14 Nov 2018 11:53:57 +0100 Subject: Remove bogus line from configure.json Change-Id: I83a7a38d574b353e7748a71d83183b75f6dc7c1a Reviewed-by: Allan Sandfeld Jensen --- src/core/configure.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/configure.json b/src/core/configure.json index 3aba2d55a..f49bf08d1 100644 --- a/src/core/configure.json +++ b/src/core/configure.json @@ -658,7 +658,6 @@ "webengine-win-compiler64": { "label": "64bit compiler", "condition": "config.win32 && tests.webengine-win-compiler64", - "type": "isWindowsHostCompiler64", "output": [ "privateFeature" ] } }, -- cgit v1.2.3 From c0ac4d0673a25d52ad7d315b6e96f75bbe8be14c Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Tue, 13 Nov 2018 15:15:25 +0100 Subject: Fix running thumb vs arm instruction set on yocto On yocto CC/CXX export contains flags like -marm, -mthumb see https://lists.yoctoproject.org/pipermail/poky/2018-September/011497.html Fix builds for webengine and check also QMAKE_CC for flags, otherwise build ends up passing -marm and -mthumb flags at the same time. Change-Id: I76feb0eaf3bed8a6c3552db1bbf1a0809f03110a Reviewed-by: Allan Sandfeld Jensen --- mkspecs/features/functions.prf | 4 +++- src/core/config/linux.pri | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mkspecs/features/functions.prf b/mkspecs/features/functions.prf index c9bd65b03..f433de3b2 100644 --- a/mkspecs/features/functions.prf +++ b/mkspecs/features/functions.prf @@ -14,7 +14,9 @@ defineReplace(extractCFlag) { CFLAGS = $$QMAKE_CC $$QMAKE_CFLAGS OPTION = $$find(CFLAGS, $$1) OPTION = $$split(OPTION, =) - return ($$member(OPTION, 1)) + PARAM = $$member(OPTION, 1) + !isEmpty(PARAM): return ($$PARAM) + return ($$OPTION) } defineReplace(which) { diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri index ed7745b89..0eea066e4 100644 --- a/src/core/config/linux.pri +++ b/src/core/config/linux.pri @@ -83,8 +83,10 @@ contains(QT_ARCH, "arm") { } } - if(isEmpty(MARMV)|lessThan(MARMV, 7)):contains(QMAKE_CFLAGS, "-marm"): gn_args += arm_use_thumb=false - else: contains(QMAKE_CFLAGS, "-mthumb"): gn_args += arm_use_thumb=true + MTHUMB = $$extractCFlag("-mthumb") + MARM = $$extractCFlag("-marm") + if (isEmpty(MARMV) | lessThan(MARMV, 7) | !isEmpty(MARM)): gn_args += arm_use_thumb=false + else: !isEmpty(MTHUMB): gn_args += arm_use_thumb=true } contains(QT_ARCH, "mips") { -- cgit v1.2.3 From 55181670c621dfd79d0bb05738cb5b59665e6bd7 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Tue, 13 Nov 2018 18:50:01 +0100 Subject: Add check for thumb instruction set We currently require thumb instruction set on arm to build internal ffmpeg. Task-number: QTBUG-71772 Change-Id: I43ed152a51f0dea97b800c868eb13a4e5e8e077e Reviewed-by: Allan Sandfeld Jensen --- configure.pri | 18 ++++++++++++++++++ src/core/config/linux.pri | 15 +++++++++++---- src/core/configure.json | 14 ++++++++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/configure.pri b/configure.pri index 254755743..26c57ce61 100644 --- a/configure.pri +++ b/configure.pri @@ -294,3 +294,21 @@ defineTest(qtConfTest_isWindowsHostCompiler64) { qtLog("Required 64-bit cross-building or native toolchain was not detected.") return(false) } + +# Fixme QTBUG-71772 +defineTest(qtConfTest_hasThumbFlag) { + FLAG = $$extractCFlag("-mthumb") + !isEmpty(FLAG): return(true) + FLAG = $$extractCFlag("-marm") + !isEmpty(FLAG): return(false) + + MARCH = $$extractCFlag("-march=.*") + MARMV = $$replace(MARCH, "armv",) + !isEmpty(MARMV) { + MARMV = $$split(MARMV,) + MARMV = $$member(MARMV, 0) + } + if (isEmpty(MARMV) | lessThan(MARMV, 7)): return(false) + # no flag assume mthumb + return(true) +} diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri index 0eea066e4..752d2281f 100644 --- a/src/core/config/linux.pri +++ b/src/core/config/linux.pri @@ -69,6 +69,7 @@ contains(QT_ARCH, "arm") { gn_args += arm_version=$$MARMV } + # TODO: use neon detection from qtbase !lessThan(MARMV, 8) { gn_args += arm_use_neon=true } else { @@ -83,10 +84,16 @@ contains(QT_ARCH, "arm") { } } - MTHUMB = $$extractCFlag("-mthumb") - MARM = $$extractCFlag("-marm") - if (isEmpty(MARMV) | lessThan(MARMV, 7) | !isEmpty(MARM)): gn_args += arm_use_thumb=false - else: !isEmpty(MTHUMB): gn_args += arm_use_thumb=true + qtConfig(webengine-arm-thumb) { + gn_args += arm_use_thumb=true # this adds -mthumb + } else { + gn_args += arm_use_thumb=false + !qtConfig(webengine-system-ffmpeg) { + # Fixme QTBUG-71772 + gn_args += media_use_ffmpeg=false + gn_args += use_webaudio_ffmpeg=false + } + } } contains(QT_ARCH, "mips") { diff --git a/src/core/configure.json b/src/core/configure.json index f49bf08d1..e17605302 100644 --- a/src/core/configure.json +++ b/src/core/configure.json @@ -328,6 +328,10 @@ "webengine-win-compiler64": { "label": "64bit compiler", "type": "isWindowsHostCompiler64" + }, + "webengine-arm-thumb" : { + "label": "thumb instruction set", + "type": "hasThumbFlag" } }, @@ -659,6 +663,11 @@ "label": "64bit compiler", "condition": "config.win32 && tests.webengine-win-compiler64", "output": [ "privateFeature" ] + }, + "webengine-arm-thumb": { + "label": "Thumb instruction set", + "condition": "config.linux && features.webengine-embedded-build && arch.arm && tests.webengine-arm-thumb", + "output": [ "privateFeature" ] } }, @@ -697,6 +706,11 @@ "type": "warning", "condition": "config.win32 && !features.webengine-win-compiler64", "message": "64-bit cross-building or native toolchain is required to build QtWebEngine." + }, + { + "type": "warning", + "condition": "config.linux && features.webengine-embedded-build && !features.webengine-system-ffmpeg && arch.arm && !features.webengine-arm-thumb", + "message": "Thumb instruction set is required to build ffmpeg for QtWebEngine." } ], -- cgit v1.2.3 From 5fac32e6653e713f6e3e65e02e5c1b81df56c075 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 14 Nov 2018 17:45:13 +0100 Subject: Fix emulated touch events Touch events now does hit-testing based on surface, so we need to register outselves as a surface to have touch events do anything. Fixes: QTBUG-71801 Change-Id: Iafd43dfcecf029f9c11e0c0c58a349ff38badbaa Reviewed-by: Alexandru Croitor --- src/core/render_widget_host_view_qt.cpp | 9 ++++++++- src/core/render_widget_host_view_qt.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index bc41337d9..af7471759 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -54,6 +54,7 @@ #include "content/browser/frame_host/frame_tree.h" #include "content/browser/renderer_host/render_view_host_impl.h" #include "content/common/content_switches_internal.h" +#include "content/browser/renderer_host/render_widget_host_input_event_router.h" #include "content/common/cursors/webcursor.h" #include "content/common/input_messages.h" #include "third_party/skia/include/core/SkColor.h" @@ -274,6 +275,9 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget , m_wheelAckPending(false) , m_pendingResize(false) , m_mouseWheelPhaseHandler(this) + // This frame-sink id is based on what RenderWidgetHostViewChildFrame does: + , m_frameSinkId(base::checked_cast(widget->GetProcess()->GetID()), + base::checked_cast(widget->GetRoutingID())) { host()->SetView(this); #ifndef QT_NO_ACCESSIBILITY @@ -291,6 +295,9 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget m_imeHasHiddenTextCapability = context && context->hasCapability(QPlatformInputContext::HiddenTextCapability); m_localSurfaceId = m_localSurfaceIdAllocator.GenerateId(); + + if (host()->delegate() && host()->delegate()->GetInputEventRouter()) + host()->delegate()->GetInputEventRouter()->AddFrameSinkIdOwner(GetFrameSinkId(), this); } RenderWidgetHostViewQt::~RenderWidgetHostViewQt() @@ -1682,7 +1689,7 @@ viz::SurfaceId RenderWidgetHostViewQt::GetCurrentSurfaceId() const const viz::FrameSinkId &RenderWidgetHostViewQt::GetFrameSinkId() const { - return viz::FrameSinkIdAllocator::InvalidFrameSinkId(); + return m_frameSinkId; } const viz::LocalSurfaceId &RenderWidgetHostViewQt::GetLocalSurfaceId() const diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h index 6dd4d57e5..a12ffe636 100644 --- a/src/core/render_widget_host_view_qt.h +++ b/src/core/render_widget_host_view_qt.h @@ -268,6 +268,7 @@ private: bool m_pendingResize; QList m_pendingWheelEvents; content::MouseWheelPhaseHandler m_mouseWheelPhaseHandler; + viz::FrameSinkId m_frameSinkId; uint32_t m_latestCaptureSequenceNumber = 0u; std::string m_editCommand; -- cgit v1.2.3 From 44abfea789b8677a741530c44a0cd35e5276ddf3 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Mon, 19 Nov 2018 13:43:54 +0100 Subject: Fix IME with negative start position Change-Id: I64a39975788cc40c5e0595c1a0c5db9000889bfd Reviewed-by: Allan Sandfeld Jensen --- src/core/render_widget_host_view_qt.cpp | 11 ++---- .../widgets/qwebengineview/tst_qwebengineview.cpp | 42 ++++++++++++++++++++++ 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index af7471759..267460bdc 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -1316,14 +1316,9 @@ void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev) if (replacementLength > 0) { - int start = ev->replacementStart(); - - if (start >= 0) - replacementRange = gfx::Range(start, start + replacementLength); - else if (m_surroundingText.length() + start >= 0) { - start = m_surroundingText.length() + start; - replacementRange = gfx::Range(start, start + replacementLength); - } + int replacementStart = ev->replacementStart() < 0 ? m_cursorPosition + ev->replacementStart() : ev->replacementStart(); + if (replacementStart >= 0 && replacementStart < m_surroundingText.length()) + replacementRange = gfx::Range(replacementStart, replacementStart + replacementLength); } // There are so-far two known cases, when an empty QInputMethodEvent is received. diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index a0f8f11d2..a6487d19a 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -2292,6 +2292,48 @@ void tst_QWebEngineView::imeComposition() QTRY_COMPARE(view.focusProxy()->inputMethodQuery(Qt::ImAnchorPosition).toInt(), 15); QTRY_COMPARE(view.focusProxy()->inputMethodQuery(Qt::ImCurrentSelection).toString(), QString("")); QCOMPARE(selectionChangedSpy.count(), 2); + selectionChangedSpy.clear(); + + + // 5. Mimic behavior of QtVirtualKeyboard with enabled text prediction. + evaluateJavaScriptSync(view.page(), "document.getElementById('input1').value='QtWebEngine';"); + QTRY_COMPARE(evaluateJavaScriptSync(view.page(), "document.getElementById('input1').value").toString(), QString("QtWebEngine")); + + // Move cursor into position. + QTest::keyClick(view.focusProxy(), Qt::Key_Home); + for (int j = 0; j < 2; ++j) + QTest::keyClick(view.focusProxy(), Qt::Key_Right); + QTRY_COMPARE(view.focusProxy()->inputMethodQuery(Qt::ImCursorPosition).toInt(), 2); + + // Turn text into composition by using negative start position. + { + int replaceFrom = -1 * view.focusProxy()->inputMethodQuery(Qt::ImCursorPosition).toInt(); + int replaceLength = view.focusProxy()->inputMethodQuery(Qt::ImSurroundingText).toString().size(); + + QList attributes; + QInputMethodEvent event("QtWebEngine", attributes); + event.setCommitString(QString(), replaceFrom, replaceLength); + QApplication::sendEvent(view.focusProxy(), &event); + } + QTRY_COMPARE(view.focusProxy()->inputMethodQuery(Qt::ImSurroundingText).toString(), QString("")); + QCOMPARE(view.focusProxy()->inputMethodQuery(Qt::ImCursorPosition).toInt(), 11); + QCOMPARE(view.focusProxy()->inputMethodQuery(Qt::ImAnchorPosition).toInt(), 11); + QCOMPARE(view.focusProxy()->inputMethodQuery(Qt::ImCurrentSelection).toString(), QString("")); + QCOMPARE(evaluateJavaScriptSync(view.page(), "document.getElementById('input1').value").toString(), QString("QtWebEngine")); + + // Commit. + { + QList attributes; + QInputMethodEvent event(QString(), attributes); + event.setCommitString("QtWebEngine", 0, 0); + QApplication::sendEvent(view.focusProxy(), &event); + } + QTRY_COMPARE(view.focusProxy()->inputMethodQuery(Qt::ImSurroundingText).toString(), QString("QtWebEngine")); + QCOMPARE(view.focusProxy()->inputMethodQuery(Qt::ImCursorPosition).toInt(), 11); + QCOMPARE(view.focusProxy()->inputMethodQuery(Qt::ImAnchorPosition).toInt(), 11); + QCOMPARE(view.focusProxy()->inputMethodQuery(Qt::ImCurrentSelection).toString(), QString("")); + QCOMPARE(evaluateJavaScriptSync(view.page(), "document.getElementById('input1').value").toString(), QString("QtWebEngine")); + QCOMPARE(selectionChangedSpy.count(), 0); } void tst_QWebEngineView::newlineInTextarea() -- cgit v1.2.3 From bd34017fdd17a1044bd645c68386fda29ab77d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Mon, 26 Nov 2018 14:37:49 +0100 Subject: Fix use-after-free in URLRequestCustomJobProxy::reply The following operations are executing concurrently on the UI & IO threads: 1. UI thread executes QWebEngineUrlRequestJob::reply --> PostTask(IO, URLRequestCustomJobProxy::reply). IO thread executes URLRequestCustomJob::Kill --> PostTask(UI, URLRequestCustomJobProxy::release). 2. UI thread executes URLRequestCustomJobProxy::release, then deletes the QWebEngineUrlRequestJob and the QIODevice. IO thread executes URLRequestCustomJobProxy::reply and tries to use the QIODevice. Depending on scheduling, the IO thread will try to use the QIODevice after it has been deleted on the UI thread. Change-Id: I7a9793a7492a493e1787e7ee6d0058c0d1aa00ac Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Michal Klocek --- src/core/net/url_request_custom_job.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/net/url_request_custom_job.cpp b/src/core/net/url_request_custom_job.cpp index ecfa8e17a..d371c7bff 100644 --- a/src/core/net/url_request_custom_job.cpp +++ b/src/core/net/url_request_custom_job.cpp @@ -84,6 +84,7 @@ void URLRequestCustomJob::Start() void URLRequestCustomJob::Kill() { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); + m_proxy->m_job = nullptr; if (m_device && m_device->isOpen()) m_device->close(); if (m_pendingReadBuffer) { -- cgit v1.2.3 From ba816f1f5cd5ddb7f5cba32d0c9816bb439dffba Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 23 Nov 2018 13:26:50 +0100 Subject: Document client certificate feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id47a763642003f6056f1591e8ba7f82e255cd43e Reviewed-by: Leena Miettinen Reviewed-by: Michael BrĂ¼ning --- src/webengine/doc/src/qtwebengine-features.qdoc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/webengine/doc/src/qtwebengine-features.qdoc b/src/webengine/doc/src/qtwebengine-features.qdoc index 41d0581e5..1dce17e08 100644 --- a/src/webengine/doc/src/qtwebengine-features.qdoc +++ b/src/webengine/doc/src/qtwebengine-features.qdoc @@ -36,6 +36,7 @@ \list \li \l{Audio and Video Codecs} \li \l{Chromium DevTools} + \li \l{Client Certificates} \li \l{Drag and Drop} \li \l{Fullscreen} \li \l{HTML5 DRM} @@ -111,6 +112,23 @@ For more information, see \l {Qt WebEngine Debugging and Profiling}. + \section1 Client Certificates + + Some web servers, in particular many intranet sites, require the client to + authenticate itself with a certificate, called a \e {client certificate}. Qt WebEngine + will read the client certificates installed in the system settings in macOS and + Windows, and on Linux those installed into the NSS database. Certificates can + be installed into the NSS database using the \c pk12util tool. + + By default, QtWebEngine will not offer any client certificates to servers, as doing + so uniquely identifies the user and might violate privacy expectations. + + To activate support for client certificates, an application needs to listen to + the QWebEnginePage::selectClientCertificate signal and select one of the offered + certificates. For applications that can navigate to untrusted web sites, it is + recommended to always give the user a choice before uniquely identifying them + to a remote server. + \section1 Custom Schemes Qt WebEngine makes it possible for the application to define its own custom -- cgit v1.2.3