From 344f37986f278ec9846ea8070c2400697f0dd242 Mon Sep 17 00:00:00 2001 From: stelar7 Date: Sat, 27 May 2023 19:21:42 +0200 Subject: [PATCH] LibWeb: Allow calculated values in transform --- .../Libraries/LibWeb/CSS/StyleProperties.cpp | 17 +++++++++++++++-- .../CSS/StyleValues/CalculatedStyleValue.cpp | 2 +- .../CSS/StyleValues/CalculatedStyleValue.h | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index 21201160887..3c638dac48b 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -400,7 +400,20 @@ Vector StyleProperties::transformations() const transformation.function = transformation_style_value.transform_function(); Vector values; for (auto& transformation_value : transformation_style_value.values()) { - if (transformation_value->is_length()) { + if (transformation_value->is_calculated()) { + auto& calculated = transformation_value->as_calculated(); + if (calculated.resolves_to_length()) { + dbgln("FIXME: Unable to resolve length with no layout node! {}", calculated.to_string()); + } else if (calculated.resolves_to_percentage()) { + values.append({ calculated.resolve_percentage().value() }); + } else if (calculated.resolves_to_number()) { + values.append({ calculated.resolve_number().value() }); + } else if (calculated.resolves_to_angle()) { + values.append({ calculated.resolve_angle().value() }); + } else { + dbgln("FIXME: Unsupported calc value in transform! {}", calculated.to_string()); + } + } else if (transformation_value->is_length()) { values.append({ transformation_value->as_length().length() }); } else if (transformation_value->is_percentage()) { values.append({ transformation_value->as_percentage().percentage() }); @@ -409,7 +422,7 @@ Vector StyleProperties::transformations() const } else if (transformation_value->is_angle()) { values.append({ transformation_value->as_angle().angle() }); } else { - dbgln("FIXME: Unsupported value in transform!"); + dbgln("FIXME: Unsupported value in transform! {}", transformation_value->to_string()); } } transformation.values = move(values); diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp index 2ce0745d64f..27c59da0dc4 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp @@ -745,7 +745,7 @@ Optional