summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorMichael BrĂ¼ning <michael.bruning@qt.io>2018-12-14 13:15:31 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-12-18 15:58:19 +0100
commit50fac0d1d7e82f2423e0a3e557b4a1f30be5bf33 (patch)
treeb085f03fdafa4ecbcfcb5a96b68404e155879b6a /src/core
parent8124f0bc1893e0997989913044665fa1c5cf79d7 (diff)
parent4f1e0003d98116e33a847360e0e95c46daae25fc (diff)
Merge remote-tracking branch 'origin/5.12' into dev
Conflicts: src/core/compositor/delegated_frame_node.cpp src/core/profile_adapter.cpp src/core/profile_io_data_qt.cpp src/webengine/api/qquickwebengineprofile.cpp src/webenginewidgets/api/qwebengineprofile.cpp Change-Id: I35ec8480e758bbcb6c5942a5401cb1b6dbdcc428
Diffstat (limited to 'src/core')
-rw-r--r--src/core/api/qwebengineurlscheme.cpp6
-rw-r--r--src/core/api/qwebengineurlschemehandler.cpp43
-rw-r--r--src/core/chromium_overrides.cpp5
-rw-r--r--src/core/compositor/delegated_frame_node.cpp19
-rw-r--r--src/core/config/linux.pri10
-rw-r--r--src/core/ozone/gl_context_qt.cpp5
-rw-r--r--src/core/profile_adapter.cpp5
-rw-r--r--src/core/profile_io_data_qt.cpp19
-rw-r--r--src/core/profile_io_data_qt.h3
-rw-r--r--src/core/render_widget_host_view_qt.cpp33
-rw-r--r--src/core/web_event_factory.cpp2
11 files changed, 122 insertions, 28 deletions
diff --git a/src/core/api/qwebengineurlscheme.cpp b/src/core/api/qwebengineurlscheme.cpp
index f36f3335b..d63599163 100644
--- a/src/core/api/qwebengineurlscheme.cpp
+++ b/src/core/api/qwebengineurlscheme.cpp
@@ -84,8 +84,10 @@ public:
URLs.
Custom URL schemes must be configured early at application startup, before
- creating any Qt WebEngine classes. The configuration applies globally to all
- profiles.
+ creating any Qt WebEngine classes. In general this means the schemes need to be configured before
+ a QGuiApplication or QApplication instance is created.
+
+ Every registered scheme configuration applies globally to all profiles.
\code
int main(int argc, char **argv)
diff --git a/src/core/api/qwebengineurlschemehandler.cpp b/src/core/api/qwebengineurlschemehandler.cpp
index 6ec5c25ec..2e93f4b73 100644
--- a/src/core/api/qwebengineurlschemehandler.cpp
+++ b/src/core/api/qwebengineurlschemehandler.cpp
@@ -48,12 +48,51 @@ QT_BEGIN_NAMESPACE
\brief The QWebEngineUrlSchemeHandler is a base class for handling custom URL schemes.
\since 5.6
- To implement a custom URL scheme for QtWebEngine, you must write a class derived from this class,
- and reimplement requestStarted(). Then install it via QWebEngineProfile::installUrlSchemeHandler()
+ To implement a custom URL scheme for QtWebEngine, you first have to create an instance of
+ QWebEngineUrlScheme and register it using QWebEngineUrlScheme::registerScheme().
+
+ \note Make sure that you create and register the scheme object \e before the QGuiApplication
+ or QApplication object is instantiated.
+
+ Then you must create a class derived from QWebEngineUrlSchemeHandler,
+ and reimplement the requestStarted() method.
+
+ Finally, install the scheme handler object via QWebEngineProfile::installUrlSchemeHandler()
or QQuickWebEngineProfile::installUrlSchemeHandler().
+ \code
+
+ class MySchemeHandler : public QWebEngineUrlSchemeHandler
+ {
+ public:
+ MySchemeHandler(QObject *parent = nullptr);
+ void requestStarted(QWebEngineUrlRequestJob *request)
+ {
+ // ....
+ }
+ };
+
+ int main(int argc, char **argv)
+ {
+ QWebEngineUrlScheme scheme("myscheme");
+ scheme.setSyntax(QWebEngineUrlScheme::Syntax::HostAndPort);
+ scheme.setDefaultPort(2345);
+ scheme.setFlags(QWebEngineUrlScheme::SecureScheme);
+ QWebEngineUrlScheme::registerScheme(scheme);
+
+ // ...
+ QApplication app(argc, argv);
+ // ...
+
+ // installUrlSchemeHandler does not take ownership of the handler.
+ MySchemeHandler *handler = new MySchemeHandler(parent);
+ QWebEngineProfile::defaultProfile()->installUrlSchemeHandler("myscheme", handler);
+ }
+ \endcode
+
\inmodule QtWebEngineCore
+ \sa {QWebEngineUrlScheme}, {WebEngine Widgets WebUI Example}
*/
/*!
diff --git a/src/core/chromium_overrides.cpp b/src/core/chromium_overrides.cpp
index a497ddc46..841dcf4c9 100644
--- a/src/core/chromium_overrides.cpp
+++ b/src/core/chromium_overrides.cpp
@@ -92,6 +92,11 @@ void GetScreenInfoFromNativeWindow(QWindow* window, content::ScreenInfo* results
} // namespace QtWebEngineCore
+void *GetQtXDisplay()
+{
+ return GLContextHelper::getXDisplay();
+}
+
namespace content {
class WebContentsImpl;
class WebContentsView;
diff --git a/src/core/compositor/delegated_frame_node.cpp b/src/core/compositor/delegated_frame_node.cpp
index c4a6d8078..e91a8728f 100644
--- a/src/core/compositor/delegated_frame_node.cpp
+++ b/src/core/compositor/delegated_frame_node.cpp
@@ -92,6 +92,10 @@
#define GL_TEXTURE_RECTANGLE 0x84F5
#endif
+#ifndef GL_NEAREST
+#define GL_NEAREST 0x2600
+#endif
+
#ifndef GL_LINEAR
#define GL_LINEAR 0x2601
#endif
@@ -986,7 +990,20 @@ inline auto &findTexture(Container &map, Container &previousMap, const Key &key)
QSGTexture *DelegatedFrameNode::initAndHoldTexture(const CompositorResource *resource, bool hasAlphaChannel, RenderWidgetHostViewQtDelegate *apiDelegate, int target)
{
- QSGTexture::Filtering filtering = resource->filter == GL_LINEAR ? QSGTexture::Linear : QSGTexture::Nearest;
+ QSGTexture::Filtering filtering;
+
+ if (resource->filter == GL_NEAREST)
+ filtering = QSGTexture::Nearest;
+ else if (resource->filter == GL_LINEAR)
+ filtering = QSGTexture::Linear;
+ else {
+ // Depends on qtdeclarative fix, see QTBUG-71322
+#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 1)
+ filtering = QSGTexture::Linear;
+#else
+ filtering = QSGTexture::Nearest;
+#endif
+ }
if (resource->is_software) {
QSharedPointer<QSGTexture> &texture =
diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri
index 752d2281f..85b948db2 100644
--- a/src/core/config/linux.pri
+++ b/src/core/config/linux.pri
@@ -24,10 +24,6 @@ qtConfig(webengine-embedded-build) {
!use_gold_linker: gn_args += use_gold=false
}
-qtConfig(webengine-system-x11): hasX11Dependencies() {
- gn_args += ozone_platform_x11=true
-}
-
clang {
clang_full_path = $$which($${QMAKE_CXX})
# Remove the "/bin/clang++" part.
@@ -171,7 +167,11 @@ host_build {
gn_args += use_alsa=false
}
!packagesExist(libpci): gn_args += use_libpci=false
- !packagesExist(xscrnsaver): gn_args += use_xscrnsaver=false
+
+ qtConfig(webengine-system-x11): hasX11Dependencies() {
+ gn_args += ozone_platform_x11=true
+ packagesExist(xscrnsaver): gn_args += use_xscrnsaver=true
+ }
qtConfig(webengine-system-libevent): gn_args += use_system_libevent=true
qtConfig(webengine-system-libwebp): gn_args += use_system_libwebp=true
diff --git a/src/core/ozone/gl_context_qt.cpp b/src/core/ozone/gl_context_qt.cpp
index 18181d310..7e913817e 100644
--- a/src/core/ozone/gl_context_qt.cpp
+++ b/src/core/ozone/gl_context_qt.cpp
@@ -130,8 +130,9 @@ void* GLContextHelper::getEGLDisplay()
void* GLContextHelper::getXDisplay()
{
- return qApp->platformNativeInterface()->nativeResourceForScreen(
- QByteArrayLiteral("display"), qApp->primaryScreen());
+ if (QGuiApplication::platformName() != QLatin1String("xcb"))
+ return nullptr;
+ return qApp->platformNativeInterface()->nativeResourceForScreen(QByteArrayLiteral("display"), qApp->primaryScreen());
}
void* GLContextHelper::getNativeDisplay()
diff --git a/src/core/profile_adapter.cpp b/src/core/profile_adapter.cpp
index 437423a4a..b080a4ced 100644
--- a/src/core/profile_adapter.cpp
+++ b/src/core/profile_adapter.cpp
@@ -44,6 +44,7 @@
#include "content/public/browser/browsing_data_remover.h"
#include "content/public/browser/download_manager.h"
+#include "api/qwebengineurlscheme.h"
#include "content_client_qt.h"
#include "download_manager_delegate_qt.h"
#include "net/url_request_context_getter_qt.h"
@@ -489,6 +490,10 @@ void ProfileAdapter::installUrlSchemeHandler(const QByteArray &scheme, QWebEngin
qWarning("URL scheme handler already installed for the scheme: %s", scheme.constData());
return;
}
+ if (QWebEngineUrlScheme::schemeByName(canonicalScheme) == QWebEngineUrlScheme())
+ qWarning("Please register the custom scheme '%s' via QWebEngineUrlScheme::registerScheme() "
+ "before installing the custom scheme handler.", scheme.constData());
+
m_customUrlSchemeHandlers.insert(canonicalScheme, handler);
updateCustomUrlSchemeHandlers();
}
diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp
index 4519bd8fb..a95607d09 100644
--- a/src/core/profile_io_data_qt.cpp
+++ b/src/core/profile_io_data_qt.cpp
@@ -59,6 +59,7 @@
#include "net/http/http_cache.h"
#include "net/http/http_server_properties_impl.h"
#include "net/http/http_network_session.h"
+#include "net/http/transport_security_persister.h"
#include "net/proxy_resolution/dhcp_pac_file_fetcher_factory.h"
#include "net/proxy_resolution/pac_file_fetcher_impl.h"
#include "net/proxy_resolution/proxy_config_service.h"
@@ -306,6 +307,7 @@ void ProfileIODataQt::generateStorage()
// we need to get rid of dangling pointer due to coming storage deletion
m_urlRequestContext->set_http_transaction_factory(0);
m_httpNetworkSession.reset();
+ m_transportSecurityPersister.reset();
}
m_storage.reset(new net::URLRequestContextStorage(m_urlRequestContext.get()));
@@ -338,8 +340,20 @@ void ProfileIODataQt::generateStorage()
m_networkDelegate.get()));
m_storage->set_ssl_config_service(std::make_unique<SSLConfigServiceQt>());
- m_storage->set_transport_security_state(std::unique_ptr<net::TransportSecurityState>(
- new net::TransportSecurityState()));
+ m_storage->set_transport_security_state(std::make_unique<net::TransportSecurityState>());
+
+ if (!m_dataPath.isEmpty()) {
+ scoped_refptr<base::SequencedTaskRunner> background_task_runner(
+ base::CreateSequencedTaskRunnerWithTraits(
+ {base::MayBlock(),
+ base::TaskPriority::BACKGROUND,
+ base::TaskShutdownBehavior::BLOCK_SHUTDOWN}));
+ m_transportSecurityPersister =
+ std::make_unique<net::TransportSecurityPersister>(
+ m_urlRequestContext->transport_security_state(),
+ toFilePath(m_dataPath),
+ background_task_runner);
+ };
if (!m_httpAuthPreferences)
m_httpAuthPreferences.reset(new net::HttpAuthPreferences());
@@ -618,6 +632,7 @@ void ProfileIODataQt::setFullConfiguration()
m_httpCacheMaxSize = m_profileAdapter->httpCacheMaxSize();
m_customUrlSchemes = m_profileAdapter->customUrlSchemes();
m_useForGlobalCertificateVerification = m_profileAdapter->isUsedForGlobalCertificateVerification();
+ m_dataPath = m_profileAdapter->dataPath();
}
void ProfileIODataQt::updateStorageSettings()
diff --git a/src/core/profile_io_data_qt.h b/src/core/profile_io_data_qt.h
index b7706f190..9291f7313 100644
--- a/src/core/profile_io_data_qt.h
+++ b/src/core/profile_io_data_qt.h
@@ -58,6 +58,7 @@ class ProxyConfigService;
class URLRequestContext;
class URLRequestContextStorage;
class URLRequestJobFactoryImpl;
+class TransportSecurityPersister;
}
namespace QtWebEngineCore {
@@ -116,6 +117,7 @@ private:
std::unique_ptr<net::DhcpPacFileFetcherFactory> m_dhcpPacFileFetcherFactory;
std::unique_ptr<net::HttpAuthPreferences> m_httpAuthPreferences;
std::unique_ptr<net::URLRequestJobFactory> m_jobFactory;
+ std::unique_ptr<net::TransportSecurityPersister> m_transportSecurityPersister;
base::WeakPtr<ProfileIODataQt> m_weakPtr;
scoped_refptr<CookieMonsterDelegateQt> m_cookieDelegate;
content::URLRequestInterceptorScopedVector m_requestInterceptors;
@@ -146,6 +148,7 @@ private:
bool m_useForGlobalCertificateVerification = false;
bool m_hasPageInterceptors = false;
base::WeakPtrFactory<ProfileIODataQt> m_weakPtrFactory; // this should be always the last member
+ QString m_dataPath;
DISALLOW_COPY_AND_ASSIGN(ProfileIODataQt);
};
} // namespace QtWebEngineCore
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index fc42d5bde..4bb41a303 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -747,25 +747,29 @@ void RenderWidgetHostViewQt::OnUpdateTextInputStateCalled(content::TextInputMana
Q_UNUSED(updated_view);
Q_UNUSED(did_update_state);
- ui::TextInputType type = getTextInputType();
- m_delegate->inputMethodStateChanged(type != ui::TEXT_INPUT_TYPE_NONE, type == ui::TEXT_INPUT_TYPE_PASSWORD);
- m_delegate->setInputMethodHints(toQtInputMethodHints(type));
-
const content::TextInputState *state = text_input_manager_->GetTextInputState();
- if (!state)
+ if (!state) {
+ m_delegate->inputMethodStateChanged(false /*editorVisible*/, false /*passwordInput*/);
+ m_delegate->setInputMethodHints(Qt::ImhNone);
return;
+ }
- // At this point it is unknown whether the text input state has been updated due to a text selection.
- // Keep the cursor position updated for cursor movements too.
- if (GetSelectedText().empty())
- m_cursorPosition = state->selection_start;
+ ui::TextInputType type = getTextInputType();
+ m_delegate->setInputMethodHints(toQtInputMethodHints(getTextInputType()) | Qt::ImhNoPredictiveText | Qt::ImhNoTextHandles | Qt::ImhNoEditMenu);
m_surroundingText = QString::fromStdString(state->value);
-
// Remove IME composition text from the surrounding text
if (state->composition_start != -1 && state->composition_end != -1)
m_surroundingText.remove(state->composition_start, state->composition_end - state->composition_start);
+ // In case of text selection, the update is expected in RenderWidgetHostViewQt::selectionChanged().
+ if (GetSelectedText().empty()) {
+ // At this point it is unknown whether the text input state has been updated due to a text selection.
+ // Keep the cursor position updated for cursor movements too.
+ m_cursorPosition = state->selection_start;
+ m_delegate->inputMethodStateChanged(type != ui::TEXT_INPUT_TYPE_NONE, type == ui::TEXT_INPUT_TYPE_PASSWORD);
+ }
+
if (m_imState & ImStateFlags::TextInputStateUpdated) {
m_imState = ImStateFlags::TextInputStateUpdated;
return;
@@ -822,9 +826,10 @@ void RenderWidgetHostViewQt::selectionChanged()
{
// Reset input manager state
m_imState = 0;
+ ui::TextInputType type = getTextInputType();
// Handle text selection out of an input field
- if (getTextInputType() == ui::TEXT_INPUT_TYPE_NONE) {
+ if (type == ui::TEXT_INPUT_TYPE_NONE) {
if (GetSelectedText().empty() && m_emptyPreviousSelection)
return;
@@ -844,12 +849,13 @@ void RenderWidgetHostViewQt::selectionChanged()
// if the selection is cleared because TextInputState changes before the TextSelection change.
Q_ASSERT(text_input_manager_->GetTextInputState());
m_cursorPosition = text_input_manager_->GetTextInputState()->selection_start;
+ m_delegate->inputMethodStateChanged(true /*editorVisible*/, type == ui::TEXT_INPUT_TYPE_PASSWORD);
m_anchorPositionWithinSelection = m_cursorPosition;
m_cursorPositionWithinSelection = m_cursorPosition;
if (!m_emptyPreviousSelection) {
- m_emptyPreviousSelection = GetSelectedText().empty();
+ m_emptyPreviousSelection = true;
m_adapterClient->selectionChanged();
}
@@ -884,6 +890,7 @@ void RenderWidgetHostViewQt::selectionChanged()
m_cursorPosition = newCursorPositionWithinSelection;
m_emptyPreviousSelection = selection->selected_text().empty();
+ m_delegate->inputMethodStateChanged(true /*editorVisible*/, type == ui::TEXT_INPUT_TYPE_PASSWORD);
m_adapterClient->selectionChanged();
}
@@ -1106,7 +1113,7 @@ QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query)
// TODO: Implement this
return QVariant(); // No limit.
case Qt::ImHints:
- return int(toQtInputMethodHints(getTextInputType()));
+ return int(toQtInputMethodHints(getTextInputType()) | Qt::ImhNoPredictiveText | Qt::ImhNoTextHandles | Qt::ImhNoEditMenu);
default:
return QVariant();
}
diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp
index a45f7048b..24c3a3e64 100644
--- a/src/core/web_event_factory.cpp
+++ b/src/core/web_event_factory.cpp
@@ -101,7 +101,7 @@ static KeyboardDriver keyboardDriverImpl()
if (platformName == QLatin1Literal("xcb") || platformName == QLatin1Literal("wayland"))
return KeyboardDriver::Xkb;
-#if QT_CONFIG(libinput) && QT_CONFIG(xkbcommon_evdev)
+#if QT_CONFIG(libinput)
// Based on QEglFSIntegration::createInputHandlers and QLibInputKeyboard::processKey.
if (platformName == QLatin1Literal("eglfs") && !qEnvironmentVariableIntValue("QT_QPA_EGLFS_NO_LIBINPUT"))
return KeyboardDriver::Xkb;