srctree

Robin Linden parent 65c708c8 1250dcd6
layout: Handle max-height: none

This fixes that max-height: none would be treated as max-height: 0.

inlinesplit
layout/layout.cpp added: 12, removed: 3, total 9
@@ -171,7 +171,7 @@ void calculate_height(LayoutBox &box, int const font_size) {
box.dimensions.content.height = std::max(box.dimensions.content.height, to_px(*min, font_size));
}
 
if (auto max = box.get_property("max-height")) {
if (auto max = box.get_property("max-height"); max && max != "none") {
box.dimensions.content.height = std::min(box.dimensions.content.height, to_px(*max, font_size));
}
}
 
layout/layout_test.cpp added: 12, removed: 3, total 9
@@ -931,6 +931,15 @@ int main() {
expect_eq(layout, expected_layout);
});
 
etest::test("max-height: auto", [] {
dom::Node dom = dom::Element{.name{"html"}};
style::StyledNode style{.node{dom}, .properties{{"height", "100px"}, {"max-height", "none"}}};
layout::LayoutBox expected_layout{.node = &style, .type = LayoutType::Block, .dimensions{{0, 0, 0, 100}}};
 
auto layout = layout::create_layout(style, 0);
expect_eq(layout, expected_layout);
});
 
etest::test("get_property", [] {
dom::Node dom_root = dom::Element{.name{"html"}, .attributes{}, .children{}};
auto style_root = style::StyledNode{.node = dom_root, .properties = {{"color", "green"}}, .children{}};