Skip to content

Truly independent web browser

LibWebView: Remember whether a view's last load finished

Andreas Klingafbdc6fc52ff
diff --git a/Libraries/LibWebView/ViewImplementation.cpp b/Libraries/LibWebView/ViewImplementation.cpp
index 08fa00065c2..61ec32fffe6 100644
--- a/Libraries/LibWebView/ViewImplementation.cpp
+++ b/Libraries/LibWebView/ViewImplementation.cpp
@@ -2777,6 +2777,7 @@ void ViewImplementation::did_cancel_loading(Badge<CanonicalNavigable>, bool canc
void ViewImplementation::did_finish_navigation()
{
+ m_last_load_finished = true;
set_loading_state(false);
if (!m_webdriver_navigation_observation.has_value())
@@ -2798,6 +2799,8 @@ void ViewImplementation::did_finish_navigation()
void ViewImplementation::set_loading_state(bool is_loading)
{
+ if (is_loading)
+ m_last_load_finished = false;
if (m_is_loading == is_loading)
return;
m_is_loading = is_loading;
diff --git a/Libraries/LibWebView/ViewImplementation.h b/Libraries/LibWebView/ViewImplementation.h
index 42d740d62cb..fd8cdf5355d 100644
--- a/Libraries/LibWebView/ViewImplementation.h
+++ b/Libraries/LibWebView/ViewImplementation.h
@@ -160,6 +160,8 @@ public:
void reload();
void stop_loading();
bool is_loading() const { return m_is_loading; }
+ // Whether the most recent load ran to completion, rather than being stopped or canceled.
+ bool last_load_finished() const { return m_last_load_finished; }
bool crash_overlay_active() const { return m_crash_state.has_value(); }
String crash_overlay_failed_url() const;
@@ -901,6 +903,7 @@ protected:
bool m_can_undo { false };
bool m_can_redo { false };
bool m_is_loading { false };
+ bool m_last_load_finished { false };
// WebDriver's observation of the top-level navigation completion state. The navigation itself is the
// canonical traversable's ongoing navigation record.
struct WebDriverNavigationObservation {