mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibWeb: Use shortest serialization for shorthands with repeated values
For shorthands where all the values are repeated, we now only output the value once.
This commit is contained in:
parent
528af90cd4
commit
54351e7327
Notes:
github-actions[bot]
2025-03-20 13:32:03 +00:00
Author: https://github.com/tcl3
Commit: 54351e7327
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4016
Reviewed-by: https://github.com/gmta ✅
8 changed files with 81 additions and 30 deletions
|
@ -396,6 +396,17 @@ String ShorthandStyleValue::to_string(SerializationMode mode) const
|
|||
return builder.to_string_without_validation();
|
||||
}
|
||||
default:
|
||||
auto all_properties_same_value = true;
|
||||
auto first_property_value = m_properties.values.first();
|
||||
for (auto i = 1u; i < m_properties.values.size(); ++i) {
|
||||
if (m_properties.values[i] != first_property_value) {
|
||||
all_properties_same_value = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (all_properties_same_value)
|
||||
return first_property_value->to_string(mode);
|
||||
|
||||
StringBuilder builder;
|
||||
auto first = true;
|
||||
for (auto& value : m_properties.values) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue