LibWeb/CSS: Extract SerializationMode into its own header

Prep for using this to serialize dimension types, and perhaps other
things in the future.
This commit is contained in:
Sam Atkins 2025-05-16 19:20:24 +01:00 committed by Tim Ledbetter
commit eec4365542
Notes: github-actions[bot] 2025-05-17 06:54:49 +00:00
26 changed files with 112 additions and 99 deletions

View file

@ -426,7 +426,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
};
Vector<NameAndValue> properties;
as<DOM::Element>(*layout_node.dom_node()).computed_properties()->for_each_property([&](auto property_id, auto& value) {
properties.append({ CSS::string_from_property_id(property_id), value.to_string(CSS::CSSStyleValue::SerializationMode::Normal) });
properties.append({ CSS::string_from_property_id(property_id), value.to_string(CSS::SerializationMode::Normal) });
});
quick_sort(properties, [](auto& a, auto& b) { return a.name < b.name; });
@ -827,14 +827,14 @@ void dump_style_properties(StringBuilder& builder, CSS::CSSStyleProperties const
builder.appendff("Declarations ({}):\n", declaration.length());
for (auto& property : declaration.properties()) {
indent(builder, indent_levels);
builder.appendff(" {}: '{}'", CSS::string_from_property_id(property.property_id), property.value->to_string(CSS::CSSStyleValue::SerializationMode::Normal));
builder.appendff(" {}: '{}'", CSS::string_from_property_id(property.property_id), property.value->to_string(CSS::SerializationMode::Normal));
if (property.important == CSS::Important::Yes)
builder.append(" \033[31;1m!important\033[0m"sv);
builder.append('\n');
}
for (auto& property : declaration.custom_properties()) {
indent(builder, indent_levels);
builder.appendff(" {}: '{}'", property.key, property.value.value->to_string(CSS::CSSStyleValue::SerializationMode::Normal));
builder.appendff(" {}: '{}'", property.key, property.value.value->to_string(CSS::SerializationMode::Normal));
if (property.value.important == CSS::Important::Yes)
builder.append(" \033[31;1m!important\033[0m"sv);
builder.append('\n');
@ -847,7 +847,7 @@ void dump_descriptors(StringBuilder& builder, CSS::CSSDescriptors const& descrip
builder.appendff("Declarations ({}):\n", descriptors.length());
for (auto const& descriptor : descriptors.descriptors()) {
indent(builder, indent_levels);
builder.appendff(" {}: '{}'", CSS::to_string(descriptor.descriptor_id), descriptor.value->to_string(CSS::CSSStyleValue::SerializationMode::Normal));
builder.appendff(" {}: '{}'", CSS::to_string(descriptor.descriptor_id), descriptor.value->to_string(CSS::SerializationMode::Normal));
builder.append('\n');
}
}