From 9883dca4714c82079d390da18d1e3ff36f29b5a7 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 17 May 2017 16:56:30 +0200 Subject: [macOS] Use the OpenGL CoreProfile when the global shared context does Previously when a default QSurfaceFormat was set with an OpenGL Core profile, all the contexts created on the Qt side would obey the profile, but Chromium would still use the Compatibility profile for its contexts leading to warnings when trying to create shared contexts. The fix is to check which OpenGL profile is used in the Qt global shared context, and pass that information along to Chromium. Note that this works only on macOS for now, and the default non-Core profile is used on other platforms, even though Core was requested. Passing CoreProfile to Chromium on Windows and Linux currently leads to crashes. Task-number: QTBUG-60605 Change-Id: I27a77091923624d19ccc2019953a5b07f9282916 Reviewed-by: Peter Varga Reviewed-by: Kai Koehne --- src/core/web_engine_context.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 2748d2a0f..56dbb84b7 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -389,8 +389,22 @@ WebEngineContext::WebEngineContext() } } } else { - if (!qt_gl_global_share_context()->isOpenGLES()) + if (!qt_gl_global_share_context()->isOpenGLES()) { + // Default to Desktop non-Core profile OpenGL. glType = gl::kGLImplementationDesktopName; + + // Check if Core profile was requested and is supported. + QSurfaceFormat globalSharedFormat = qt_gl_global_share_context()->format(); + if (globalSharedFormat.profile() == QSurfaceFormat::CoreProfile) { +#ifdef Q_OS_MACOS + glType = gl::kGLImplementationCoreProfileName; +#else + qWarning("An OpenGL Core Profile was requested, but it is not supported " + "on the current platform. Falling back to a non-Core profile. " + "Note that this might cause rendering issues."); +#endif + } + } } } else { qWarning("WebEngineContext used before QtWebEngine::initialize() or OpenGL context creation failed."); -- cgit v1.2.1 From c2f786d59c8171c05cc7ff8c98b8a85175e5e5a2 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 7 Jul 2017 18:24:43 +0200 Subject: Fix "Could not share GL contexts" warnings on Windows Make sure that a non-Core Profile OpenGL Context is created on the Chromium side, so that sharing between the Qt global context and the Chromium ones works. Change-Id: Ifc5f39268395615fe50c8aa9467f833c0de233a8 Reviewed-by: Joerg Bornemann Reviewed-by: Kai Koehne Reviewed-by: Viktor Engelmann --- src/core/web_engine_context.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 56dbb84b7..9d993b7f4 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -332,6 +332,17 @@ WebEngineContext::WebEngineContext() parsedCommandLine->AppendSwitch(switches::kDisablePepper3DImageChromium); #endif +#if defined(Q_OS_WIN) + // This switch is used in Chromium's gl_context_wgl.cc file to determine whether to create + // an OpenGL Core Profile context. If the switch is not set, it would always try to create a + // Core Profile context, even if Qt uses a legacy profile, which causes + // "Could not share GL contexts" warnings, because it's not possible to share between Core and + // legacy profiles. + // Given that Core profile is not currently supported on Windows anyway, pass this switch to + // get rid of the warnings. + parsedCommandLine->AppendSwitch(switches::kDisableES3GLContext); +#endif + if (useEmbeddedSwitches) { // Inspired by the Android port's default switches if (!parsedCommandLine->HasSwitch(switches::kDisableOverlayScrollbar)) -- cgit v1.2.1 From ef09ea48c36e00dc2a03188936887caf95c2307e Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 19 Jun 2017 11:35:43 +0200 Subject: Take into account the value of the --touch-events Chromium switch In Chromium 56 the --touch-events switch controls both the availability of the Touch Events API in JavaScript (presence of 'ontouchstart' in 'window' object), and whether touch events are dispatched at all. In Chromium 57, the switch controls only the Touch Events API availability, and touch events are always dispatched. In Qt 5.9.0 which is based on Chromium 56, we always dispatched touch events, ignored the value of --touch-events, and determined the availability of the Touch Events API by checking if QTouchDevice lists any touch screen devices (essentially Chromium's --touch-events=auto option). This commit changes the behavior of WebEngine to match that of Chromium 57, so that users can choose to enable or disable the Touch Events API via the --touch-events switch, whereas the default will be 'auto' mode. Touch events will always be dispatched as usual. Users that wish to stop dispatching touch events can install an event filter on WebEngine's view focus proxy. Task-number: QTBUG-61045 Change-Id: I07404af3336619869aa87a90a1b426036548dd55 Reviewed-by: Leena Miettinen Reviewed-by: Kai Koehne --- src/core/web_engine_settings.cpp | 27 ++++++++++++++++++++++++- src/webengine/doc/src/qtwebengine-features.qdoc | 17 ++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index 58f0a3e2c..0079e02ba 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -48,6 +48,7 @@ #include "content/browser/gpu/gpu_process_host.h" #include "content/public/common/content_switches.h" #include "content/public/common/web_preferences.h" +#include "ui/events/event_switches.h" #include #include @@ -97,6 +98,29 @@ static inline bool isTouchScreenAvailable() { return touchScreenAvailable; } +static inline bool isTouchEventsAPIEnabled() { + static bool initialized = false; + static bool touchEventsAPIEnabled = false; + if (!initialized) { + base::CommandLine *parsedCommandLine = base::CommandLine::ForCurrentProcess(); + + // By default the Touch Events API support (presence of 'ontouchstart' in 'window' object) + // will be determined based on the availability of touch screen devices. + const std::string touchEventsSwitchValue = + parsedCommandLine->HasSwitch(switches::kTouchEvents) ? + parsedCommandLine->GetSwitchValueASCII(switches::kTouchEvents) : + switches::kTouchEventsAuto; + + if (touchEventsSwitchValue == switches::kTouchEventsEnabled) + touchEventsAPIEnabled = true; + else if (touchEventsSwitchValue == switches::kTouchEventsAuto) + touchEventsAPIEnabled = isTouchScreenAvailable(); + + initialized = true; + } + return touchEventsAPIEnabled; +} + WebEngineSettings::WebEngineSettings(WebEngineSettings *_parentSettings) : m_adapter(0) @@ -298,7 +322,8 @@ void WebEngineSettings::doApply() void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *prefs) { // Override for now - prefs->touch_enabled = isTouchScreenAvailable(); + prefs->touch_enabled = isTouchEventsAPIEnabled(); + prefs->device_supports_touch = isTouchScreenAvailable(); if (prefs->viewport_enabled) { // We should enable viewport and viewport-meta together, but since 5.7 we // no longer have a command-line flag for viewport-meta. diff --git a/src/webengine/doc/src/qtwebengine-features.qdoc b/src/webengine/doc/src/qtwebengine-features.qdoc index 11d3a4ca1..b80ad6a35 100644 --- a/src/webengine/doc/src/qtwebengine-features.qdoc +++ b/src/webengine/doc/src/qtwebengine-features.qdoc @@ -45,6 +45,7 @@ \li \l{Pepper Plugin API} \li \l{Print to PDF} \li \l{Spellchecker} + \li \l{Touch} \li \l{View Source} \li \l{WebRTC} \endlist @@ -312,6 +313,22 @@ Support for this feature was added in Qt 5.8.0. + \section1 Touch + + Qt WebEngine supports touch devices for navigating and interacting with web pages. + + Applications can prohibit the use of touch events in the following ways: + + \list + \li Passing the flag \c --touch-events=disabled on the command line will disable touch event + support in JavaScript API (meaning \c ontouchstart and related handlers will not be present + in the \c document.window object). Touch events will still be delivered to web pages. + + \li Installing an event filter object using \l {QObject::installEventFilter} on the WebEngine + view focus proxy object, and filtering out all touch events. + + \endlist + \section1 View Source Qt WebEngine supports viewing the HTML source of a web page. -- cgit v1.2.1 From de2e77720e522b91325e5ff9507b32b23b6c6700 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 29 Jun 2017 17:04:31 +0200 Subject: Document about popups not appearing on Windows when in fullscreen mode On Windows there is an issue that an OpenGL-backed fullscreen window will prevent other top-level windows from appearing on top of it (for example a select / combo box popup). This appears to be a limitation of the Windows platform compositor (DWM). The workaround is to call QWindowsWindowFunctions::setHasBorderInFullScreen on the QWindow which will show the fullscreen WebEngine view. Task-number: QTBUG-61563 Change-Id: I5e0f08ef49de6119ef7910cec2b32ea267301c18 Reviewed-by: Leena Miettinen --- src/webengine/doc/qtwebengine.qdocconf | 1 + src/webengine/doc/src/qtwebengine-platform-notes.qdoc | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'src') diff --git a/src/webengine/doc/qtwebengine.qdocconf b/src/webengine/doc/qtwebengine.qdocconf index ea9c6f21b..7b1bad4e6 100644 --- a/src/webengine/doc/qtwebengine.qdocconf +++ b/src/webengine/doc/qtwebengine.qdocconf @@ -42,6 +42,7 @@ depends += qtcore \ qtgui \ qtlocation \ qtnetwork \ + qtplatformheaders \ qtprintsupport \ qtpositioning \ qtqml \ diff --git a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc index ec678672c..068d395b6 100644 --- a/src/webengine/doc/src/qtwebengine-platform-notes.qdoc +++ b/src/webengine/doc/src/qtwebengine-platform-notes.qdoc @@ -182,4 +182,10 @@ It can be re-enabled by setting the \c QTWEBENGINE_ENABLE_LINUX_ACCESSIBILITY environment variable to a non-empty value. + \section1 Popups in Fullscreen Applications on Windows + Because of a limitation in the Windows compositor, applications that show a fullscreen web + engine view will not properly display popups or other top-level windows. The reason and + workaround for the issue can be found at \l {Fullscreen OpenGL Based Windows} and + \l {QWindowsWindowFunctions::setHasBorderInFullScreen}. + */ -- cgit v1.2.1 From 636b61fcf626e67fc34b3f16d857d8c089353095 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Thu, 13 Jul 2017 11:51:21 +0200 Subject: Update Chromium Pulls following changes: 1a14be1 Enable using gnu thin archives on Linux 296b240 Silence gcc -Waddress warnings in logging.h fabd7e0 Fix building without git installed 1173dda Do not export c memory handling functions 25ceaa6 Do not launch zygote processes in single-process mode 721a4d1 Carry over user-agent override when opening new windows Change-Id: If48223d76fbb35f1847e416a7f244e4b6ed85f33 Reviewed-by: Alexandru Croitor --- src/3rdparty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/3rdparty b/src/3rdparty index 53521384e..1a14be1c4 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit 53521384e3d0ab71727ae950c37951f7d3402ce3 +Subproject commit 1a14be1c45c61b3d4c65519ec203f2d039eb34c9 -- cgit v1.2.1 From 19e5c2057b9f127726018d3e39a62066317a983f Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 13 Jul 2017 14:37:18 +0200 Subject: Fix propagation of unhandled key press events Unhandled key presses for printable keys were not received by the parent widget anymore. This was a regression from 5.8.0. The propagation is suppressed if NativeWebKeyboardEvent::skip_in_browser is true. Commit 4501b9d8 accidentally removed the wrong skip_in_browser assignment. Task-number: QTBUG-61621 Change-Id: I7eafa1fac5fb9a7edc4af2bc1aac21c106264713 Reviewed-by: Peter Varga --- src/core/render_widget_host_view_qt.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 131f2a664..dd372b72f 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -1145,8 +1145,9 @@ void RenderWidgetHostViewQt::handleKeyEvent(QKeyEvent *ev) if (keyDownTextInsertion) { // Blink won't consume the RawKeyDown, but rather the Char event in this case. - // Make sure to skip the former on the way back. The same os_event will be set on both of them. - webEvent.skip_in_browser = true; + // The RawKeyDown is skipped on the way back (see above). + // The same os_event will be set on both NativeWebKeyboardEvents. + webEvent.skip_in_browser = false; webEvent.type = blink::WebInputEvent::Char; m_host->ForwardKeyboardEvent(webEvent); } -- cgit v1.2.1 From 57f1127b8e4663e420a34e5ab5d90ca4d3665925 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 17 Jul 2017 17:32:37 +0200 Subject: Support command-line argument --force-webrtc-ip-handling-policy This command-line argument makes it possibly to block exposure of internal IP addresses when WebRTC access hasn't been granted, using --force-webrtc-ip-handling-policy=default_public_interface_only Task-number: QTBUG-57505 Change-Id: I0cddd1b20e0814811894204cb31e0c463a75f7be Reviewed-by: Kai Koehne --- src/core/web_contents_adapter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 93e8674bd..a788b9679 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -73,6 +73,7 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/favicon_status.h" #include "content/public/common/content_constants.h" +#include "content/public/common/content_switches.h" #include #include "content/public/common/page_state.h" #include "content/public/common/page_zoom.h" @@ -419,6 +420,11 @@ void WebContentsAdapter::initialize(WebContentsAdapterClient *adapterClient) rendererPrefs->caret_blink_interval = 0.5 * static_cast(qtCursorFlashTime) / 1000; rendererPrefs->user_agent_override = d->browserContextAdapter->httpUserAgent().toStdString(); rendererPrefs->accept_languages = d->browserContextAdapter->httpAcceptLanguageWithoutQualities().toStdString(); +#if defined(ENABLE_WEBRTC) + base::CommandLine* commandLine = base::CommandLine::ForCurrentProcess(); + if (commandLine->HasSwitch(switches::kForceWebRtcIPHandlingPolicy)) + rendererPrefs->webrtc_ip_handling_policy = commandLine->GetSwitchValueASCII(switches::kForceWebRtcIPHandlingPolicy); +#endif d->webContents->GetRenderViewHost()->SyncRendererPrefs(); // Create and attach observers to the WebContents. -- cgit v1.2.1 From 009f5ebb4bd6e50188671e0815a5dae6afe39db5 Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Tue, 27 Jun 2017 12:29:17 +0200 Subject: Fix C-ABI breakage Re-export missing C memory handling functions. Task-number: QTBUG-61521 Change-Id: I8f94d93a70c81117735a9610e391a1e31c54f15a Reviewed-by: Allan Sandfeld Jensen --- src/core/api/core_api.pro | 4 +- src/core/api/qtbug-61521.cpp | 121 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 src/core/api/qtbug-61521.cpp (limited to 'src') diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro index d3d47e03a..05166536e 100644 --- a/src/core/api/core_api.pro +++ b/src/core/api/core_api.pro @@ -50,6 +50,8 @@ SOURCES = \ qwebengineurlrequestjob.cpp \ qwebengineurlschemehandler.cpp +### Qt6 Remove this workaround unix:!isEmpty(QMAKE_LFLAGS_VERSION_SCRIPT):!static { - SOURCES += qtbug-60565.cpp + SOURCES += qtbug-60565.cpp \ + qtbug-61521.cpp } diff --git a/src/core/api/qtbug-61521.cpp b/src/core/api/qtbug-61521.cpp new file mode 100644 index 000000000..86d5998ef --- /dev/null +++ b/src/core/api/qtbug-61521.cpp @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#define SHIM_ALIAS_SYMBOL(fn) __attribute__((weak, alias(#fn))) +#define SHIM_SYMBOL_VERSION(fn) __asm__(".symver __" #fn "," #fn "@Qt_5") +#define SHIM_HIDDEN __attribute__ ((visibility ("hidden"))) + +extern "C" { + +SHIM_SYMBOL_VERSION(malloc); +void* __malloc(size_t size) + SHIM_ALIAS_SYMBOL(ShimMalloc); + +SHIM_SYMBOL_VERSION(free); +void __free(void* ptr) + SHIM_ALIAS_SYMBOL(ShimFree); + +SHIM_SYMBOL_VERSION(realloc); +void* __realloc(void* ptr, size_t size) + SHIM_ALIAS_SYMBOL(ShimRealloc); + +SHIM_SYMBOL_VERSION(calloc); +void* __calloc(size_t n, size_t size) + SHIM_ALIAS_SYMBOL(ShimCalloc); + +SHIM_SYMBOL_VERSION(cfree); +void __cfree(void* ptr) + SHIM_ALIAS_SYMBOL(ShimCFree); + +SHIM_SYMBOL_VERSION(memalign); +void* __memalign(size_t align, size_t s) + SHIM_ALIAS_SYMBOL(ShimMemalign); + +SHIM_SYMBOL_VERSION(valloc); +void* __valloc(size_t size) + SHIM_ALIAS_SYMBOL(ShimValloc); + +SHIM_SYMBOL_VERSION(pvalloc); +void* __pvalloc(size_t size) + SHIM_ALIAS_SYMBOL(ShimPvalloc); + +SHIM_SYMBOL_VERSION(posix_memalign); +int __posix_memalign(void** r, size_t a, size_t s) + SHIM_ALIAS_SYMBOL(ShimPosixMemalign); + +SHIM_HIDDEN void* ShimMalloc(size_t size) { + return malloc(size); +} + +SHIM_HIDDEN void ShimFree(void* ptr) { + free(ptr); +} + +SHIM_HIDDEN void* ShimRealloc(void* ptr, size_t size) { + return realloc(ptr,size); +} + +SHIM_HIDDEN void* ShimCalloc(size_t n, size_t size) { + return calloc(n,size); +} + +SHIM_HIDDEN void ShimCFree(void* ptr) { + cfree(ptr); +} + +SHIM_HIDDEN void* ShimMemalign(size_t align, size_t s) { + return memalign(align,s); +} + +SHIM_HIDDEN void* ShimValloc(size_t size) { + return valloc(size); +} + +SHIM_HIDDEN void* ShimPvalloc(size_t size) { + return pvalloc(size); +} + +SHIM_HIDDEN int ShimPosixMemalign(void** r, size_t a, size_t s) { + return posix_memalign(r,a,s); +} +} // extern "C" -- cgit v1.2.1 From 74f5f945ba62c839977420397fc307fe1edacbc5 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 19 Jul 2017 12:21:58 +0200 Subject: Doc: Align QtWebEngineWidgets overview with the one for the QtWebEngine module Change-Id: If4db465b9764be80df7fe953be63fc1a40b60d75 Reviewed-by: Leena Miettinen --- src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc b/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc index 959f96b10..3da554a81 100644 --- a/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc +++ b/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc @@ -28,8 +28,7 @@ /*! \module QtWebEngineWidgets \title Qt WebEngine Widgets C++ Classes - \brief Provides a web browser engine as well as C++ classes to render and - interact with web content + \brief Provides C++ classes for rendering web content in a QWidget based application \ingroup modules \ingroup qtwebengine-modules \qtvariable webenginewidgets -- cgit v1.2.1 From b5c8c48a87a19618b23d6d4fc5035915a9322117 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 20 Jul 2017 16:14:47 +0200 Subject: Fix logic to check for proxy settings The previous code tried to find out whether a user has set an application proxy by checking the type of the applicationProxy. This is wrong, because a system proxy will actually also change the applicationProxy type. Instead, we now rely on QNetworkProxyFactory::usesSystemConfiguration to decide whether to use QtNetwork's application proxy, or Chromium's logic for the system proxy. We also save the state of QNetworkProxy::useSystemConfiguration to be able to track changes. [ChangeLog][Networking] Fixed an issue where system proxy settings were not picked up correctly. Task-number: QTBUG-61910 Change-Id: I1d9af3f6006ba187266fe50c645f425a46632e41 Reviewed-by: Peter Varga --- src/core/proxy_config_service_qt.cpp | 92 +++++++++++++++++++++++------------- src/core/proxy_config_service_qt.h | 6 ++- 2 files changed, 63 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/core/proxy_config_service_qt.cpp b/src/core/proxy_config_service_qt.cpp index b7ed83624..491131e42 100644 --- a/src/core/proxy_config_service_qt.cpp +++ b/src/core/proxy_config_service_qt.cpp @@ -36,6 +36,9 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + + +//================ Based on ChromeProxyConfigService ======================= // Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -67,11 +70,10 @@ net::ProxyServer ProxyConfigServiceQt::fromQNetworkProxy(const QNetworkProxy &qt return net::ProxyServer(proxyScheme, net::HostPortPair(qtProxy.hostName().toStdString(), qtProxy.port())); } -//================ Based on ChromeProxyConfigService ======================= - ProxyConfigServiceQt::ProxyConfigServiceQt(std::unique_ptr baseService) : m_baseService(baseService.release()), - m_registeredObserver(false) + m_registeredObserver(false), + m_usesSystemConfiguration(false) { } @@ -83,7 +85,6 @@ ProxyConfigServiceQt::~ProxyConfigServiceQt() void ProxyConfigServiceQt::AddObserver(net::ProxyConfigService::Observer *observer) { - RegisterObserver(); m_observers.AddObserver(observer); } @@ -94,28 +95,31 @@ void ProxyConfigServiceQt::RemoveObserver(net::ProxyConfigService::Observer *obs net::ProxyConfigService::ConfigAvailability ProxyConfigServiceQt::GetLatestProxyConfig(net::ProxyConfig *config) { - RegisterObserver(); - - // Ask the base service if available. - net::ProxyConfig systemConfig; - ConfigAvailability systemAvailability = net::ProxyConfigService::CONFIG_UNSET; - if (m_baseService.get()) - systemAvailability = m_baseService->GetLatestProxyConfig(&systemConfig); +#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) + m_usesSystemConfiguration = QNetworkProxyFactory::usesSystemConfiguration(); +#endif + if (m_usesSystemConfiguration) { + // Use Chromium's base service to retrieve system settings + net::ProxyConfig systemConfig; + ConfigAvailability systemAvailability = net::ProxyConfigService::CONFIG_UNSET; + if (m_baseService.get()) + systemAvailability = m_baseService->GetLatestProxyConfig(&systemConfig); + *config = systemConfig; + // make sure to get updates via OnProxyConfigChanged + RegisterObserver(); + return systemAvailability; + } + // Use QNetworkProxy::applicationProxy settings const QNetworkProxy &qtProxy = QNetworkProxy::applicationProxy(); if (qtProxy == m_qtApplicationProxy && !m_qtProxyConfig.proxy_rules().empty()) { + // no changes *config = m_qtProxyConfig; return CONFIG_VALID; } + m_qtApplicationProxy = qtProxy; m_qtProxyConfig = net::ProxyConfig(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) - if (qtProxy.type() == QNetworkProxy::NoProxy - && QNetworkProxyFactory::usesSystemConfiguration()) { - *config = systemConfig; - return systemAvailability; - } -#endif net::ProxyConfig::ProxyRules qtRules; net::ProxyServer server = fromQNetworkProxy(qtProxy); @@ -145,31 +149,51 @@ net::ProxyConfigService::ConfigAvailability ProxyConfigServiceQt::GetLatestProxy void ProxyConfigServiceQt::OnLazyPoll() { - if (m_qtApplicationProxy != QNetworkProxy::applicationProxy()) { - net::ProxyConfig unusedConfig; - OnProxyConfigChanged(unusedConfig, CONFIG_VALID); + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + +#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) + // We need to update if + // - setUseSystemConfiguration() was called in between + // - user changed application proxy + if (m_usesSystemConfiguration != QNetworkProxyFactory::usesSystemConfiguration() + || (!m_usesSystemConfiguration && m_qtApplicationProxy != QNetworkProxy::applicationProxy())) { + Update(); + } else if (m_usesSystemConfiguration) { + if (m_baseService.get()) + m_baseService->OnLazyPoll(); } - if (m_baseService.get()) - m_baseService->OnLazyPoll(); +#else + if (m_qtApplicationProxy != QNetworkProxy::applicationProxy()) + Update(); +#endif } - +// Called when the base service changed void ProxyConfigServiceQt::OnProxyConfigChanged(const net::ProxyConfig &config, ConfigAvailability availability) { - Q_UNUSED(config); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + Q_UNUSED(config); - if (m_qtApplicationProxy != QNetworkProxy::applicationProxy() - || m_qtApplicationProxy.type() == QNetworkProxy::NoProxy) { - net::ProxyConfig actual_config; - availability = GetLatestProxyConfig(&actual_config); - if (availability == CONFIG_PENDING) - return; - for (net::ProxyConfigService::Observer &observer: m_observers) - observer.OnProxyConfigChanged(actual_config, availability); - } + if (!m_usesSystemConfiguration) + return; + + Update(); +} + +// Update our observers +void ProxyConfigServiceQt::Update() +{ + net::ProxyConfig actual_config; + ConfigAvailability availability = GetLatestProxyConfig(&actual_config); + if (availability == CONFIG_PENDING) + return; + for (net::ProxyConfigService::Observer &observer: m_observers) + observer.OnProxyConfigChanged(actual_config, availability); } +// Register ourselves as observer of the base service. +// This has to be done on the IO thread, and therefore cannot be done +// in the constructor. void ProxyConfigServiceQt::RegisterObserver() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); diff --git a/src/core/proxy_config_service_qt.h b/src/core/proxy_config_service_qt.h index f2f9a2210..7be3289d0 100644 --- a/src/core/proxy_config_service_qt.h +++ b/src/core/proxy_config_service_qt.h @@ -69,13 +69,17 @@ private: void OnProxyConfigChanged(const net::ProxyConfig& config, ConfigAvailability availability) override; + // Retrieve new proxy settings and notify observers. + void Update(); + // Makes sure that the observer registration with the base service is set up. void RegisterObserver(); std::unique_ptr m_baseService; base::ObserverList m_observers; - // Keep the last QNetworkProxy::applicationProxy state around. + // Keep the last state around. + bool m_usesSystemConfiguration; QNetworkProxy m_qtApplicationProxy; net::ProxyConfig m_qtProxyConfig; -- cgit v1.2.1 From 656d3a7b7d0596d82c753a60b4e69917567b666e Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 21 Jul 2017 16:05:46 +0200 Subject: Avoid default handler in switch Change-Id: I4533e28a2c1a338abdb1d373a0a3bfe598a5edce Reviewed-by: Peter Varga --- src/core/proxy_config_service_qt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/core/proxy_config_service_qt.cpp b/src/core/proxy_config_service_qt.cpp index 491131e42..32f02f425 100644 --- a/src/core/proxy_config_service_qt.cpp +++ b/src/core/proxy_config_service_qt.cpp @@ -63,7 +63,7 @@ net::ProxyServer ProxyConfigServiceQt::fromQNetworkProxy(const QNetworkProxy &qt proxyScheme = net::ProxyServer::SCHEME_HTTP; break; case QNetworkProxy::NoProxy: - default: + case QNetworkProxy::DefaultProxy: proxyScheme = net::ProxyServer::SCHEME_DIRECT; break; } -- cgit v1.2.1 From 4b5029e208affc15cde07006ea91d4a28c243a57 Mon Sep 17 00:00:00 2001 From: Leena Miettinen Date: Thu, 27 Jul 2017 08:58:30 +0200 Subject: Doc: Add example code for using Greasemonkey attributes in scripts Task-number: QTBUG-61788 Change-Id: Ie6c29f3999ea795a37ea444f56e40ddc70ca1c03 Reviewed-by: Kai Koehne --- src/webengine/doc/src/external-resources.qdoc | 10 ++++++++++ src/webengine/doc/src/qtwebengine-overview.qdoc | 25 +++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/webengine/doc/src/external-resources.qdoc b/src/webengine/doc/src/external-resources.qdoc index a75c7aaed..6cced588c 100644 --- a/src/webengine/doc/src/external-resources.qdoc +++ b/src/webengine/doc/src/external-resources.qdoc @@ -136,3 +136,13 @@ \externalpage https://http2.akamai.com/demo \title Akamai HTTP/2 Demo */ + +/*! + \externalpage https://www.chromium.org/developers/design-documents/user-scripts + \title User Scripts +*/ + +/*! + \externalpage https://wiki.greasespot.net/Metadata_Block#.40name + \title Metadata Block +*/ diff --git a/src/webengine/doc/src/qtwebengine-overview.qdoc b/src/webengine/doc/src/qtwebengine-overview.qdoc index e180b22c0..e9ca573b7 100644 --- a/src/webengine/doc/src/qtwebengine-overview.qdoc +++ b/src/webengine/doc/src/qtwebengine-overview.qdoc @@ -181,8 +181,29 @@ script to run, the injection point, and the world where the script is run. This enables accessing the DOM to manipulate it within a world. - The following \l Greasemonkey attributes are supported since Qt 5.8: - \c @exclude, \c @include, \c @name, \c @match, and \c @run-at. + Since Qt 5.8, Qt WebEngine supports augmenting a script by using the + following \l{Metadata Block}{Greasemonkey-like attributes}: + + \list + \li \c {@exclude } + \li \c {@include } + \li \c {@match } + \li \c {@name } + \li \c {@run-at [document-start|document-end|document-idle]} + \endlist + + The attributes determine if and when a \l {User Scripts}{user script} is + run. They must be placed immediately in the beginning of the script, inside + a \c ==UserScript== comment: + + \code + // ==UserScript== + // @include http://*.qt.io/* + // @exclude http://wiki.qt.io/* + // ==/UserScript== + + window.alert("Page is from qt.io, but not wiki.qt.io"); + \endcode \section1 Managing Certificates -- cgit v1.2.1 From 4250e432fd8bd197548e119d66259cd5e9ecaf88 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 31 Jul 2017 10:34:24 +0200 Subject: Fix typo in dictionary path Change-Id: I398f88943e6f59781ad9227e2888cb25079b638c Reviewed-by: Kai Koehne --- src/webengine/doc/src/qtwebengine-features.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/webengine/doc/src/qtwebengine-features.qdoc b/src/webengine/doc/src/qtwebengine-features.qdoc index b80ad6a35..30d21f2ae 100644 --- a/src/webengine/doc/src/qtwebengine-features.qdoc +++ b/src/webengine/doc/src/qtwebengine-features.qdoc @@ -296,7 +296,7 @@ When the Qt WebEngine spellchecker initializes, it will try to load the \c bdict dictionaries and to check them for consistency. First, it searches \e qtwebengine_dictionaries directories relative to the executable, - then it will look in \c QT_INSTALL_PREFIX/qtwebengines_dictionaries. + then it will look in \c QT_INSTALL_PREFIX/qtwebengine_dictionaries. Spellchecking is disabled by default and can be enabled per profile by using the QWebEngineProfile::setSpellCheckEnabled() method in widget-based -- cgit v1.2.1 From 905160596f03a4313620e5c68db5dd51d5da0f73 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Fri, 28 Jul 2017 15:08:47 +0200 Subject: Fix reorder warning in proxy_config_service_qt.cpp Task-number: QTBUG-61910 Change-Id: I894d1f180ba9952213b6f67a2445aa927dfd7e9b Reviewed-by: Kai Koehne --- src/core/proxy_config_service_qt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/core/proxy_config_service_qt.cpp b/src/core/proxy_config_service_qt.cpp index 32f02f425..48f3593e6 100644 --- a/src/core/proxy_config_service_qt.cpp +++ b/src/core/proxy_config_service_qt.cpp @@ -72,8 +72,8 @@ net::ProxyServer ProxyConfigServiceQt::fromQNetworkProxy(const QNetworkProxy &qt ProxyConfigServiceQt::ProxyConfigServiceQt(std::unique_ptr baseService) : m_baseService(baseService.release()), - m_registeredObserver(false), - m_usesSystemConfiguration(false) + m_usesSystemConfiguration(false), + m_registeredObserver(false) { } -- cgit v1.2.1 From b238f224a7827de182e8ac77ffac31d9ae25ce57 Mon Sep 17 00:00:00 2001 From: Leena Miettinen Date: Thu, 3 Aug 2017 16:10:40 +0200 Subject: Doc: List some command-line arguments that are useful during debugging Task-number: QTBUG-61796 Change-Id: I76d3fec780796dd0f300c54a1bccecc50f7270e0 Reviewed-by: Allan Sandfeld Jensen --- src/webengine/doc/src/qtwebengine-debugging.qdoc | 33 +++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/webengine/doc/src/qtwebengine-debugging.qdoc b/src/webengine/doc/src/qtwebengine-debugging.qdoc index e929fabeb..5ff1c6342 100644 --- a/src/webengine/doc/src/qtwebengine-debugging.qdoc +++ b/src/webengine/doc/src/qtwebengine-debugging.qdoc @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. @@ -71,4 +71,35 @@ For a detailed explanation of the capabilities of developer tools, see the \l {Chrome DevTools} page. + + \section1 Using Command-Line Arguments + + You can use the following command-line arguments while debugging to provide + input for bug reports: + + \list + \li \c {--disable-gpu} disables GPU hardware acceleration. This is + useful when diagnosing OpenGL problems. + \li \c {--disable-logging} disables console logging, which might be + useful for debug builds. + \li \c {--enable-logging --log-level=0} enables console logging and sets + the logging level to 0, which means that messages of the severity + \c info and above are recorded in the log. This is the default for + debug builds. Other possible log levels are \c 1 for warnings, \c 2 + for errors, and \c 3 for fatal errors. + \li \c {--no-sandbox} disables the sandbox for the renderer and plugin + processes. Keep in mind that disabling the sandbox might present a + security risk. + \li \c {--single-process} runs the renderer and plugins in the same + process as the browser. This is useful for getting stack traces for + renderer crashes. + \endlist + + Alternatively, the environment variable QTWEBENGINE_CHROMIUM_FLAGS can be + set. For example, the following value could be set to disable logging while + debugging an application called \e mybrowser: + + \code + QTWEBENGINE_CHROMIUM_FLAGS="--disable-logging" mybrowser + \endcode */ -- cgit v1.2.1 From 59e35e033b8c8327db5b3fdbfb5d6ecee48a4405 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 3 Aug 2017 10:40:38 +0200 Subject: Set web contents font setting to default Chromium has since version 50 overridden the global font settings with the settings of every web contents created, so we need to first set the global settings in the web contents, to still follow system defaults. Task-number: QTBUG-62146 Change-Id: If10847c81beda08ecb7bfdf7556e39b1d2989754 Reviewed-by: Joerg Bornemann --- src/core/web_contents_adapter.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index a788b9679..8273b247f 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -83,6 +83,7 @@ #include "content/public/common/web_preferences.h" #include "third_party/WebKit/public/web/WebFindOptions.h" #include "printing/features/features.h" +#include "ui/gfx/font_render_params.h" #include #include @@ -425,6 +426,15 @@ void WebContentsAdapter::initialize(WebContentsAdapterClient *adapterClient) if (commandLine->HasSwitch(switches::kForceWebRtcIPHandlingPolicy)) rendererPrefs->webrtc_ip_handling_policy = commandLine->GetSwitchValueASCII(switches::kForceWebRtcIPHandlingPolicy); #endif + // Set web-contents font settings to the default font settings as Chromium constantly overrides + // the global font defaults with the font settings of the latest web-contents created. + CR_DEFINE_STATIC_LOCAL(const gfx::FontRenderParams, params, (gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), NULL))); + rendererPrefs->should_antialias_text = params.antialiasing; + rendererPrefs->use_subpixel_positioning = params.subpixel_positioning; + rendererPrefs->hinting = params.hinting; + rendererPrefs->use_autohinter = params.autohinter; + rendererPrefs->use_bitmaps = params.use_bitmaps; + rendererPrefs->subpixel_rendering = params.subpixel_rendering; d->webContents->GetRenderViewHost()->SyncRendererPrefs(); // Create and attach observers to the WebContents. -- cgit v1.2.1