From f06cb10ce5a6d543d97bd05484179f56b60e6e5a Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Fri, 14 Mar 2014 18:28:33 +0100 Subject: Base load signals on Blink loader events This mainly remove the use of the LoadingStateChanged callback, which is tied to DidStartLoading and DidStopLoading. Those signals are handled from the browser process side, also wrapping the time where the render process is initialized. We can't rely on those signals for loadStarted, but afterward rely on the Blink loader for loadFinished. We must use the same source for both. Instead only rely on Blink callbacks ultimately related to network events. This gives us a behavior closer to QtWebKit. The major compromise that this forces us to to accept is that loadStarted is now triggered asynchronously. This will basically break anything expecting loadStarted to be emitted synchronously from the load method. This also adjust autotests to get a few more passing. Initial-patch-by: Pierre Rossi Change-Id: Ib6c0170df891d1b7f8ed4dc1d483985523e267dc Reviewed-by: Pierre Rossi Reviewed-by: Simon Hausmann --- src/webenginewidgets/api/qwebenginepage.cpp | 28 ++++++++++++++-------------- src/webenginewidgets/api/qwebenginepage_p.h | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/webenginewidgets') diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 4c4243ccc..a514882d6 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -151,7 +151,6 @@ QWebEnginePagePrivate::QWebEnginePagePrivate() , adapter(new WebContentsAdapter(SoftwareRenderingMode)) , history(new QWebEngineHistory(new QWebEngineHistoryPrivate(adapter.data()))) , view(0) - , m_isLoading(false) { memset(actions, 0, sizeof(actions)); } @@ -191,18 +190,6 @@ void QWebEnginePagePrivate::iconChanged(const QUrl &url) Q_UNUSED(url) } -void QWebEnginePagePrivate::loadingStateChanged() -{ - Q_Q(QWebEnginePage); - const bool wasLoading = m_isLoading; - m_isLoading = adapter->isLoading(); - if (m_isLoading != wasLoading) { - if (m_isLoading) - Q_EMIT q->loadStarted(); - } - updateNavigationActions(); -} - void QWebEnginePagePrivate::loadProgressChanged(int progress) { Q_Q(QWebEnginePage); @@ -228,15 +215,28 @@ qreal QWebEnginePagePrivate::dpiScale() const return 1.0; } +void QWebEnginePagePrivate::loadStarted(const QUrl &provisionalUrl) +{ + Q_UNUSED(provisionalUrl) + Q_Q(QWebEnginePage); + Q_EMIT q->loadStarted(); + updateNavigationActions(); +} + +void QWebEnginePagePrivate::loadCommitted() +{ + updateNavigationActions(); +} + void QWebEnginePagePrivate::loadFinished(bool success, int error_code, const QString &error_description) { Q_Q(QWebEnginePage); Q_UNUSED(error_code); Q_UNUSED(error_description); - m_isLoading = adapter->isLoading(); if (success) m_explicitUrl = QUrl(); Q_EMIT q->loadFinished(success); + updateNavigationActions(); } void QWebEnginePagePrivate::focusContainer() diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index 42f66cd01..0e06f1685 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -114,11 +114,12 @@ public: virtual void titleChanged(const QString&) Q_DECL_OVERRIDE; virtual void urlChanged(const QUrl&) Q_DECL_OVERRIDE; virtual void iconChanged(const QUrl&) Q_DECL_OVERRIDE; - virtual void loadingStateChanged() Q_DECL_OVERRIDE; virtual void loadProgressChanged(int progress) Q_DECL_OVERRIDE; virtual void selectionChanged() Q_DECL_OVERRIDE; virtual QRectF viewportRect() const Q_DECL_OVERRIDE; virtual qreal dpiScale() const Q_DECL_OVERRIDE; + virtual void loadStarted(const QUrl &provisionalUrl) Q_DECL_OVERRIDE; + virtual void loadCommitted() Q_DECL_OVERRIDE; virtual void loadFinished(bool success, int error_code, const QString &error_description = QString()) Q_DECL_OVERRIDE; virtual void focusContainer() Q_DECL_OVERRIDE; virtual void adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, const QRect &initialGeometry) Q_DECL_OVERRIDE; @@ -144,7 +145,6 @@ public: QWebEngineHistory *history; QWebEngineView *view; QSize viewportSize; - bool m_isLoading; QUrl m_explicitUrl; WebEngineContextMenuData m_menuData; QPointer m_rwhvDelegate; -- cgit v1.2.3