diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/web_contents_adapter_client.h | 3 | ||||
-rw-r--r-- | src/core/web_contents_delegate_qt.cpp | 28 | ||||
-rw-r--r-- | src/core/web_contents_delegate_qt.h | 5 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview.cpp | 19 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview_p_p.h | 4 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.cpp | 28 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage_p.h | 4 |
7 files changed, 47 insertions, 44 deletions
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h index e436fd61d..0cb4e3d10 100644 --- a/src/core/web_contents_adapter_client.h +++ b/src/core/web_contents_adapter_client.h @@ -119,11 +119,12 @@ public: virtual void titleChanged(const QString&) = 0; virtual void urlChanged(const QUrl&) = 0; virtual void iconChanged(const QUrl&) = 0; - virtual void loadingStateChanged() = 0; virtual void loadProgressChanged(int progress) = 0; virtual void selectionChanged() = 0; virtual QRectF viewportRect() const = 0; virtual qreal dpiScale() const = 0; + virtual void loadStarted(const QUrl &provisionalUrl) = 0; + virtual void loadCommitted() = 0; virtual void loadFinished(bool success, int error_code = 0, const QString &error_description = QString()) = 0; virtual void focusContainer() = 0; virtual void adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, const QRect & initialGeometry) = 0; diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index c0b050de6..e57ee4890 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -89,32 +89,38 @@ void WebContentsDelegateQt::CloseContents(content::WebContents *source) GetJavaScriptDialogManager()->CancelActiveAndPendingDialogs(source); } -void WebContentsDelegateQt::LoadingStateChanged(content::WebContents* source) -{ - m_viewClient->loadingStateChanged(); -} - void WebContentsDelegateQt::LoadProgressChanged(content::WebContents* source, double progress) { m_viewClient->loadProgressChanged(qRound(progress * 100)); } -void WebContentsDelegateQt::DidFailLoad(int64 frame_id, const GURL &validated_url, bool is_main_frame, int error_code, const string16 &error_description, content::RenderViewHost *render_view_host) +void WebContentsDelegateQt::DidStartProvisionalLoadForFrame(int64, int64, bool is_main_frame, const GURL &validated_url, bool, bool, content::RenderViewHost*) { if (is_main_frame) - m_viewClient->loadFinished(false, error_code, toQt(error_description)); + m_viewClient->loadStarted(toQt(validated_url)); +} + +void WebContentsDelegateQt::DidCommitProvisionalLoadForFrame(int64, bool is_main_frame, const GURL& url, content::PageTransition transition_type, content::RenderViewHost *render_view_host) +{ + // This is currently used for canGoBack/Forward values, which is flattened across frames. For other purposes we might have to pass is_main_frame. + m_viewClient->loadCommitted(); } -void WebContentsDelegateQt::DidFinishLoad(int64 frame_id, const GURL &validated_url, bool is_main_frame, content::RenderViewHost *render_view_host) +void WebContentsDelegateQt::DidFailProvisionalLoad(int64 frame_id, bool is_main_frame, const GURL& validated_url, int error_code, const string16& error_description, content::RenderViewHost *render_view_host) +{ + DidFailLoad(frame_id, validated_url, is_main_frame, error_code, error_description, render_view_host); +} + +void WebContentsDelegateQt::DidFailLoad(int64, const GURL&, bool is_main_frame, int error_code, const string16 &error_description, content::RenderViewHost*) { if (is_main_frame) - m_viewClient->loadFinished(true); + m_viewClient->loadFinished(false, error_code, toQt(error_description)); } -void WebContentsDelegateQt::DidFailProvisionalLoad(int64 frame_id, bool is_main_frame, const GURL& validated_url, int error_code, const string16& error_description, content::RenderViewHost* render_view_host) +void WebContentsDelegateQt::DidFinishLoad(int64, const GURL&, bool is_main_frame, content::RenderViewHost*) { if (is_main_frame) - DidFailLoad(frame_id, validated_url, is_main_frame, error_code, error_description, render_view_host); + m_viewClient->loadFinished(true); } void WebContentsDelegateQt::DidUpdateFaviconURL(int32 page_id, const std::vector<content::FaviconURL>& candidates) diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index 4c8701945..ac787f50c 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -66,12 +66,13 @@ public: virtual void NavigationStateChanged(const content::WebContents* source, unsigned changed_flags) Q_DECL_OVERRIDE; virtual void AddNewContents(content::WebContents* source, content::WebContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture, bool* was_blocked) Q_DECL_OVERRIDE; virtual void CloseContents(content::WebContents *source) Q_DECL_OVERRIDE; - virtual void LoadingStateChanged(content::WebContents* source) Q_DECL_OVERRIDE; virtual void LoadProgressChanged(content::WebContents* source, double progress) Q_DECL_OVERRIDE; + virtual void DidStartProvisionalLoadForFrame(int64 frame_id, int64 parent_frame_id, bool is_main_frame, const GURL &validated_url, bool is_error_page, bool is_iframe_srcdoc, content::RenderViewHost *render_view_host) Q_DECL_OVERRIDE; + virtual void DidCommitProvisionalLoadForFrame(int64 frame_id, bool is_main_frame, const GURL &url, content::PageTransition transition_type, content::RenderViewHost *render_view_host) Q_DECL_OVERRIDE; + virtual void DidFailProvisionalLoad(int64 frame_id, bool is_main_frame, const GURL &validated_url, int error_code, const string16& error_description, content::RenderViewHost *render_view_host) Q_DECL_OVERRIDE; virtual void DidFailLoad(int64 frame_id, const GURL &validated_url, bool is_main_frame, int error_code, const string16 &error_description, content::RenderViewHost *render_view_host) Q_DECL_OVERRIDE; virtual void DidFinishLoad(int64 frame_id, const GURL &validated_url, bool is_main_frame, content::RenderViewHost *render_view_host) Q_DECL_OVERRIDE; virtual void DidUpdateFaviconURL(int32 page_id, const std::vector<content::FaviconURL>& candidates) Q_DECL_OVERRIDE; - virtual void DidFailProvisionalLoad(int64 frame_id, bool is_main_frame, const GURL& validated_url, int error_code, const string16& error_description, content::RenderViewHost* render_view_host) Q_DECL_OVERRIDE; virtual content::JavaScriptDialogManager *GetJavaScriptDialogManager() Q_DECL_OVERRIDE; virtual void ToggleFullscreenModeForTab(content::WebContents* web_contents, bool enter_fullscreen) Q_DECL_OVERRIDE; virtual bool IsFullscreenForTabOrPending(const content::WebContents* web_contents) const Q_DECL_OVERRIDE; diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 58262cd3f..27282e111 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -72,7 +72,6 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate() , contextMenuExtraItems(0) , loadProgress(0) , inspectable(false) - , m_isLoading(false) , m_isFullScreen(false) , devicePixelRatio(QGuiApplication::primaryScreen()->devicePixelRatio()) , m_dpiScale(1.0) @@ -213,17 +212,6 @@ void QQuickWebEngineViewPrivate::iconChanged(const QUrl &url) Q_EMIT q->iconChanged(); } -void QQuickWebEngineViewPrivate::loadingStateChanged() -{ - Q_Q(QQuickWebEngineView); - const bool wasLoading = m_isLoading; - m_isLoading = adapter->isLoading(); - if (m_isLoading && !wasLoading) { - QQuickWebEngineLoadRequest loadRequest(q->url(), QQuickWebEngineView::LoadStartedStatus); - Q_EMIT q->loadingChanged(&loadRequest); - } -} - void QQuickWebEngineViewPrivate::loadProgressChanged(int progress) { Q_Q(QQuickWebEngineView); @@ -242,6 +230,13 @@ qreal QQuickWebEngineViewPrivate::dpiScale() const return m_dpiScale; } +void QQuickWebEngineViewPrivate::loadStarted(const QUrl &provisionalUrl) +{ + Q_Q(QQuickWebEngineView); + QQuickWebEngineLoadRequest loadRequest(provisionalUrl, QQuickWebEngineView::LoadStartedStatus); + Q_EMIT q->loadingChanged(&loadRequest); +} + void QQuickWebEngineViewPrivate::loadFinished(bool success, int error_code, const QString &error_description) { Q_Q(QQuickWebEngineView); diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index 8b489138c..564287114 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -131,11 +131,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 = 0, const QString &error_description = QString()) Q_DECL_OVERRIDE; virtual void focusContainer() Q_DECL_OVERRIDE; virtual void adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, const QRect &) Q_DECL_OVERRIDE; @@ -164,7 +165,6 @@ public: QUrl icon; int loadProgress; bool inspectable; - bool m_isLoading; bool m_isFullScreen; qreal devicePixelRatio; QMap<quint64, QJSValue> m_callbacks; 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<RenderWidgetHostViewQtDelegateWebPage> m_rwhvDelegate; |