srctree

Robin Linden parent 081359e6 94adc71b
engine: Add //type plumbing

inlinesplit
engine/BUILD added: 13, removed: 7, total 6
@@ -15,6 +15,8 @@ cc_library(
"//layout",
"//protocol",
"//style",
"//type",
"//type:naive",
"//uri",
"@spdlog",
],
 
engine/engine.cpp added: 13, removed: 7, total 6
@@ -43,7 +43,7 @@ void Engine::set_layout_width(int width) {
}
 
styled_ = style::style_tree(dom_.html_node, stylesheet_, {.window_width = layout_width_});
layout_ = layout::create_layout(*styled_, layout_width_);
layout_ = layout::create_layout(*styled_, layout_width_, *type_);
on_layout_update_();
}
 
@@ -128,7 +128,7 @@ void Engine::on_navigation_success() {
 
spdlog::info("Styling dom w/ {} rules", stylesheet_.rules.size());
styled_ = style::style_tree(dom_.html_node, stylesheet_, {.window_width = layout_width_});
layout_ = layout::create_layout(*styled_, layout_width_);
layout_ = layout::create_layout(*styled_, layout_width_, *type_);
on_page_loaded_();
}
 
 
engine/engine.h added: 13, removed: 7, total 6
@@ -12,6 +12,8 @@
#include "protocol/iprotocol_handler.h"
#include "protocol/response.h"
#include "style/styled_node.h"
#include "type/naive.h"
#include "type/type.h"
#include "uri/uri.h"
 
#include <functional>
@@ -24,8 +26,9 @@ namespace engine {
 
class Engine {
public:
explicit Engine(std::unique_ptr<protocol::IProtocolHandler> protocol_handler)
: protocol_handler_{std::move(protocol_handler)} {}
explicit Engine(std::unique_ptr<protocol::IProtocolHandler> protocol_handler,
std::unique_ptr<type::IType const> type = std::make_unique<type::NaiveType>())
: protocol_handler_{std::move(protocol_handler)}, type_{std::move(type)} {}
 
protocol::Error navigate(uri::Uri uri);
 
@@ -58,6 +61,7 @@ private:
int layout_width_{};
 
std::unique_ptr<protocol::IProtocolHandler> protocol_handler_{};
std::unique_ptr<type::IType const> type_{};
 
uri::Uri uri_{};
protocol::Response response_{};