1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:37:35 +00:00

LibWeb: Add calc() resolution to CSS::Length

This patch finally adds the actual calculation that goes into calc()
expressions. When the resolution of a Length that is a calculated value
the parsed CalculatedStyleValue gets traversed and appropriate values
get calculated.
This commit is contained in:
Tobias Christiansen 2021-06-12 00:50:16 +02:00 committed by Ali Mohammad Pur
parent 20667dfff5
commit 9c65c10245
2 changed files with 124 additions and 2 deletions

View file

@ -53,10 +53,10 @@ public:
{
if (is_undefined())
return fallback_for_undefined;
if (is_calculated())
return Length(resolve_calculated_value(layout_node, reference_for_percent), Type::Px);
if (is_percentage())
return make_px(raw_value() / 100.0f * reference_for_percent);
if (is_calculated())
return {};
if (is_relative())
return make_px(to_px(layout_node));
return *this;
@ -153,6 +153,7 @@ public:
private:
float relative_length_to_px(const Layout::Node&) const;
float resolve_calculated_value(const Layout::Node& layout_node, float reference_for_percent) const;
const char* unit_name() const;