summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorKirill Burtsev <kirill.burtsev@qt.io>2020-07-31 16:02:36 +0200
committerKirill Burtsev <kirill.burtsev@qt.io>2020-08-31 10:05:07 +0200
commitd25075fb681fa92fad1f9bdcb262a3e361e7659e (patch)
treef68a40335197e0966bd850a4a8d2722922baa914 /src/core
parent5f1f7e8913b74f9a88864b4155db8753007db52c (diff)
Don't send duplicate load progress values
Suppress duplicated progress values coming from chromium. Verify this behavior reliably (and not only 0 and 100 value) by loading html with subresources with minor delay through test http server. Change-Id: Id034dda9012212d54d12fc95d5939ba301577c1c Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
Diffstat (limited to 'src/core')
-rw-r--r--src/core/web_contents_delegate_qt.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index f13621b99..7822d7a41 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -259,9 +259,12 @@ void WebContentsDelegateQt::LoadProgressChanged(double progress)
return;
if (m_lastLoadProgress < 0) // suppress signals that aren't between loadStarted and loadFinished
return;
- m_lastLoadProgress = qMax(m_lastLoadProgress, qRound(progress * 100)); // ensure monotonicity
- m_lastLoadProgress = qMin(m_lastLoadProgress, 100);
- m_viewClient->loadProgressChanged(m_lastLoadProgress);
+
+ int p = qMin(qRound(progress * 100), 100);
+ if (p > m_lastLoadProgress) { // ensure strict monotonic increase
+ m_lastLoadProgress = p;
+ m_viewClient->loadProgressChanged(p);
+ }
}
bool WebContentsDelegateQt::HandleKeyboardEvent(content::WebContents *, const content::NativeWebKeyboardEvent &event)
@@ -359,8 +362,9 @@ void WebContentsDelegateQt::EmitLoadFinished(bool success, const QUrl &url, bool
{
if (m_lastLoadProgress < 0) // not currently running
return;
+ if (m_lastLoadProgress < 100)
+ m_viewClient->loadProgressChanged(100);
m_lastLoadProgress = -1;
- m_viewClient->loadProgressChanged(100);
m_viewClient->loadFinished(success, url, isErrorPage, errorCode, errorDescription);
m_viewClient->updateNavigationActions();
}