From b447e486b593b1e9fdbbdefa2848ea4f7dd92794 Mon Sep 17 00:00:00 2001 From: Baitinq Date: Thu, 24 Nov 2022 01:17:15 +0100 Subject: [PATCH] Browser: Add History::replace_current() function This function replaces the current history entry with a new history entry. --- Userland/Applications/Browser/History.cpp | 9 +++++++++ Userland/Applications/Browser/History.h | 1 + 2 files changed, 10 insertions(+) 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;