srctree

Robin Linden parent d74f82a2 ab3b7af8
layout: Support disabling whitespace collapsing

inlinesplit
layout/layout.cpp added: 15, removed: 5, total 10
@@ -321,13 +321,16 @@ void layout(LayoutBox &box, geom::Rect const &bounds, int const root_font_size)
 
} // namespace
 
std::optional<LayoutBox> create_layout(style::StyledNode const &node, int width) {
std::optional<LayoutBox> create_layout(style::StyledNode const &node, int width, WhitespaceMode ws_mode) {
auto tree = create_tree(node);
if (!tree) {
return {};
}
 
collapse_whitespace(*tree);
if (ws_mode == WhitespaceMode::Collapse) {
collapse_whitespace(*tree);
}
 
layout(*tree, {0, 0, width, 0}, node.get_property<css::PropertyId::FontSize>());
return *tree;
}
 
layout/layout.h added: 15, removed: 5, total 10
@@ -13,7 +13,14 @@
 
namespace layout {
 
std::optional<LayoutBox> create_layout(style::StyledNode const &node, int width);
// Being able to toggle this is a debug feature that will go away once both it
// and text wrapping are more ready.
enum class WhitespaceMode {
Preserve,
Collapse,
};
 
std::optional<LayoutBox> create_layout(style::StyledNode const &, int width, WhitespaceMode = WhitespaceMode::Collapse);
 
} // namespace layout