mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 15:19:42 +00:00
LibWeb: Support parsing and serializing 3D translate values
This commit is contained in:
parent
d804f1311c
commit
27baaa13e9
Notes:
github-actions[bot]
2025-04-30 17:37:57 +00:00
Author: https://github.com/tcl3
Commit: 27baaa13e9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4528
5 changed files with 109 additions and 98 deletions
|
@ -148,11 +148,7 @@ String TransformationStyleValue::to_string(SerializationMode mode) const
|
|||
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)
|
||||
if (value.as_length().length().raw_value() == 0 && value.as_length().length().type() == Length::Type::Px)
|
||||
return {};
|
||||
}
|
||||
return value.to_string(mode);
|
||||
|
@ -160,13 +156,19 @@ String TransformationStyleValue::to_string(SerializationMode mode) const
|
|||
|
||||
auto x_value = resolve_to_string(m_properties.values[0]);
|
||||
auto y_value = resolve_to_string(m_properties.values[1]);
|
||||
// FIXME: 3D translation
|
||||
Optional<String> z_value;
|
||||
if (m_properties.values.size() == 3 && (!m_properties.values[2]->is_length() || m_properties.values[2]->as_length().length() != Length::make_px(0)))
|
||||
z_value = resolve_to_string(m_properties.values[2]);
|
||||
|
||||
StringBuilder builder;
|
||||
builder.append(x_value.value_or("0px"_string));
|
||||
if (y_value.has_value()) {
|
||||
if (y_value.has_value() || z_value.has_value()) {
|
||||
builder.append(" "sv);
|
||||
builder.append(y_value.value());
|
||||
builder.append(y_value.value_or("0px"_string));
|
||||
}
|
||||
if (z_value.has_value()) {
|
||||
builder.append(" "sv);
|
||||
builder.append(z_value.value());
|
||||
}
|
||||
|
||||
return builder.to_string_without_validation();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue