diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h index 6fd29ec61b3dade5e4b96dac9d7873beda9f3a32..514d3afb4c90363f2c5729de31cbf9e5ecb50c83 100644 --- a/src/core/web_contents_adapter_client.h +++ b/src/core/web_contents_adapter_client.h @@ -465,6 +465,7 @@ public: virtual void selectClientCert(const QSharedPointer<ClientCertSelectController> &selectController) = 0; virtual void updateScrollPosition(const QPointF &position) = 0; virtual void updateContentsSize(const QSizeF &size) = 0; + virtual void updateNavigationActions() = 0; virtual void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions, const QPixmap &pixmap, const QPoint &offset) = 0; virtual bool supportsDragging() const = 0; diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 569b939d8e9ac3ec8b04a029d2a76cd220c6d59a..9472c0be93b95883acd94b9ca3358fd169b1f796 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -263,6 +263,7 @@ void WebContentsDelegateQt::EmitLoadStarted(const QUrl &url, bool isErrorPage) if (m_lastLoadProgress >= 0 && m_lastLoadProgress < 100) // already running return; m_viewClient->loadStarted(url, isErrorPage); + m_viewClient->updateNavigationActions(); m_viewClient->loadProgressChanged(0); m_lastLoadProgress = 0; } @@ -287,6 +288,16 @@ void WebContentsDelegateQt::EmitLoadFinished(bool success, const QUrl &url, bool m_lastLoadProgress = -1; m_viewClient->loadProgressChanged(100); m_viewClient->loadFinished(success, url, isErrorPage, errorCode, errorDescription); + m_viewClient->updateNavigationActions(); +} + +void WebContentsDelegateQt::EmitLoadCommitted() +{ + // Make sure that we don't set the findNext WebFindOptions on a new frame. + m_lastSearchedString = QString(); + + m_viewClient->loadCommitted(); + m_viewClient->updateNavigationActions(); } void WebContentsDelegateQt::DidFinishNavigation(content::NavigationHandle *navigation_handle) @@ -302,11 +313,7 @@ void WebContentsDelegateQt::DidFinishNavigation(content::NavigationHandle *navig profileAdapter->visitedLinksManager()->addUrl(url); } - // Make sure that we don't set the findNext WebFindOptions on a new frame. - m_lastSearchedString = QString(); - - // 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(); + EmitLoadCommitted(); } // Success is reported by DidFinishLoad, but DidFailLoad is now dead code and needs to be handled below if (navigation_handle->GetNetErrorCode() == net::OK) @@ -325,10 +332,8 @@ void WebContentsDelegateQt::DidFinishNavigation(content::NavigationHandle *navig EmitLoadStarted(toQt(GURL(content::kUnreachableWebDataURL)), true); // If it is already committed we will not see another DidFinishNavigation call or a DidFinishLoad call. - if (navigation_handle->HasCommitted()) { - m_lastSearchedString = QString(); - m_viewClient->loadCommitted(); - } + if (navigation_handle->HasCommitted()) + EmitLoadCommitted(); } } diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h index 124250a40a7560b6872f93e9daf0cbb1a7dc1592..966494ec739d969e0d904e2e4abb81b91dff017e 100644 --- a/src/core/web_contents_delegate_qt.h +++ b/src/core/web_contents_delegate_qt.h @@ -159,6 +159,7 @@ private: QWeakPointer<WebContentsAdapter> createWindow(std::unique_ptr<content::WebContents> new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture); void EmitLoadStarted(const QUrl &url, bool isErrorPage = false); void EmitLoadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()); + void EmitLoadCommitted(); WebContentsAdapterClient *m_viewClient; QString m_lastSearchedString; diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index 116f49c3c2e687ef01e4037fdb89ec771b75f603..a3a12819b5cc6090b8f5f5a483ea9f24e08be69d 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -878,6 +878,15 @@ void QQuickWebEngineViewPrivate::updateAction(QQuickWebEngineView::WebAction act a->d_ptr->setEnabled(enabled); } +void QQuickWebEngineViewPrivate::updateNavigationActions() +{ + updateAction(QQuickWebEngineView::Back); + updateAction(QQuickWebEngineView::Forward); + updateAction(QQuickWebEngineView::Stop); + updateAction(QQuickWebEngineView::Reload); + updateAction(QQuickWebEngineView::ReloadAndBypassCache); + updateAction(QQuickWebEngineView::ViewSource); +} QUrl QQuickWebEngineView::url() const { diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index ee38ece6b735d8eef1ca302606931b669182506e..d20bfca46616c5e72aac50b0c27e741a5cf3cd43 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -145,6 +145,7 @@ public: void requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) override; void updateScrollPosition(const QPointF &position) override; void updateContentsSize(const QSizeF &size) override; + void updateNavigationActions() override; void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions, const QPixmap &pixmap, const QPoint &offset) override; bool supportsDragging() const override; diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 953cb4168b6730020a454b631cc6e47738136405..3a2a075206921b9a89f8c3c438b4c7d7e1d0df08 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -368,12 +368,6 @@ void QWebEnginePagePrivate::loadStarted(const QUrl &provisionalUrl, bool isError isLoading = true; QTimer::singleShot(0, q, &QWebEnginePage::loadStarted); - updateNavigationActions(); -} - -void QWebEnginePagePrivate::loadCommitted() -{ - updateNavigationActions(); } void QWebEnginePagePrivate::loadFinished(bool success, const QUrl &url, bool isErrorPage, int errorCode, const QString &errorDescription) @@ -401,7 +395,6 @@ void QWebEnginePagePrivate::loadFinished(bool success, const QUrl &url, bool isE emit q->loadFinished(success); }); } - updateNavigationActions(); } void QWebEnginePagePrivate::didPrintPageToPdf(const QString &filePath, bool success) diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index 66a92dec9c1f7af8c0b46a5d5dfe839b05545ba5..dc8a34af6c4b4db07f380de434e2175e2482ed26 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -100,7 +100,7 @@ public: qreal dpiScale() const override; QColor backgroundColor() const override; void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) override; - void loadCommitted() override; + void loadCommitted() override { } void loadVisuallyCommitted() override { } void loadFinished(bool success, const QUrl &url, bool isErrorPage = false, int errorCode = 0, const QString &errorDescription = QString()) override; void focusContainer() override; @@ -141,6 +141,7 @@ public: void requestGeometryChange(const QRect &geometry, const QRect &frameGeometry) override; void updateScrollPosition(const QPointF &position) override; void updateContentsSize(const QSizeF &size) override; + void updateNavigationActions() override; void startDragging(const content::DropData &dropData, Qt::DropActions allowedActions, const QPixmap &pixmap, const QPoint &offset) override; bool supportsDragging() const override; @@ -154,7 +155,6 @@ public: QtWebEngineCore::WebContentsAdapter *webContentsAdapter() override; void updateAction(QWebEnginePage::WebAction) const; - void updateNavigationActions(); void _q_webActionTriggered(bool checked); void wasShown();