LibWeb: Allow calculated values in transform

This commit is contained in:
stelar7 2023-05-27 19:21:42 +02:00 committed by Andreas Kling
parent e23d31ae83
commit 344f37986f
Notes: sideshowbarker 2024-07-16 20:31:50 +09:00
3 changed files with 17 additions and 4 deletions

View File

@ -400,7 +400,20 @@ Vector<CSS::Transformation> StyleProperties::transformations() const
transformation.function = transformation_style_value.transform_function();
Vector<TransformValue> 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<CSS::Transformation> 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);

View File

@ -745,7 +745,7 @@ Optional<Time> CalculatedStyleValue::resolve_time_percentage(Time const& percent
});
}
Optional<float> CalculatedStyleValue::resolve_number()
Optional<float> CalculatedStyleValue::resolve_number() const
{
auto result = m_calculation->resolve(nullptr, {});
if (result.value().has<Number>())

View File

@ -94,7 +94,7 @@ public:
bool resolves_to_integer() const { return m_resolved_type == ResolvedType::Integer; }
bool resolves_to_number() const { return resolves_to_integer() || m_resolved_type == ResolvedType::Number; }
Optional<float> resolve_number();
Optional<float> resolve_number() const;
Optional<i64> resolve_integer();
bool contains_percentage() const;