srctree

Robin Linden parent 1d4c4f07 5d1c9f92
browser: Update to more idiomatic C++

inlinesplit
browser/engine.cpp added: 13, removed: 17, total 0
@@ -87,15 +87,11 @@ void Engine::on_navigation_success() {
}
 
auto head_links = dom::nodes_by_path(dom_.html(), "html.head.link");
head_links.erase(
std::remove_if(begin(head_links),
end(head_links),
[](auto const *link) {
return !link->attributes.contains("rel")
|| (link->attributes.contains("rel") && link->attributes.at("rel") != "stylesheet")
|| !link->attributes.contains("href");
}),
end(head_links));
std::erase_if(head_links, [](auto const *link) {
return !link->attributes.contains("rel")
|| (link->attributes.contains("rel") && link->attributes.at("rel") != "stylesheet")
|| !link->attributes.contains("href");
});
 
// Start downloading all stylesheets.
spdlog::info("Loading {} stylesheets", head_links.size());
 
browser/gui.cpp added: 13, removed: 17, total 0
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2021 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2021-2022 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
@@ -54,7 +54,7 @@ int main(int argc, char **argv) {
return 1;
}
 
browser::gui::App app{kBrowserTitle, page_provided ? *page_provided : kStartpage, page_provided.has_value()};
browser::gui::App app{kBrowserTitle, page_provided.value_or(kStartpage), page_provided.has_value()};
app.set_scale(scale);
return app.run();
}
 
browser/gui/app.cpp added: 13, removed: 17, total 0
@@ -47,9 +47,9 @@ App::App(std::string browser_title, std::string start_page_hint, bool load_start
painter_->set_viewport_size(window_.getSize().x, window_.getSize().y);
 
engine_.set_layout_width(window_.getSize().x / scale_);
engine_.set_on_navigation_failure(std::bind(&App::on_navigation_failure, this, std::placeholders::_1));
engine_.set_on_page_loaded(std::bind(&App::on_page_loaded, this));
engine_.set_on_layout_updated(std::bind(&App::on_layout_updated, this));
engine_.set_on_navigation_failure(std::bind_front(&App::on_navigation_failure, this));
engine_.set_on_page_loaded(std::bind_front(&App::on_page_loaded, this));
engine_.set_on_layout_updated(std::bind_front(&App::on_layout_updated, this));
 
if (load_start_page) {
navigate();