1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 04:57:44 +00:00

Browser: Add context menu with history for back/forward button

Right clicking on back or forward will now show a context menu with
URLs to navigate to. Also added an optional argument for the number of
steps in go_back() and go_forward().
This commit is contained in:
Marcus Nilsson 2021-05-24 00:58:00 +02:00 committed by GitHub
parent 0688e02339
commit 6b85c7647c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 68 additions and 20 deletions

View file

@ -34,16 +34,16 @@ URL History::current() const
return m_items[m_current];
}
void History::go_back()
void History::go_back(int steps)
{
VERIFY(can_go_back());
m_current--;
VERIFY(can_go_back(steps));
m_current -= steps;
}
void History::go_forward()
void History::go_forward(int steps)
{
VERIFY(can_go_forward());
m_current++;
VERIFY(can_go_forward(steps));
m_current += steps;
}
void History::clear()
@ -52,4 +52,22 @@ void History::clear()
m_current = -1;
}
const Vector<URL> History::get_back_history()
{
Vector<URL> back_history;
for (int i = m_current - 1; i >= 0; i--) {
back_history.append(m_items[i]);
}
return back_history;
}
const Vector<URL> History::get_forward_history()
{
Vector<URL> forward_history;
for (int i = m_current + 1; i < static_cast<int>(m_items.size()); i++) {
forward_history.append(m_items[i]);
}
return forward_history;
}
}