mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibWeb/CSS: Merge TranslationStyleValue into TransformationStyleValue
As with ScaleStyleValue, the serialization is the only unique part of this class, and we can just move it over.
This commit is contained in:
committed by
Andreas Kling
parent
ac15e626dd
commit
03a4ecce19
@@ -87,6 +87,32 @@ String TransformationStyleValue::to_string(SerializationMode mode) const
|
||||
}
|
||||
return builder.to_string_without_validation();
|
||||
}
|
||||
if (m_properties.property == PropertyID::Translate) {
|
||||
auto resolve_to_string = [mode](CSSStyleValue const& value) -> Optional<String> {
|
||||
if (value.is_length()) {
|
||||
if (value.as_length().length().raw_value() == 0)
|
||||
return {};
|
||||
}
|
||||
if (value.is_percentage()) {
|
||||
if (value.as_percentage().percentage().value() == 0)
|
||||
return {};
|
||||
}
|
||||
return value.to_string(mode);
|
||||
};
|
||||
|
||||
auto x_value = resolve_to_string(m_properties.values[0]);
|
||||
auto y_value = resolve_to_string(m_properties.values[1]);
|
||||
// FIXME: 3D translation
|
||||
|
||||
StringBuilder builder;
|
||||
builder.append(x_value.value_or("0px"_string));
|
||||
if (y_value.has_value()) {
|
||||
builder.append(" "sv);
|
||||
builder.append(y_value.value());
|
||||
}
|
||||
|
||||
return builder.to_string_without_validation();
|
||||
}
|
||||
|
||||
StringBuilder builder;
|
||||
builder.append(CSS::to_string(m_properties.transform_function));
|
||||
|
||||
Reference in New Issue
Block a user