mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:07:36 +00:00
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.
This commit is contained in:
parent
c91978baa6
commit
11b730fccb
5 changed files with 3 additions and 127 deletions
|
@ -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
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* 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<StringView> History::get_back_title_history()
|
||||
{
|
||||
Vector<StringView> 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<StringView> History::get_forward_title_history()
|
||||
{
|
||||
Vector<StringView> forward_title_history;
|
||||
for (int i = m_current + 1; i < static_cast<int>(m_items.size()); i++) {
|
||||
forward_title_history.append(m_items[i].title);
|
||||
}
|
||||
return forward_title_history;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/URL.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
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<StringView> get_back_title_history();
|
||||
Vector<StringView> 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<int>(m_items.size()); }
|
||||
void clear();
|
||||
|
||||
private:
|
||||
Vector<URLTitlePair> m_items;
|
||||
int m_current { -1 };
|
||||
};
|
||||
|
||||
}
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
#include "Tab.h"
|
||||
#include "BrowserWindow.h"
|
||||
#include "History.h"
|
||||
#include "Settings.h"
|
||||
#include "Utilities.h"
|
||||
#include <Browser/History.h>
|
||||
#include <QCoreApplication>
|
||||
#include <QFont>
|
||||
#include <QFontMetrics>
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
#define AK_DONT_REPLACE_STD
|
||||
|
||||
#include "History.h"
|
||||
#include "WebContentView.h"
|
||||
#include <Browser/History.h>
|
||||
#include <QBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue