diff --git a/Meta/gn/secondary/Userland/Libraries/LibWebView/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibWebView/BUILD.gn index a6abba1cfe2..b777e7fb4ac 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibWebView/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibWebView/BUILD.gn @@ -120,7 +120,6 @@ shared_library("LibWebView") { "Attribute.cpp", "CookieJar.cpp", "Database.cpp", - "History.cpp", "InspectorClient.cpp", "ProcessHandle.cpp", "ProcessManager.cpp", diff --git a/Userland/Libraries/LibWebView/CMakeLists.txt b/Userland/Libraries/LibWebView/CMakeLists.txt index 7d2b6e23262..2c6b9428b3e 100644 --- a/Userland/Libraries/LibWebView/CMakeLists.txt +++ b/Userland/Libraries/LibWebView/CMakeLists.txt @@ -4,7 +4,6 @@ set(SOURCES Attribute.cpp CookieJar.cpp Database.cpp - History.cpp InspectorClient.cpp ProcessHandle.cpp ProcessManager.cpp diff --git a/Userland/Libraries/LibWebView/Forward.h b/Userland/Libraries/LibWebView/Forward.h index 64332eec92b..713323a1d50 100644 --- a/Userland/Libraries/LibWebView/Forward.h +++ b/Userland/Libraries/LibWebView/Forward.h @@ -12,7 +12,6 @@ namespace WebView { class CookieJar; class Database; -class History; class InspectorClient; class OutOfProcessWebView; class ProcessManager; diff --git a/Userland/Libraries/LibWebView/History.cpp b/Userland/Libraries/LibWebView/History.cpp deleted file mode 100644 index 23c87cd4031..00000000000 --- a/Userland/Libraries/LibWebView/History.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2020, Andreas Kling - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#include - -namespace WebView { - -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; - } -} - -Vector History::get_all_history_entries() -{ - return m_items; -} - -void History::push(const URL::URL& url, ByteString 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++; -} - -void History::replace_current(const URL::URL& url, ByteString const& title) -{ - if (m_current == -1) - return; - - m_items.remove(m_current); - m_current--; - push(url, title); -} - -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(ByteString const& title) -{ - if (m_current == -1) - return; - m_items[m_current].title = title; -} - -Vector const 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 const 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/Userland/Libraries/LibWebView/History.h b/Userland/Libraries/LibWebView/History.h deleted file mode 100644 index 0635ea4188c..00000000000 --- a/Userland/Libraries/LibWebView/History.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2018-2020, Andreas Kling - * - * SPDX-License-Identifier: BSD-2-Clause - */ - -#pragma once - -#include -#include - -namespace WebView { - -class History { -public: - struct URLTitlePair { - URL::URL url; - ByteString title; - }; - void dump() const; - Vector get_all_history_entries(); - - void push(const URL::URL& url, ByteString const& title); - void replace_current(const URL::URL& url, ByteString const& title); - void update_title(ByteString const& title); - URLTitlePair current() const; - - Vector const get_back_title_history(); - Vector const 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(); - - bool is_empty() const { return m_items.is_empty(); } - -private: - Vector m_items; - int m_current { -1 }; -}; - -}