mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:17:35 +00:00
LibWeb: Allow calculated values in transform
This commit is contained in:
parent
e23d31ae83
commit
344f37986f
3 changed files with 17 additions and 4 deletions
|
@ -400,7 +400,20 @@ Vector<CSS::Transformation> StyleProperties::transformations() const
|
||||||
transformation.function = transformation_style_value.transform_function();
|
transformation.function = transformation_style_value.transform_function();
|
||||||
Vector<TransformValue> values;
|
Vector<TransformValue> values;
|
||||||
for (auto& transformation_value : transformation_style_value.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() });
|
values.append({ transformation_value->as_length().length() });
|
||||||
} else if (transformation_value->is_percentage()) {
|
} else if (transformation_value->is_percentage()) {
|
||||||
values.append({ transformation_value->as_percentage().percentage() });
|
values.append({ transformation_value->as_percentage().percentage() });
|
||||||
|
@ -409,7 +422,7 @@ Vector<CSS::Transformation> StyleProperties::transformations() const
|
||||||
} else if (transformation_value->is_angle()) {
|
} else if (transformation_value->is_angle()) {
|
||||||
values.append({ transformation_value->as_angle().angle() });
|
values.append({ transformation_value->as_angle().angle() });
|
||||||
} else {
|
} else {
|
||||||
dbgln("FIXME: Unsupported value in transform!");
|
dbgln("FIXME: Unsupported value in transform! {}", transformation_value->to_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
transformation.values = move(values);
|
transformation.values = move(values);
|
||||||
|
|
|
@ -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, {});
|
auto result = m_calculation->resolve(nullptr, {});
|
||||||
if (result.value().has<Number>())
|
if (result.value().has<Number>())
|
||||||
|
|
|
@ -94,7 +94,7 @@ public:
|
||||||
|
|
||||||
bool resolves_to_integer() const { return m_resolved_type == ResolvedType::Integer; }
|
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; }
|
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();
|
Optional<i64> resolve_integer();
|
||||||
|
|
||||||
bool contains_percentage() const;
|
bool contains_percentage() const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue