srctree

Robin Linden parent a68352c7 5dec6cc1
browser/gui: Extract navigate_{back,forward} into helpers

inlinesplit
browser/gui/app.cpp added: 28, removed: 19, total 9
@@ -220,29 +220,14 @@ int App::run() {
if (!event.key.alt) {
break;
}
 
auto entry = browse_history_.previous();
if (!entry) {
break;
}
 
browse_history_.pop();
url_buf_ = entry->uri;
navigate();
navigate_back();
break;
}
case sf::Keyboard::Key::Right: {
if (!event.key.alt) {
break;
}
 
auto entry = browse_history_.next();
if (!entry) {
break;
}
 
url_buf_ = entry->uri;
navigate();
navigate_forward();
break;
}
default:
@@ -347,6 +332,27 @@ void App::navigate() {
url_buf_ = engine_.uri().uri;
}
 
void App::navigate_back() {
auto entry = browse_history_.previous();
if (!entry) {
return;
}
 
browse_history_.pop();
url_buf_ = entry->uri;
navigate();
}
 
void App::navigate_forward() {
auto entry = browse_history_.next();
if (!entry) {
return;
}
 
url_buf_ = entry->uri;
navigate();
}
 
void App::on_navigation_failure(protocol::Error err) {
update_status_line();
response_headers_str_ = engine_.response().headers.to_string();
 
browser/gui/app.h added: 28, removed: 19, total 9
@@ -79,6 +79,9 @@ private:
void navigate();
void layout();
 
void navigate_back();
void navigate_forward();
 
layout::LayoutBox const *get_hovered_node(geom::Position document_position) const;
geom::Position to_document_position(geom::Position window_position) const;