From 0f6de0c45ab458b5bb0df500e3174af31960f5f3 Mon Sep 17 00:00:00 2001 From: Jake Wilson Date: Tue, 18 Aug 2020 23:34:28 -0400 Subject: Browser: add urls to browser history on load start urls were previously added to history in the Tab::load() function, which excluded the setter on window.location.href. This commit adds all urls to browser history when the page loads, as long as the load_type is not LoadType::HistoryNavigation. Closes #3148 --- Applications/Browser/Tab.cpp | 9 +++++++-- Applications/Browser/Tab.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'Applications/Browser') diff --git a/Applications/Browser/Tab.cpp b/Applications/Browser/Tab.cpp index 7c3f9c7c75..18a690ddb2 100644 --- a/Applications/Browser/Tab.cpp +++ b/Applications/Browser/Tab.cpp @@ -132,6 +132,12 @@ Tab::Tab(Type type) hooks().on_load_start = [this](auto& url) { m_location_box->set_icon(nullptr); m_location_box->set_text(url.to_string()); + + // don't add to history if back or forward is pressed + if (!m_is_history_navigation) + m_history.push(url); + m_is_history_navigation = false; + update_actions(); update_bookmark_button(url.to_string()); }; @@ -404,8 +410,7 @@ Tab::~Tab() void Tab::load(const URL& url, LoadType load_type) { - if (load_type == LoadType::Normal) - m_history.push(url); + m_is_history_navigation = (load_type == LoadType::HistoryNavigation); if (m_type == Type::InProcessWebView) m_page_view->load(url); diff --git a/Applications/Browser/Tab.h b/Applications/Browser/Tab.h index 2db9cfcf6c..c7adea48ad 100644 --- a/Applications/Browser/Tab.h +++ b/Applications/Browser/Tab.h @@ -109,6 +109,8 @@ private: String m_title; RefPtr m_icon; + + bool m_is_history_navigation { false }; }; URL url_from_user_input(const String& input); -- cgit v1.2.3