summaryrefslogtreecommitdiff
path: root/Userland/Applications/Browser
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2022-11-24 01:17:15 +0100
committerAndreas Kling <kling@serenityos.org>2022-11-26 11:03:24 +0100
commitb447e486b593b1e9fdbbdefa2848ea4f7dd92794 (patch)
treee021e79a2ee8b5e368224252fc8e842a7454beb7 /Userland/Applications/Browser
parent45214fdb1a5bd1ca61485ac36d365cc277dff6a7 (diff)
downloadserenity-b447e486b593b1e9fdbbdefa2848ea4f7dd92794.zip
Browser: Add History::replace_current() function
This function replaces the current history entry with a new history entry.
Diffstat (limited to 'Userland/Applications/Browser')
-rw-r--r--Userland/Applications/Browser/History.cpp9
-rw-r--r--Userland/Applications/Browser/History.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Applications/Browser/History.cpp b/Userland/Applications/Browser/History.cpp
index bddd81267c..964944a364 100644
--- a/Userland/Applications/Browser/History.cpp
+++ b/Userland/Applications/Browser/History.cpp
@@ -30,6 +30,15 @@ void History::push(const URL& url, String const& title)
m_current++;
}
+void History::replace_current(const URL& url, String const& title)
+{
+ if (m_current == -1)
+ return;
+
+ m_current--;
+ push(url, title);
+}
+
History::URLTitlePair History::current() const
{
if (m_current == -1)
diff --git a/Userland/Applications/Browser/History.h b/Userland/Applications/Browser/History.h
index 05afcd8532..655c561989 100644
--- a/Userland/Applications/Browser/History.h
+++ b/Userland/Applications/Browser/History.h
@@ -20,6 +20,7 @@ public:
void dump() const;
void push(const URL& url, String const& title);
+ void replace_current(const URL& url, String const& title);
void update_title(String const& title);
URLTitlePair current() const;