mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 14:19:48 +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:
parent
ac15e626dd
commit
03a4ecce19
Notes:
github-actions[bot]
2025-01-17 09:15:27 +00:00
Author: https://github.com/AtkinsSJ
Commit: 03a4ecce19
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3263
9 changed files with 36 additions and 125 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue