mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 12:37:45 +00:00
Browser: Add title to go back/forward context menu
Adds page title to the context menu for go back/forward.
This commit is contained in:
parent
3f5eb6446b
commit
0aa0e00dd5
3 changed files with 39 additions and 23 deletions
|
@ -13,21 +13,24 @@ void History::dump() const
|
|||
dbgln("Dump {} items(s)", m_items.size());
|
||||
int i = 0;
|
||||
for (auto& item : m_items) {
|
||||
dbgln("[{}] {} {}", i, item, m_current == i ? '*' : ' ');
|
||||
dbgln("[{}] {} '{}' {}", i, item.url, item.title, m_current == i ? '*' : ' ');
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
void History::push(const URL& url)
|
||||
void History::push(const URL& url, const String& title)
|
||||
{
|
||||
if (!m_items.is_empty() && m_items[m_current] == url)
|
||||
if (!m_items.is_empty() && m_items[m_current].url == url)
|
||||
return;
|
||||
m_items.shrink(m_current + 1);
|
||||
m_items.append(url);
|
||||
m_items.append(URLTitlePair {
|
||||
.url = url,
|
||||
.title = title,
|
||||
});
|
||||
m_current++;
|
||||
}
|
||||
|
||||
URL History::current() const
|
||||
History::URLTitlePair History::current() const
|
||||
{
|
||||
if (m_current == -1)
|
||||
return {};
|
||||
|
@ -52,22 +55,27 @@ void History::clear()
|
|||
m_current = -1;
|
||||
}
|
||||
|
||||
const Vector<URL> History::get_back_history()
|
||||
void History::update_title(const String& title)
|
||||
{
|
||||
Vector<URL> back_history;
|
||||
m_items[m_current].title = title;
|
||||
}
|
||||
|
||||
const Vector<StringView> History::get_back_title_history()
|
||||
{
|
||||
Vector<StringView> back_title_history;
|
||||
for (int i = m_current - 1; i >= 0; i--) {
|
||||
back_history.append(m_items[i]);
|
||||
back_title_history.append(m_items[i].title);
|
||||
}
|
||||
return back_history;
|
||||
return back_title_history;
|
||||
}
|
||||
|
||||
const Vector<URL> History::get_forward_history()
|
||||
const Vector<StringView> History::get_forward_title_history()
|
||||
{
|
||||
Vector<URL> forward_history;
|
||||
Vector<StringView> forward_title_history;
|
||||
for (int i = m_current + 1; i < static_cast<int>(m_items.size()); i++) {
|
||||
forward_history.append(m_items[i]);
|
||||
forward_title_history.append(m_items[i].title);
|
||||
}
|
||||
return forward_history;
|
||||
return forward_title_history;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue