1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:57:45 +00:00

LibWeb: Limit color alpha values to 4 decimal places when serializing

The spec explicitly mentions that these values need to round-trip, and
4 decimal places is enough for 8-bit values
This commit is contained in:
Matthew Olsson 2024-03-03 09:18:12 -07:00 committed by Alexander Kalenik
parent 0487485fb1
commit da18957063

View file

@ -144,7 +144,7 @@ void serialize_a_srgb_value(StringBuilder& builder, Color color)
if (color.alpha() == 255)
builder.appendff("rgb({}, {}, {})"sv, color.red(), color.green(), color.blue());
else
builder.appendff("rgba({}, {}, {}, {})"sv, color.red(), color.green(), color.blue(), (float)(color.alpha()) / 255.0f);
builder.appendff("rgba({}, {}, {}, {:.4})"sv, color.red(), color.green(), color.blue(), (float)(color.alpha()) / 255.0f);
}
String escape_a_character(u32 character)