From f04389b65574a4ba97a69c5feb6004dcfb171ba7 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 7 Jan 2016 12:57:23 +0100 Subject: Avoid creating contents adapter when setting background color MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moves the initial setting of a non-default background color to initialization, so we don't need to force the creation of the contents adapter if a WebView component sets the background color. Change-Id: Iabd0146e6072653962877162d66da58154faf770 Reviewed-by: Michael BrĂ¼ning Reviewed-by: Jocelyn Turcotte (Woboq GmbH) --- src/webengine/api/qquickwebengineview.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 32800dd70..fd758bea2 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -707,6 +707,9 @@ void QQuickWebEngineViewPrivate::adoptWebContents(WebContentsAdapter *webContent // associate the webChannel with the new adapter if (qmlWebChannel) adapter->setWebChannel(qmlWebChannel); + // set initial background color if non-default + if (m_backgroundColor != Qt::white) + adapter->backgroundColorChanged(); // re-bind the userscrips to the new adapter Q_FOREACH (QQuickWebEngineScript *script, m_userScripts) @@ -747,6 +750,8 @@ void QQuickWebEngineViewPrivate::ensureContentsAdapter() if (!adapter) { adapter = new WebContentsAdapter(); adapter->initialize(this); + if (m_backgroundColor != Qt::white) + adapter->backgroundColorChanged(); if (explicitUrl.isValid()) adapter->load(explicitUrl); // push down the page's user scripts @@ -1063,8 +1068,8 @@ void QQuickWebEngineView::setBackgroundColor(const QColor &color) if (color == d->m_backgroundColor) return; d->m_backgroundColor = color; - d->ensureContentsAdapter(); - d->adapter->backgroundColorChanged(); + if (d->adapter) + d->adapter->backgroundColorChanged(); emit backgroundColorChanged(); } -- cgit v1.2.3