From da189570635855dcbfa81860998dce41f441680f Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Sun, 3 Mar 2024 09:18:12 -0700 Subject: [PATCH] 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 --- Userland/Libraries/LibWeb/CSS/Serialize.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/CSS/Serialize.cpp b/Userland/Libraries/LibWeb/CSS/Serialize.cpp index 42fcdd1b34..59abb82601 100644 --- a/Userland/Libraries/LibWeb/CSS/Serialize.cpp +++ b/Userland/Libraries/LibWeb/CSS/Serialize.cpp @@ -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)