summaryrefslogtreecommitdiff
path: root/Applications/Browser
diff options
context:
space:
mode:
authorJake Wilson <jakewilsonfl@gmail.com>2020-08-18 23:34:28 -0400
committerAndreas Kling <kling@serenityos.org>2020-08-19 21:11:10 +0200
commit0f6de0c45ab458b5bb0df500e3174af31960f5f3 (patch)
treed493455fc7b711b5f6a1e6587dd0f03f3f514f9e /Applications/Browser
parentf503d3c0468fbbe4c8672b00e407e710bfd93b0b (diff)
downloadserenity-0f6de0c45ab458b5bb0df500e3174af31960f5f3.zip
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
Diffstat (limited to 'Applications/Browser')
-rw-r--r--Applications/Browser/Tab.cpp9
-rw-r--r--Applications/Browser/Tab.h2
2 files changed, 9 insertions, 2 deletions
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<const Gfx::Bitmap> m_icon;
+
+ bool m_is_history_navigation { false };
};
URL url_from_user_input(const String& input);