From 11b730fccb2e36a6b1409dddb54772e635638be2 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sat, 22 Oct 2022 23:42:00 +0200 Subject: [PATCH] Ladybird: Use Browser's History.{cpp,h} There are no custom changes for Ladybird in the current copies of those files, so we just need to ensure to keep Ladybird up to date for any changes made upstream. --- Ladybird/CMakeLists.txt | 2 +- Ladybird/History.cpp | 83 ----------------------------------------- Ladybird/History.h | 41 -------------------- Ladybird/Tab.cpp | 2 +- Ladybird/Tab.h | 2 +- 5 files changed, 3 insertions(+), 127 deletions(-) delete mode 100644 Ladybird/History.cpp delete mode 100644 Ladybird/History.h diff --git a/Ladybird/CMakeLists.txt b/Ladybird/CMakeLists.txt index 59b8702020..7fa52471d0 100644 --- a/Ladybird/CMakeLists.txt +++ b/Ladybird/CMakeLists.txt @@ -67,9 +67,9 @@ set(BROWSER_SOURCE_DIR ${SERENITY_SOURCE_DIR}/Userland/Applications/Browser/) set(SOURCES ${BROWSER_SOURCE_DIR}/CookieJar.cpp + ${BROWSER_SOURCE_DIR}/History.cpp BrowserWindow.cpp ConsoleWidget.cpp - History.cpp ModelTranslator.cpp Settings.cpp SettingsDialog.cpp diff --git a/Ladybird/History.cpp b/Ladybird/History.cpp deleted file mode 100644 index 1e332b7dca..0000000000 --- a/Ladybird/History.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2020, Andreas Kling - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include "History.h" - -namespace Browser { - -void History::dump() const -{ - dbgln("Dump {} items(s)", m_items.size()); - int i = 0; - for (auto& item : m_items) { - dbgln("[{}] {} '{}' {}", i, item.url, item.title, m_current == i ? '*' : ' '); - ++i; - } -} - -void History::push(const URL& url, String const& title) -{ - if (!m_items.is_empty() && m_items[m_current].url == url) - return; - m_items.shrink(m_current + 1); - m_items.append(URLTitlePair { - .url = url, - .title = title, - }); - m_current++; -} - -History::URLTitlePair History::current() const -{ - if (m_current == -1) - return {}; - return m_items[m_current]; -} - -void History::go_back(int steps) -{ - VERIFY(can_go_back(steps)); - m_current -= steps; -} - -void History::go_forward(int steps) -{ - VERIFY(can_go_forward(steps)); - m_current += steps; -} - -void History::clear() -{ - m_items = {}; - m_current = -1; -} - -void History::update_title(String const& title) -{ - if (m_current == -1) - return; - m_items[m_current].title = title; -} - -Vector History::get_back_title_history() -{ - Vector back_title_history; - for (int i = m_current - 1; i >= 0; i--) { - back_title_history.append(m_items[i].title); - } - return back_title_history; -} - -Vector History::get_forward_title_history() -{ - Vector forward_title_history; - for (int i = m_current + 1; i < static_cast(m_items.size()); i++) { - forward_title_history.append(m_items[i].title); - } - return forward_title_history; -} - -} diff --git a/Ladybird/History.h b/Ladybird/History.h deleted file mode 100644 index 4449944c72..0000000000 --- a/Ladybird/History.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2018-2020, Andreas Kling - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#pragma once - -#include -#include - -namespace Browser { - -class History { -public: - struct URLTitlePair { - URL url; - String title; - }; - void dump() const; - - void push(const URL& url, String const& title); - void update_title(String const& title); - URLTitlePair current() const; - - Vector get_back_title_history(); - Vector get_forward_title_history(); - - void go_back(int steps = 1); - void go_forward(int steps = 1); - - bool can_go_back(int steps = 1) { return (m_current - steps) >= 0; } - bool can_go_forward(int steps = 1) { return (m_current + steps) < static_cast(m_items.size()); } - void clear(); - -private: - Vector m_items; - int m_current { -1 }; -}; - -} diff --git a/Ladybird/Tab.cpp b/Ladybird/Tab.cpp index 9982099b9d..b68c166bc9 100644 --- a/Ladybird/Tab.cpp +++ b/Ladybird/Tab.cpp @@ -7,9 +7,9 @@ #include "Tab.h" #include "BrowserWindow.h" -#include "History.h" #include "Settings.h" #include "Utilities.h" +#include #include #include #include diff --git a/Ladybird/Tab.h b/Ladybird/Tab.h index 1b6737555d..dd3bdb9b29 100644 --- a/Ladybird/Tab.h +++ b/Ladybird/Tab.h @@ -9,8 +9,8 @@ #define AK_DONT_REPLACE_STD -#include "History.h" #include "WebContentView.h" +#include #include #include #include